his_api_controller.go 1.7MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  116. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. //beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. //beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  159. //beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  160. //beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  171. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  172. //beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  173. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  174. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  175. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  176. }
  177. func (c *HisApiController) Get5101() {
  178. adminUser := c.GetAdminUserInfo()
  179. admin_user_id, _ := c.GetInt64("admin_user_id")
  180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  182. if miConfig.MdtrtareaAdmvs == "341203" {
  183. fmt.Println(miConfig.SecretKey)
  184. var res models.Result9001Two
  185. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  187. resp, requestErr := http.Get(api)
  188. if requestErr != nil {
  189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  190. return
  191. }
  192. body, ioErr := ioutil.ReadAll(resp.Body)
  193. if ioErr != nil {
  194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. var respJSON map[string]interface{}
  199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  202. return
  203. }
  204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  205. if status == "0" {
  206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  207. c.ServeSuccessJSON(map[string]interface{}{
  208. "failed_code": -10,
  209. "msg": err_msg,
  210. })
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. sign := models.HisSignIn{
  224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  225. SignNo: res.Output.Signinoutb.SignNo,
  226. SignTime: "",
  227. Ctime: time.Now().Unix(),
  228. Mtime: time.Now().Unix(),
  229. Status: 1,
  230. InputLog: "",
  231. OutputLog: "",
  232. FixmedinsCode: miConfig.Code,
  233. }
  234. err := service.CreateSignIn(&sign)
  235. if err == nil {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "msg": "签到成功",
  238. })
  239. }
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": res.ErrMsg,
  244. })
  245. return
  246. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  247. //return
  248. }
  249. } else if miConfig.MdtrtareaAdmvs == "340699" {
  250. fmt.Println(miConfig.SecretKey)
  251. var res models.Result9001Two
  252. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  254. resp, requestErr := http.Get(api)
  255. if requestErr != nil {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. body, ioErr := ioutil.ReadAll(resp.Body)
  260. if ioErr != nil {
  261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  263. return
  264. }
  265. var respJSON map[string]interface{}
  266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. return
  270. }
  271. status := respJSON["data"].(map[string]interface{})["status"].(string)
  272. if status == "0" {
  273. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": err_msg,
  277. })
  278. return
  279. }
  280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  281. result, _ := json.Marshal(respJSON)
  282. fmt.Println("log")
  283. fmt.Println(string(result))
  284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  285. utils.ErrorLog("解析失败:%v", err)
  286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  287. return
  288. }
  289. if res.Infcode == 0 {
  290. sign := models.HisSignIn{
  291. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  292. SignNo: res.Output.Signinoutb.SignNo,
  293. SignTime: "",
  294. Ctime: time.Now().Unix(),
  295. Mtime: time.Now().Unix(),
  296. Status: 1,
  297. InputLog: "",
  298. OutputLog: "",
  299. FixmedinsCode: miConfig.Code,
  300. }
  301. err := service.CreateSignIn(&sign)
  302. if err == nil {
  303. c.ServeSuccessJSON(map[string]interface{}{
  304. "msg": "查询成功",
  305. })
  306. }
  307. } else {
  308. c.ServeSuccessJSON(map[string]interface{}{
  309. "failed_code": -10,
  310. "msg": res.ErrMsg,
  311. })
  312. return
  313. }
  314. }
  315. }
  316. func (c *HisApiController) Get5102() {
  317. adminUser := c.GetAdminUserInfo()
  318. admin_user_id, _ := c.GetInt64("admin_user_id")
  319. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  320. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  321. if miConfig.MdtrtareaAdmvs == "341203" {
  322. fmt.Println(miConfig.SecretKey)
  323. var res models.Result9001Two
  324. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  326. resp, requestErr := http.Get(api)
  327. if requestErr != nil {
  328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  329. return
  330. }
  331. body, ioErr := ioutil.ReadAll(resp.Body)
  332. if ioErr != nil {
  333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  335. return
  336. }
  337. var respJSON map[string]interface{}
  338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  341. return
  342. }
  343. status := respJSON["data"].(map[string]interface{})["status"].(string)
  344. if status == "0" {
  345. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "failed_code": -10,
  348. "msg": err_msg,
  349. })
  350. return
  351. }
  352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  353. result, _ := json.Marshal(respJSON)
  354. fmt.Println("log")
  355. fmt.Println(string(result))
  356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  357. utils.ErrorLog("解析失败:%v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. if res.Infcode == 0 {
  362. sign := models.HisSignIn{
  363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  364. SignNo: res.Output.Signinoutb.SignNo,
  365. SignTime: "",
  366. Ctime: time.Now().Unix(),
  367. Mtime: time.Now().Unix(),
  368. Status: 1,
  369. InputLog: "",
  370. OutputLog: "",
  371. FixmedinsCode: miConfig.Code,
  372. }
  373. err := service.CreateSignIn(&sign)
  374. if err == nil {
  375. c.ServeSuccessJSON(map[string]interface{}{
  376. "msg": "签到成功",
  377. })
  378. }
  379. } else {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. return
  385. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  386. //return
  387. }
  388. } else if miConfig.MdtrtareaAdmvs == "340699" {
  389. fmt.Println(miConfig.SecretKey)
  390. var res models.Result9001Two
  391. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  392. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  393. resp, requestErr := http.Get(api)
  394. if requestErr != nil {
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. body, ioErr := ioutil.ReadAll(resp.Body)
  399. if ioErr != nil {
  400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  402. return
  403. }
  404. var respJSON map[string]interface{}
  405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. status := respJSON["data"].(map[string]interface{})["status"].(string)
  411. if status == "0" {
  412. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "failed_code": -10,
  415. "msg": err_msg,
  416. })
  417. return
  418. }
  419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  420. result, _ := json.Marshal(respJSON)
  421. fmt.Println("log")
  422. fmt.Println(string(result))
  423. if err := json.Unmarshal([]byte(result), &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == 0 {
  429. sign := models.HisSignIn{
  430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  431. SignNo: res.Output.Signinoutb.SignNo,
  432. SignTime: "",
  433. Ctime: time.Now().Unix(),
  434. Mtime: time.Now().Unix(),
  435. Status: 1,
  436. InputLog: "",
  437. OutputLog: "",
  438. FixmedinsCode: miConfig.Code,
  439. }
  440. err := service.CreateSignIn(&sign)
  441. if err == nil {
  442. c.ServeSuccessJSON(map[string]interface{}{
  443. "msg": "查询成功",
  444. })
  445. }
  446. } else {
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "failed_code": -10,
  449. "msg": res.ErrMsg,
  450. })
  451. return
  452. }
  453. }
  454. }
  455. func (c *HisApiController) Get3201() {
  456. adminUser := c.GetAdminUserInfo()
  457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  458. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  459. var response Response
  460. if err := json.Unmarshal([]byte(result), &response); err != nil {
  461. fmt.Println("Error decoding JSON:", err)
  462. return
  463. }
  464. }
  465. func (c *HisApiController) TestNet() {
  466. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  467. //return
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "msg": "成功",
  470. })
  471. }
  472. func (c *HisApiController) Get3508() {
  473. admin_user_id, _ := c.GetInt64("admin_user_id")
  474. drug_id, _ := c.GetInt64("id")
  475. start_time := c.GetString("start_time")
  476. end_time := c.GetString("end_time")
  477. adminUser := c.GetAdminUserInfo()
  478. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  480. drug, _ := service.GetDrugByID(drug_id)
  481. var struct3508 models.Struct3508
  482. struct3508.OrgName = miConfig.OrgName
  483. struct3508.FixmedinsCode = miConfig.Code
  484. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  485. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  486. struct3508.AccessKey = miConfig.AccessKey
  487. struct3508.Opter = curRoles.UserName
  488. struct3508.RequestUrl = miConfig.Url
  489. struct3508.Url = miConfig.Url
  490. struct3508.AppId = miConfig.Cainfo
  491. struct3508.AppSecret = miConfig.AppSecret
  492. struct3508.Enckey = miConfig.EncKey
  493. struct3508.SignKey = miConfig.SignKey
  494. struct3508.SecretKey = miConfig.SecretKey
  495. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  496. struct3508.Begndate = start_time
  497. struct3508.Enddate = end_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  501. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  502. saveLog(result1, result2, "3508", "3508")
  503. var res models.Result3508
  504. var respJSON2 map[string]interface{}
  505. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. userJSONBytes2, _ := json.Marshal(respJSON2)
  511. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  512. utils.ErrorLog("解析失败:%v", err)
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  514. return
  515. }
  516. if res.Infcode == -1 {
  517. c.ServeSuccessJSON(map[string]interface{}{
  518. "failed_code": -10,
  519. "msg": res.ErrMsg,
  520. })
  521. } else {
  522. c.ServeSuccessJSON(map[string]interface{}{
  523. "info": res.Output,
  524. })
  525. }
  526. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  527. result1, result2, _ := service.FJyb3508(struct3508)
  528. saveLog(result1, result2, "3508", "3508")
  529. var res models.Result3508
  530. var respJSON2 map[string]interface{}
  531. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  534. return
  535. }
  536. userJSONBytes2, _ := json.Marshal(respJSON2)
  537. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  538. utils.ErrorLog("解析失败:%v", err)
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  540. return
  541. }
  542. if res.Infcode == -1 {
  543. c.ServeSuccessJSON(map[string]interface{}{
  544. "failed_code": -10,
  545. "msg": res.ErrMsg,
  546. })
  547. } else {
  548. c.ServeSuccessJSON(map[string]interface{}{
  549. "info": res.Output,
  550. })
  551. }
  552. }
  553. }
  554. func (c *HisApiController) Get3509() {
  555. admin_user_id, _ := c.GetInt64("admin_user_id")
  556. drug_id, _ := c.GetInt64("id")
  557. start_time := c.GetString("start_time")
  558. end_time := c.GetString("end_time")
  559. adminUser := c.GetAdminUserInfo()
  560. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  562. drug, _ := service.GetDrugByID(drug_id)
  563. var struct3508 models.Struct3509
  564. struct3508.OrgName = miConfig.OrgName
  565. struct3508.FixmedinsCode = miConfig.Code
  566. struct3508.AccessKey = miConfig.AccessKey
  567. struct3508.Opter = curRoles.UserName
  568. struct3508.RequestUrl = miConfig.Url
  569. struct3508.Url = miConfig.Url
  570. struct3508.AppId = miConfig.Cainfo
  571. struct3508.AppSecret = miConfig.AppSecret
  572. struct3508.Enckey = miConfig.EncKey
  573. struct3508.SignKey = miConfig.SignKey
  574. struct3508.SecretKey = miConfig.SecretKey
  575. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  576. struct3508.Begndate = start_time
  577. struct3508.Enddate = end_time
  578. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  579. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  580. saveLog(result1, result2, "3509", "3509")
  581. var res models.Result3508
  582. var respJSON2 map[string]interface{}
  583. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  586. return
  587. }
  588. userJSONBytes2, _ := json.Marshal(respJSON2)
  589. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  590. utils.ErrorLog("解析失败:%v", err)
  591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  592. return
  593. }
  594. if res.Infcode == -1 {
  595. c.ServeSuccessJSON(map[string]interface{}{
  596. "failed_code": -10,
  597. "msg": res.ErrMsg,
  598. })
  599. } else {
  600. c.ServeSuccessJSON(map[string]interface{}{
  601. "info": res.Output,
  602. })
  603. }
  604. } else {
  605. result1, result2, _ := service.FJyb3509(struct3508)
  606. saveLog(result1, result2, "3509", "3509")
  607. var res models.Result3509
  608. var respJSON2 map[string]interface{}
  609. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  612. return
  613. }
  614. userJSONBytes2, _ := json.Marshal(respJSON2)
  615. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  616. utils.ErrorLog("解析失败:%v", err)
  617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  618. return
  619. }
  620. if res.Infcode == -1 {
  621. c.ServeSuccessJSON(map[string]interface{}{
  622. "failed_code": -10,
  623. "msg": res.ErrMsg,
  624. })
  625. } else {
  626. c.ServeSuccessJSON(map[string]interface{}{
  627. "info": res.Output,
  628. })
  629. }
  630. }
  631. }
  632. func (c *HisApiController) Get3510() {
  633. admin_user_id, _ := c.GetInt64("admin_user_id")
  634. drug_id, _ := c.GetInt64("id")
  635. start_time := c.GetString("start_time")
  636. end_time := c.GetString("end_time")
  637. adminUser := c.GetAdminUserInfo()
  638. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  640. drug, _ := service.GetDrugByID(drug_id)
  641. var struct3508 models.Struct3510
  642. struct3508.FixmedinsCode = miConfig.Code
  643. struct3508.OrgName = miConfig.OrgName
  644. struct3508.AccessKey = miConfig.AccessKey
  645. struct3508.Opter = curRoles.UserName
  646. struct3508.RequestUrl = miConfig.Url
  647. struct3508.Url = miConfig.Url
  648. struct3508.AppId = miConfig.Cainfo
  649. struct3508.AppSecret = miConfig.AppSecret
  650. struct3508.Enckey = miConfig.EncKey
  651. struct3508.SignKey = miConfig.SignKey
  652. struct3508.SecretKey = miConfig.SecretKey
  653. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  654. struct3508.Begndate = start_time
  655. struct3508.Enddate = end_time
  656. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  657. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  658. saveLog(result1, result2, "3510", "3510")
  659. var res models.Result3510
  660. var respJSON2 map[string]interface{}
  661. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. }
  666. userJSONBytes2, _ := json.Marshal(respJSON2)
  667. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  668. utils.ErrorLog("解析失败:%v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. if res.Infcode == -1 {
  673. c.ServeSuccessJSON(map[string]interface{}{
  674. "failed_code": -10,
  675. "msg": res.ErrMsg,
  676. })
  677. } else {
  678. c.ServeSuccessJSON(map[string]interface{}{
  679. "info": res.Output,
  680. })
  681. }
  682. } else {
  683. result1, result2, _ := service.FJyb3510(struct3508)
  684. saveLog(result1, result2, "3510", "3510")
  685. var res models.Result3510
  686. var respJSON2 map[string]interface{}
  687. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return
  691. }
  692. userJSONBytes2, _ := json.Marshal(respJSON2)
  693. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  694. utils.ErrorLog("解析失败:%v", err)
  695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  696. return
  697. }
  698. if res.Infcode == -1 {
  699. c.ServeSuccessJSON(map[string]interface{}{
  700. "failed_code": -10,
  701. "msg": res.ErrMsg,
  702. })
  703. } else {
  704. c.ServeSuccessJSON(map[string]interface{}{
  705. "info": res.Output,
  706. })
  707. }
  708. }
  709. }
  710. func (c *HisApiController) Get3511() {
  711. admin_user_id, _ := c.GetInt64("admin_user_id")
  712. drug_id, _ := c.GetInt64("id")
  713. start_time := c.GetString("start_time")
  714. end_time := c.GetString("end_time")
  715. adminUser := c.GetAdminUserInfo()
  716. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  717. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  718. drug, _ := service.GetDrugByID(drug_id)
  719. var struct3508 models.Struct3511
  720. struct3508.FixmedinsCode = miConfig.Code
  721. struct3508.OrgName = miConfig.OrgName
  722. struct3508.AccessKey = miConfig.AccessKey
  723. struct3508.Opter = curRoles.UserName
  724. struct3508.RequestUrl = miConfig.Url
  725. struct3508.Url = miConfig.Url
  726. struct3508.AppId = miConfig.Cainfo
  727. struct3508.AppSecret = miConfig.AppSecret
  728. struct3508.Enckey = miConfig.EncKey
  729. struct3508.SignKey = miConfig.SignKey
  730. struct3508.SecretKey = miConfig.SecretKey
  731. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  732. struct3508.Begndate = start_time
  733. struct3508.Enddate = end_time
  734. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  735. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  736. saveLog(result1, result2, "3511", "3511")
  737. var res models.Result3511
  738. var respJSON2 map[string]interface{}
  739. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  742. return
  743. }
  744. userJSONBytes2, _ := json.Marshal(respJSON2)
  745. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. if res.Infcode == -1 {
  751. c.ServeSuccessJSON(map[string]interface{}{
  752. "failed_code": -10,
  753. "msg": res.ErrMsg,
  754. })
  755. } else {
  756. c.ServeSuccessJSON(map[string]interface{}{
  757. "info": res.Output,
  758. })
  759. }
  760. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  761. var res models.Result3511
  762. //安徽
  763. data := make(map[string]interface{})
  764. data["struct_3511s"] = struct3508
  765. client := &http.Client{}
  766. bytesData, _ := json.Marshal(data)
  767. var req *http.Request
  768. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3511", bytes.NewReader(bytesData))
  769. resp, _ := client.Do(req)
  770. defer resp.Body.Close()
  771. body, ioErr := ioutil.ReadAll(resp.Body)
  772. if ioErr != nil {
  773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  774. }
  775. var respJSON map[string]interface{}
  776. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  779. return
  780. }
  781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  782. result, _ := json.Marshal(respJSON)
  783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  784. //utils.ErrorLog("解析失败:%v", err)
  785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  786. return
  787. }
  788. if res.Infcode == -1 {
  789. c.ServeSuccessJSON(map[string]interface{}{
  790. "failed_code": -10,
  791. "msg": res.ErrMsg,
  792. })
  793. } else {
  794. c.ServeSuccessJSON(map[string]interface{}{
  795. "info": res.Output,
  796. })
  797. }
  798. } else {
  799. result1, result2, _ := service.FJyb3511(struct3508)
  800. saveLog(result1, result2, "3511", "3511")
  801. var res models.Result3511
  802. var respJSON2 map[string]interface{}
  803. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  806. return
  807. }
  808. userJSONBytes2, _ := json.Marshal(respJSON2)
  809. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  810. utils.ErrorLog("解析失败:%v", err)
  811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  812. return
  813. }
  814. if res.Infcode == -1 {
  815. c.ServeSuccessJSON(map[string]interface{}{
  816. "failed_code": -10,
  817. "msg": res.ErrMsg,
  818. })
  819. } else {
  820. c.ServeSuccessJSON(map[string]interface{}{
  821. "info": res.Output,
  822. })
  823. }
  824. }
  825. }
  826. func (c *HisApiController) Get3512() {
  827. admin_user_id, _ := c.GetInt64("admin_user_id")
  828. drug_id, _ := c.GetInt64("id")
  829. start_time := c.GetString("start_time")
  830. end_time := c.GetString("end_time")
  831. adminUser := c.GetAdminUserInfo()
  832. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  833. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  834. drug, _ := service.GetDrugByIDTwo(drug_id, adminUser.CurrentOrgId)
  835. var infos models.Output2
  836. for _, item := range drug {
  837. var struct3508 models.Struct3512
  838. struct3508.FixmedinsCode = miConfig.Code
  839. struct3508.OrgName = miConfig.OrgName
  840. struct3508.AccessKey = miConfig.AccessKey
  841. struct3508.Opter = curRoles.UserName
  842. struct3508.RequestUrl = miConfig.Url
  843. struct3508.Url = miConfig.Url
  844. struct3508.AppId = miConfig.Cainfo
  845. struct3508.AppSecret = miConfig.AppSecret
  846. struct3508.Enckey = miConfig.EncKey
  847. struct3508.SignKey = miConfig.SignKey
  848. struct3508.SecretKey = miConfig.SecretKey
  849. struct3508.MedListCodg = item.MedicalInsuranceNumber
  850. struct3508.Begndate = start_time
  851. struct3508.Enddate = end_time
  852. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  853. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  854. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  855. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  856. saveLog(result1, result2, "3512", "3512")
  857. var res models.Result3512
  858. var respJSON2 map[string]interface{}
  859. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  862. return
  863. }
  864. userJSONBytes2, _ := json.Marshal(respJSON2)
  865. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  866. utils.ErrorLog("解析失败:%v", err)
  867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  868. return
  869. }
  870. for _, item := range res.Output {
  871. if item.ValiFlag == "1" {
  872. infos = append(infos, item)
  873. }
  874. }
  875. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  876. result1, result2, _ := service.FJyb3512(struct3508)
  877. saveLog(result1, result2, "3512", "3512")
  878. var res models.Result3512
  879. var respJSON2 map[string]interface{}
  880. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  883. return
  884. }
  885. userJSONBytes2, _ := json.Marshal(respJSON2)
  886. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  887. utils.ErrorLog("解析失败:%v", err)
  888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  889. return
  890. }
  891. for _, item := range res.Output {
  892. if item.ValiFlag == "1" {
  893. infos = append(infos, item)
  894. }
  895. }
  896. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  897. var res models.Result3512
  898. //安徽
  899. data := make(map[string]interface{})
  900. data["struct_3512s"] = struct3508
  901. client := &http.Client{}
  902. bytesData, _ := json.Marshal(data)
  903. var req *http.Request
  904. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3512", bytes.NewReader(bytesData))
  905. resp, _ := client.Do(req)
  906. defer resp.Body.Close()
  907. body, ioErr := ioutil.ReadAll(resp.Body)
  908. if ioErr != nil {
  909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  910. }
  911. var respJSON map[string]interface{}
  912. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  915. return
  916. }
  917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  918. result, _ := json.Marshal(respJSON)
  919. if err := json.Unmarshal([]byte(result), &res); err != nil {
  920. //utils.ErrorLog("解析失败:%v", err)
  921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  922. return
  923. }
  924. for _, item := range res.Output {
  925. if item.ValiFlag == "1" {
  926. infos = append(infos, item)
  927. }
  928. }
  929. }
  930. }
  931. c.ServeSuccessJSON(map[string]interface{}{
  932. "info": infos,
  933. })
  934. }
  935. func (c *HisApiController) Get3513() {
  936. admin_user_id, _ := c.GetInt64("admin_user_id")
  937. drug_id, _ := c.GetInt64("id")
  938. start_time := c.GetString("start_time")
  939. end_time := c.GetString("end_time")
  940. adminUser := c.GetAdminUserInfo()
  941. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  942. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  943. //drug, _ := service.GetDrugByID(drug_id)
  944. drug, _ := service.GetDrugByIDTwo(drug_id, adminUser.CurrentOrgId)
  945. var infos models.Output3
  946. for _, item := range drug {
  947. var struct3508 models.Struct3513
  948. struct3508.FixmedinsCode = miConfig.Code
  949. struct3508.OrgName = miConfig.OrgName
  950. struct3508.AccessKey = miConfig.AccessKey
  951. struct3508.Opter = curRoles.UserName
  952. struct3508.RequestUrl = miConfig.Url
  953. struct3508.Url = miConfig.Url
  954. struct3508.AppId = miConfig.Cainfo
  955. struct3508.AppSecret = miConfig.AppSecret
  956. struct3508.Enckey = miConfig.EncKey
  957. struct3508.SignKey = miConfig.SignKey
  958. struct3508.SecretKey = miConfig.SecretKey
  959. struct3508.MedListCodg = item.MedicalInsuranceNumber
  960. struct3508.Begndate = start_time
  961. struct3508.Enddate = end_time
  962. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  963. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  964. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  965. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  966. saveLog(result1, result2, "3513", "3513")
  967. var res models.Result3513
  968. var respJSON2 map[string]interface{}
  969. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  972. return
  973. }
  974. userJSONBytes2, _ := json.Marshal(respJSON2)
  975. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  976. utils.ErrorLog("解析失败:%v", err)
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. infos = append(infos, res.Output...)
  981. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  982. result1, result2, _ := service.FJyb3513(struct3508)
  983. saveLog(result1, result2, "3513", "3513")
  984. var res models.Result3513
  985. var respJSON2 map[string]interface{}
  986. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  989. return
  990. }
  991. userJSONBytes2, _ := json.Marshal(respJSON2)
  992. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  993. utils.ErrorLog("解析失败:%v", err)
  994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. return
  996. }
  997. infos = append(infos, res.Output...)
  998. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  999. var res models.Result3513
  1000. //安徽
  1001. data := make(map[string]interface{})
  1002. data["struct_3513s"] = struct3508
  1003. client := &http.Client{}
  1004. bytesData, _ := json.Marshal(data)
  1005. var req *http.Request
  1006. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3513", bytes.NewReader(bytesData))
  1007. resp, _ := client.Do(req)
  1008. defer resp.Body.Close()
  1009. body, ioErr := ioutil.ReadAll(resp.Body)
  1010. if ioErr != nil {
  1011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1012. }
  1013. var respJSON map[string]interface{}
  1014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1017. return
  1018. }
  1019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1020. result, _ := json.Marshal(respJSON)
  1021. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1022. //utils.ErrorLog("解析失败:%v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. infos = append(infos, res.Output...)
  1027. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") { //
  1028. result1, result2 := service.JXyb3513(struct3508, struct3508.SecretKey, struct3508.AccessKey, struct3508.RequestUrl)
  1029. saveLog(result1, result2, "3513", "3513")
  1030. var res models.Result3513
  1031. var respJSON2 map[string]interface{}
  1032. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1035. return
  1036. }
  1037. userJSONBytes2, _ := json.Marshal(respJSON2)
  1038. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1039. utils.ErrorLog("解析失败:%v", err)
  1040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1041. return
  1042. }
  1043. infos = append(infos, res.Output...)
  1044. }
  1045. }
  1046. type Newinfo struct {
  1047. FixmedinsCode string
  1048. MedListCodg string
  1049. MedinsListCodg string
  1050. MedinsListName string
  1051. FixmedinsBchno string
  1052. MdtrtId string
  1053. MdtrtSetlType string
  1054. BkkpSn string
  1055. DrugTracCodg string
  1056. PsnNo string
  1057. PsnCertType string
  1058. Certno string
  1059. PsnName string
  1060. Memo string
  1061. TrdnFlag string
  1062. UpdtTime string
  1063. OpterName string
  1064. Rid string
  1065. CrteTime string
  1066. OptTime string
  1067. OpterId string
  1068. CrterName string
  1069. CrterId string
  1070. OptinsNo string
  1071. }
  1072. var Newinfos []Newinfo
  1073. for _, item := range infos {
  1074. var ni Newinfo
  1075. patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1076. //patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1077. numbers := strings.Split(item.FixmedinsBchno, "-")
  1078. flow := service.GetSaleDate(numbers[1])
  1079. ni.MdtrtId = item.MdtrtId
  1080. ni.UpdtTime = flow.SaleDate
  1081. ni.PsnName = patient.Name
  1082. ni.Certno = item.Certno
  1083. ni.MedinsListName = item.MedinsListName
  1084. ni.FixmedinsBchno = item.FixmedinsBchno
  1085. ni.DrugTracCodg = item.DrugTracCodg
  1086. ni.MedListCodg = patient.Name
  1087. Newinfos = append(Newinfos, ni)
  1088. }
  1089. c.ServeSuccessJSON(map[string]interface{}{
  1090. "info": Newinfos,
  1091. })
  1092. }
  1093. func (c *HisApiController) Get35081() {
  1094. admin_user_id, _ := c.GetInt64("admin_user_id")
  1095. drug_id, _ := c.GetInt64("id")
  1096. //start_time := c.GetString("start_time")
  1097. //end_time := c.GetString("end_time")
  1098. page, _ := c.GetInt("page")
  1099. adminUser := c.GetAdminUserInfo()
  1100. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1101. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1102. drug, _ := service.GetDrugByID(drug_id)
  1103. var struct3508 models.Struct35081
  1104. struct3508.FixmedinsCode = miConfig.Code
  1105. struct3508.OrgName = miConfig.OrgName
  1106. struct3508.AccessKey = miConfig.AccessKey
  1107. struct3508.Opter = curRoles.UserName
  1108. struct3508.RequestUrl = miConfig.Url
  1109. struct3508.Url = miConfig.Url
  1110. struct3508.AppId = miConfig.Cainfo
  1111. struct3508.AppSecret = miConfig.AppSecret
  1112. struct3508.Enckey = miConfig.EncKey
  1113. struct3508.SignKey = miConfig.SignKey
  1114. struct3508.SecretKey = miConfig.SecretKey
  1115. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1116. struct3508.PageNum = page
  1117. struct3508.PageSize = 10
  1118. result1, result2, _ := service.FJyb35081(struct3508)
  1119. saveLog(result1, result2, "35081", "35081")
  1120. var res models.Result35081
  1121. var respJSON2 map[string]interface{}
  1122. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. userJSONBytes2, _ := json.Marshal(respJSON2)
  1128. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1129. utils.ErrorLog("解析失败:%v", err)
  1130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1131. return
  1132. }
  1133. if res.Infcode == -1 {
  1134. c.ServeSuccessJSON(map[string]interface{}{
  1135. "failed_code": -10,
  1136. "msg": res.ErrMsg,
  1137. })
  1138. } else {
  1139. c.ServeSuccessJSON(map[string]interface{}{
  1140. "info": res.Output,
  1141. })
  1142. }
  1143. }
  1144. func (c *HisApiController) Get35082() {
  1145. admin_user_id, _ := c.GetInt64("admin_user_id")
  1146. drug_id, _ := c.GetInt64("id")
  1147. //start_time := c.GetString("start_time")
  1148. //end_time := c.GetString("end_time")
  1149. page, _ := c.GetInt("page")
  1150. adminUser := c.GetAdminUserInfo()
  1151. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1152. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1153. drug, _ := service.GetDrugByID(drug_id)
  1154. var struct3508 models.Struct35082
  1155. struct3508.FixmedinsCode = miConfig.Code
  1156. struct3508.OrgName = miConfig.OrgName
  1157. struct3508.AccessKey = miConfig.AccessKey
  1158. struct3508.Opter = curRoles.UserName
  1159. struct3508.RequestUrl = miConfig.Url
  1160. struct3508.Url = miConfig.Url
  1161. struct3508.AppId = miConfig.Cainfo
  1162. struct3508.AppSecret = miConfig.AppSecret
  1163. struct3508.Enckey = miConfig.EncKey
  1164. struct3508.SignKey = miConfig.SignKey
  1165. struct3508.SecretKey = miConfig.SecretKey
  1166. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1167. struct3508.PageNum = page
  1168. struct3508.PageSize = 10
  1169. result1, result2, _ := service.FJyb35082(struct3508)
  1170. saveLog(result1, result2, "35082", "35082")
  1171. var res models.Result35082
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result1)), &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. if res.Infcode == -1 {
  1185. c.ServeSuccessJSON(map[string]interface{}{
  1186. "failed_code": -10,
  1187. "msg": res.ErrMsg,
  1188. })
  1189. } else {
  1190. c.ServeSuccessJSON(map[string]interface{}{
  1191. "info": res.Output,
  1192. })
  1193. }
  1194. }
  1195. func IsDigit(s string) bool {
  1196. re := regexp.MustCompile("^[0-9]+$")
  1197. return re.MatchString(s)
  1198. }
  1199. func (c *HisApiController) FJ3501AND3502() {
  1200. ids := c.GetString("ids")
  1201. admin_user_id, _ := c.GetInt64("admin_user_id")
  1202. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1203. id_arr := strings.Split(ids, ",")
  1204. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1205. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1206. //规则判断
  1207. var errs []string
  1208. for _, drug := range drugs {
  1209. if drug.IsPc == 0 {
  1210. if len(drug.DrugCode) > 0 {
  1211. codes := strings.Split(drug.DrugCode, ",")
  1212. for _, code := range codes {
  1213. if len(code) > 0 {
  1214. if len(code) != 20 {
  1215. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1216. }
  1217. if IsDigit(code) == false {
  1218. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1219. }
  1220. }
  1221. }
  1222. }
  1223. }
  1224. }
  1225. if len(errs) > 0 {
  1226. c.ServeSuccessJSON(map[string]interface{}{
  1227. "failed_code": -10,
  1228. "msg": errs,
  1229. })
  1230. return
  1231. }
  1232. //库盘
  1233. for _, drug := range drugs {
  1234. if drug.IsPc == 0 {
  1235. var res2 ResultSix
  1236. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1237. var struct3501 models.Struct3501
  1238. struct3501.Code = miConfig.Code
  1239. struct3501.OrgName = miConfig.OrgName
  1240. struct3501.AccessKey = miConfig.AccessKey
  1241. struct3501.Opter = roles.UserName
  1242. struct3501.RequestUrl = miConfig.Url
  1243. struct3501.Url = miConfig.Url
  1244. struct3501.AppId = miConfig.Cainfo
  1245. struct3501.AppSecret = miConfig.AppSecret
  1246. struct3501.Enckey = miConfig.EncKey
  1247. struct3501.SignKey = miConfig.SignKey
  1248. struct3501.SecretKey = miConfig.SecretKey
  1249. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1250. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1251. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1252. struct3501.RxFlag = "1"
  1253. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1254. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1255. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1256. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1257. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1258. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1259. struct3501.FixmedinsBchno = number
  1260. struct3501.DrugTracCodg = drug.DrugCode
  1261. memo := make(map[string]interface{})
  1262. memo["pric"] = drug.Price
  1263. bytesData, _ := json.Marshal(memo)
  1264. struct3501.Memo = string(bytesData)
  1265. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1266. result1, result2, _ := service.FJyb3501(struct3501)
  1267. saveLog(result1, result2, "3501", "3501")
  1268. //saveLog(result, requestLog, "2201", "挂号")
  1269. var respJSON2 map[string]interface{}
  1270. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. return
  1274. }
  1275. userJSONBytes2, _ := json.Marshal(respJSON2)
  1276. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1277. utils.ErrorLog("解析失败:%v", err)
  1278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. return
  1280. }
  1281. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1282. data := make(map[string]interface{})
  1283. data["struct_3501s"] = struct3501
  1284. client := &http.Client{}
  1285. bytesData, _ := json.Marshal(data)
  1286. var req *http.Request
  1287. if miConfig.MdtrtareaAdmvs == "320830" {
  1288. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1289. } else {
  1290. if miConfig.MdtrtareaAdmvs == "320921" {
  1291. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1292. } else {
  1293. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1294. }
  1295. }
  1296. resp, _ := client.Do(req)
  1297. defer resp.Body.Close()
  1298. body, ioErr := ioutil.ReadAll(resp.Body)
  1299. if ioErr != nil {
  1300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1301. }
  1302. var respJSON map[string]interface{}
  1303. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1306. return
  1307. }
  1308. var resSix10265 ResultSix10265 //1101结果
  1309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1310. result, _ := json.Marshal(respJSON)
  1311. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1312. utils.ErrorLog("解析失败:%v", err)
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1314. return
  1315. }
  1316. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1317. res2.Output = resSix10265.Output
  1318. res2.ErrMsg = resSix10265.ErrMsg
  1319. res2.Cainfo = resSix10265.Cainfo
  1320. res2.WarnMsg = resSix10265.WarnMsg
  1321. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1322. res2.Infcode = infocode
  1323. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1324. data := make(map[string]interface{})
  1325. data["struct_3501s"] = struct3501
  1326. client := &http.Client{}
  1327. bytesData, _ := json.Marshal(data)
  1328. var req *http.Request
  1329. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1330. resp, _ := client.Do(req)
  1331. defer resp.Body.Close()
  1332. body, ioErr := ioutil.ReadAll(resp.Body)
  1333. if ioErr != nil {
  1334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1335. }
  1336. var respJSON map[string]interface{}
  1337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. var resSix10265 ResultSix10265 //1101结果
  1343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1344. result, _ := json.Marshal(respJSON)
  1345. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1346. utils.ErrorLog("解析失败:%v", err)
  1347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1348. return
  1349. }
  1350. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1351. res2.Output = resSix10265.Output
  1352. res2.ErrMsg = resSix10265.ErrMsg
  1353. res2.Cainfo = resSix10265.Cainfo
  1354. res2.WarnMsg = resSix10265.WarnMsg
  1355. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1356. res2.Infcode = infocode
  1357. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1358. data := make(map[string]interface{})
  1359. data["struct_3501s"] = struct3501
  1360. client := &http.Client{}
  1361. bytesData, _ := json.Marshal(data)
  1362. var req *http.Request
  1363. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1364. resp, _ := client.Do(req)
  1365. defer resp.Body.Close()
  1366. body, ioErr := ioutil.ReadAll(resp.Body)
  1367. if ioErr != nil {
  1368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1369. }
  1370. var respJSON map[string]interface{}
  1371. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. var resSix10265 ResultSix10265 //1101结果
  1377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1378. result, _ := json.Marshal(respJSON)
  1379. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1380. utils.ErrorLog("解析失败:%v", err)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1385. res2.Output = resSix10265.Output
  1386. res2.ErrMsg = resSix10265.ErrMsg
  1387. res2.Cainfo = resSix10265.Cainfo
  1388. res2.WarnMsg = resSix10265.WarnMsg
  1389. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1390. res2.Infcode = infocode
  1391. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1392. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1393. saveLog(result1, result2, "3501", "3501")
  1394. //saveLog(result, requestLog, "2201", "挂号")
  1395. var respJSON2 map[string]interface{}
  1396. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1399. return
  1400. }
  1401. userJSONBytes2, _ := json.Marshal(respJSON2)
  1402. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. }
  1408. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1409. if res2.Infcode != -1 {
  1410. drug.IsPc = 1
  1411. drug.Bchno = number
  1412. drug.PcDate = time.Now().Unix()
  1413. service.SaveW(drug)
  1414. //if err == nil {
  1415. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1416. // var struct3502 models.Struct3502
  1417. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1418. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1419. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1420. // struct3502.FixmedinsCode = miConfig.Code
  1421. // struct3502.Code = miConfig.Code
  1422. //
  1423. // struct3502.RxFlag = "0"
  1424. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1425. // struct3502.OrgName = miConfig.OrgName
  1426. // struct3502.Opter = roles.UserName
  1427. // struct3502.AccessKey = miConfig.AccessKey
  1428. // struct3502.RequestUrl = miConfig.Url
  1429. // struct3502.SecretKey = miConfig.SecretKey
  1430. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1431. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1432. // struct3502.Url = miConfig.Url
  1433. // struct3502.AppId = miConfig.Cainfo
  1434. // struct3502.AppSecret = miConfig.AppSecret
  1435. // struct3502.Enckey = miConfig.EncKey
  1436. // struct3502.SignKey = miConfig.SignKey
  1437. // struct3502.SecretKey = miConfig.SecretKey
  1438. // struct3502.DrugTracCodg = drug.DrugCode
  1439. //
  1440. // struct3502.Memo = ""
  1441. // struct3502.InvChgType = "108"
  1442. // struct3502.FixmedinsBchno = bg_number
  1443. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1444. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1445. //
  1446. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1447. // result11, result22, _ := service.FJyb3502(struct3502)
  1448. // saveLog(result11, result22, "3502", "3502")
  1449. //
  1450. // var respJSON3 map[string]interface{}
  1451. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1452. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1454. // return
  1455. // }
  1456. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1457. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1458. // utils.ErrorLog("解析失败:%v", err)
  1459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. // return
  1461. // }
  1462. //
  1463. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1464. // data := make(map[string]interface{})
  1465. // data["struct_3502s"] = struct3502
  1466. // client := &http.Client{}
  1467. // bytesData, _ := json.Marshal(data)
  1468. // var req *http.Request
  1469. // if miConfig.MdtrtareaAdmvs == "320830" {
  1470. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1471. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1472. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1473. // } else {
  1474. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1475. // }
  1476. //
  1477. // resp, _ := client.Do(req)
  1478. // defer resp.Body.Close()
  1479. // body, ioErr := ioutil.ReadAll(resp.Body)
  1480. // if ioErr != nil {
  1481. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1482. // }
  1483. // var respJSON map[string]interface{}
  1484. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1485. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1487. // return
  1488. // }
  1489. // var resSix10265 ResultSix10265 //1101结果
  1490. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1491. // result, _ := json.Marshal(respJSON)
  1492. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1493. // utils.ErrorLog("解析失败:%v", err)
  1494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1495. // return
  1496. // }
  1497. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1498. // res3.Output = resSix10265.Output
  1499. // res3.ErrMsg = resSix10265.ErrMsg
  1500. // res3.Cainfo = resSix10265.Cainfo
  1501. // res3.WarnMsg = resSix10265.WarnMsg
  1502. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1503. // res3.Infcode = infocode
  1504. //
  1505. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1506. //
  1507. // data := make(map[string]interface{})
  1508. // data["struct_3502s"] = struct3502
  1509. // client := &http.Client{}
  1510. // bytesData, _ := json.Marshal(data)
  1511. // var req *http.Request
  1512. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1513. // resp, _ := client.Do(req)
  1514. // defer resp.Body.Close()
  1515. // body, ioErr := ioutil.ReadAll(resp.Body)
  1516. // if ioErr != nil {
  1517. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1518. // }
  1519. // var respJSON map[string]interface{}
  1520. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1521. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1523. // return
  1524. // }
  1525. // var resSix10265 ResultSix10265 //1101结果
  1526. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1527. // result, _ := json.Marshal(respJSON)
  1528. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1529. // utils.ErrorLog("解析失败:%v", err)
  1530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1531. // return
  1532. // }
  1533. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1534. // res3.Output = resSix10265.Output
  1535. // res3.ErrMsg = resSix10265.ErrMsg
  1536. // res3.Cainfo = resSix10265.Cainfo
  1537. // res3.WarnMsg = resSix10265.WarnMsg
  1538. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1539. // res3.Infcode = infocode
  1540. //
  1541. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1542. //
  1543. // data := make(map[string]interface{})
  1544. // data["struct_3501s"] = struct3501
  1545. // client := &http.Client{}
  1546. // bytesData, _ := json.Marshal(data)
  1547. // var req *http.Request
  1548. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1549. // resp, _ := client.Do(req)
  1550. // defer resp.Body.Close()
  1551. // body, ioErr := ioutil.ReadAll(resp.Body)
  1552. // if ioErr != nil {
  1553. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1554. // }
  1555. // var respJSON map[string]interface{}
  1556. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1557. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1559. // return
  1560. // }
  1561. // var resSix10265 ResultSix10265 //1101结果
  1562. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1563. // result, _ := json.Marshal(respJSON)
  1564. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1565. // utils.ErrorLog("解析失败:%v", err)
  1566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1567. // return
  1568. // }
  1569. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1570. // res2.Output = resSix10265.Output
  1571. // res2.ErrMsg = resSix10265.ErrMsg
  1572. // res2.Cainfo = resSix10265.Cainfo
  1573. // res2.WarnMsg = resSix10265.WarnMsg
  1574. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1575. // res2.Infcode = infocode
  1576. //
  1577. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1578. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1579. // saveLog(result11, result22, "3502", "3502")
  1580. //
  1581. // var respJSON3 map[string]interface{}
  1582. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1583. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. // return
  1586. // }
  1587. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1588. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1589. // utils.ErrorLog("解析失败:%v", err)
  1590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1591. // return
  1592. // }
  1593. // }
  1594. // if res3.Infcode == -1 {
  1595. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1596. // c.ServeSuccessJSON(map[string]interface{}{
  1597. // "failed_code": -10,
  1598. // "msg": res3.ErrMsg,
  1599. // })
  1600. // } else {
  1601. // drug.IsBg = 1
  1602. // drug.BgBchno = bg_number
  1603. // service.SaveW(drug)
  1604. // }
  1605. //}
  1606. //} else {
  1607. } else {
  1608. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1609. }
  1610. }
  1611. //变更
  1612. }
  1613. if len(errs) == 0 {
  1614. c.ServeSuccessJSON(map[string]interface{}{
  1615. "msg": "盘存变更成功",
  1616. })
  1617. } else {
  1618. c.ServeSuccessJSON(map[string]interface{}{
  1619. "failed_code": -10,
  1620. "msg": errs,
  1621. })
  1622. }
  1623. }
  1624. func (c *HisApiController) DeletePCandBG() {
  1625. ids := c.GetString("ids")
  1626. id_arr := strings.Split(ids, ",")
  1627. admin_user_id, _ := c.GetInt64("admin_user_id")
  1628. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1629. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1630. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1631. var err []string
  1632. for _, item := range drugs {
  1633. if item.IsPc == 1 {
  1634. var res FJ3502Result
  1635. var struct3507 models.Struct3507
  1636. struct3507.FixmedinsBchno = item.Bchno
  1637. struct3507.InvDataType = "1"
  1638. struct3507.Opter = roles.UserName
  1639. struct3507.OrgName = miConfig.OrgName
  1640. struct3507.AccessKey = miConfig.AccessKey
  1641. struct3507.RequestUrl = miConfig.Url
  1642. struct3507.FixmedinsCode = miConfig.Code
  1643. struct3507.Code = miConfig.Code
  1644. struct3507.SecretKey = miConfig.SecretKey
  1645. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1646. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1647. struct3507.Url = miConfig.Url
  1648. struct3507.AppId = miConfig.Cainfo
  1649. struct3507.AppSecret = miConfig.AppSecret
  1650. struct3507.Enckey = miConfig.EncKey
  1651. struct3507.SignKey = miConfig.SignKey
  1652. struct3507.SecretKey = miConfig.SecretKey
  1653. if miConfig.MdtrtareaAdmvs == "350500" {
  1654. result, result1, _ := service.FJyb3507(struct3507)
  1655. saveLog(result, result1, "3507", "3507")
  1656. var respJSON2 map[string]interface{}
  1657. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1660. return
  1661. }
  1662. userJSONBytes2, _ := json.Marshal(respJSON2)
  1663. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1664. utils.ErrorLog("解析失败:%v", err)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1669. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1670. saveLog(result2, result1, "3507", "3507")
  1671. var respJSON2 map[string]interface{}
  1672. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1675. return
  1676. }
  1677. userJSONBytes2, _ := json.Marshal(respJSON2)
  1678. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1679. utils.ErrorLog("解析失败:%v", err)
  1680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1681. return
  1682. }
  1683. } else {
  1684. data := make(map[string]interface{})
  1685. data["struct_3507s"] = struct3507
  1686. client := &http.Client{}
  1687. bytesData, _ := json.Marshal(data)
  1688. var req *http.Request
  1689. if miConfig.MdtrtareaAdmvs == "320830" {
  1690. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1691. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1692. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1693. } else {
  1694. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1695. }
  1696. resp, _ := client.Do(req)
  1697. defer resp.Body.Close()
  1698. body, ioErr := ioutil.ReadAll(resp.Body)
  1699. if ioErr != nil {
  1700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1701. }
  1702. var respJSON map[string]interface{}
  1703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1706. return
  1707. }
  1708. var resSix10265 ResultSix10265 //1101结果
  1709. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1710. result, _ := json.Marshal(respJSON)
  1711. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1712. utils.ErrorLog("解析失败:%v", err)
  1713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1714. return
  1715. }
  1716. res.InfRefmsgid = resSix10265.InfRefmsgid
  1717. //res.Output = resSix10265.Output
  1718. res.ErrMsg = resSix10265.ErrMsg
  1719. res.Cainfo = resSix10265.Cainfo
  1720. res.WarnMsg = resSix10265.WarnMsg
  1721. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1722. res.Infcode = infocode
  1723. }
  1724. if res.Infcode == 0 {
  1725. item.IsPc = 0
  1726. service.SaveW(item)
  1727. } else {
  1728. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1729. }
  1730. }
  1731. }
  1732. if len(err) == 0 {
  1733. c.ServeSuccessJSON(map[string]interface{}{
  1734. "msg": "删除盘存变更成功",
  1735. })
  1736. } else {
  1737. c.ServeSuccessJSON(map[string]interface{}{
  1738. "failed_code": -10,
  1739. "msg": err,
  1740. })
  1741. }
  1742. }
  1743. func (c *HisApiController) DeleteXSandBG() {
  1744. ids := c.GetString("ids")
  1745. id_arr := strings.Split(ids, ",")
  1746. admin_user_id, _ := c.GetInt64("admin_user_id")
  1747. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1748. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1750. var err []string
  1751. for _, item := range flows {
  1752. if item.IsSale == 1 && item.IsChange == 1 {
  1753. var res FJ3507Result
  1754. var res2 FJ3507Result
  1755. var struct3507 models.Struct3507
  1756. struct3507.FixmedinsBchno = item.Bchno
  1757. struct3507.InvDataType = "4"
  1758. struct3507.Opter = roles.UserName
  1759. struct3507.OrgName = miConfig.OrgName
  1760. struct3507.AccessKey = miConfig.AccessKey
  1761. struct3507.RequestUrl = miConfig.Url
  1762. struct3507.FixmedinsCode = miConfig.Code
  1763. struct3507.SecretKey = miConfig.SecretKey
  1764. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1765. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1766. struct3507.Url = miConfig.Url
  1767. struct3507.AppId = miConfig.Cainfo
  1768. struct3507.AppSecret = miConfig.AppSecret
  1769. struct3507.Enckey = miConfig.EncKey
  1770. struct3507.SignKey = miConfig.SignKey
  1771. struct3507.SecretKey = miConfig.SecretKey
  1772. //result, result1, _ := service.FJyb3507(struct3507)
  1773. //saveLog(result, result1, "3507", "3507")
  1774. if miConfig.MdtrtareaAdmvs == "350500" {
  1775. result, result1, _ := service.FJyb3507(struct3507)
  1776. saveLog(result, result1, "3507", "3507")
  1777. var respJSON2 map[string]interface{}
  1778. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1781. return
  1782. }
  1783. userJSONBytes2, _ := json.Marshal(respJSON2)
  1784. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1785. utils.ErrorLog("解析失败:%v", err)
  1786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1787. return
  1788. }
  1789. } else {
  1790. data := make(map[string]interface{})
  1791. data["struct_3507s"] = struct3507
  1792. client := &http.Client{}
  1793. bytesData, _ := json.Marshal(data)
  1794. var req *http.Request
  1795. if miConfig.MdtrtareaAdmvs == "320830" {
  1796. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1797. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1798. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1799. } else {
  1800. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1801. }
  1802. resp, _ := client.Do(req)
  1803. defer resp.Body.Close()
  1804. body, ioErr := ioutil.ReadAll(resp.Body)
  1805. if ioErr != nil {
  1806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1807. }
  1808. var respJSON map[string]interface{}
  1809. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. return
  1813. }
  1814. var resSix10265 ResultSix10265 //1101结果
  1815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1816. result, _ := json.Marshal(respJSON)
  1817. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1818. utils.ErrorLog("解析失败:%v", err)
  1819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return
  1821. }
  1822. res.InfRefmsgid = resSix10265.InfRefmsgid
  1823. //res.Output = resSix10265.Output
  1824. res.ErrMsg = resSix10265.ErrMsg
  1825. res.Cainfo = resSix10265.Cainfo
  1826. res.WarnMsg = resSix10265.WarnMsg
  1827. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1828. res.Infcode = infocode
  1829. }
  1830. if res.Infcode == 0 {
  1831. item.IsSale = 0
  1832. item.SaleDate = ""
  1833. item.Bchno = ""
  1834. err2 := service.SaveDF(item)
  1835. if err2 == nil {
  1836. var struct3507_2 models.Struct3507
  1837. struct3507_2.OrgName = miConfig.OrgName
  1838. struct3507_2.AccessKey = miConfig.AccessKey
  1839. struct3507_2.RequestUrl = miConfig.Url
  1840. struct3507_2.Opter = roles.UserName
  1841. struct3507_2.FixmedinsCode = miConfig.Code
  1842. struct3507_2.Code = miConfig.Code
  1843. struct3507_2.SecretKey = miConfig.SecretKey
  1844. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1845. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1846. struct3507_2.Url = miConfig.Url
  1847. struct3507_2.AppId = miConfig.Cainfo
  1848. struct3507_2.AppSecret = miConfig.AppSecret
  1849. struct3507_2.Enckey = miConfig.EncKey
  1850. struct3507_2.SignKey = miConfig.SignKey
  1851. struct3507_2.SecretKey = miConfig.SecretKey
  1852. struct3507_2.FixmedinsBchno = item.BgBchno
  1853. struct3507_2.InvDataType = "2"
  1854. if miConfig.MdtrtareaAdmvs == "350500" {
  1855. result11, result22, _ := service.FJyb3507(struct3507_2)
  1856. saveLog(result11, result22, "3507", "3507")
  1857. var respJSON3 map[string]interface{}
  1858. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1861. return
  1862. }
  1863. userJSONBytes3, _ := json.Marshal(respJSON3)
  1864. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1865. utils.ErrorLog("解析失败:%v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. } else {
  1870. data := make(map[string]interface{})
  1871. data["struct_3507s"] = struct3507_2
  1872. client := &http.Client{}
  1873. bytesData, _ := json.Marshal(data)
  1874. var req *http.Request
  1875. if miConfig.MdtrtareaAdmvs == "320830" {
  1876. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1877. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1878. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1879. } else {
  1880. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1881. }
  1882. resp, _ := client.Do(req)
  1883. defer resp.Body.Close()
  1884. body, ioErr := ioutil.ReadAll(resp.Body)
  1885. if ioErr != nil {
  1886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1887. }
  1888. var respJSON map[string]interface{}
  1889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1892. return
  1893. }
  1894. var resSix10265 ResultSix10265 //1101结果
  1895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1896. result, _ := json.Marshal(respJSON)
  1897. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1898. utils.ErrorLog("解析失败:%v", err)
  1899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1900. return
  1901. }
  1902. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1903. //res.Output = resSix10265.Output
  1904. res2.ErrMsg = resSix10265.ErrMsg
  1905. res2.Cainfo = resSix10265.Cainfo
  1906. res2.WarnMsg = resSix10265.WarnMsg
  1907. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1908. res2.Infcode = infocode
  1909. }
  1910. if res2.Infcode == 0 {
  1911. item.IsChange = 0
  1912. item.BgBchno = ""
  1913. service.SaveDF2(item)
  1914. } else {
  1915. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1916. }
  1917. }
  1918. } else {
  1919. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1920. }
  1921. }
  1922. if item.IsSale == 2 && item.IsChange == 1 {
  1923. var res FJ3507Result
  1924. var res2 FJ3507Result
  1925. var struct3507 models.Struct3507
  1926. struct3507.FixmedinsBchno = item.Bchno
  1927. struct3507.InvDataType = "4"
  1928. struct3507.Opter = roles.UserName
  1929. struct3507.OrgName = miConfig.OrgName
  1930. struct3507.AccessKey = miConfig.AccessKey
  1931. struct3507.RequestUrl = miConfig.Url
  1932. struct3507.FixmedinsCode = miConfig.Code
  1933. struct3507.Code = miConfig.Code
  1934. struct3507.SecretKey = miConfig.SecretKey
  1935. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1936. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1937. struct3507.Url = miConfig.Url
  1938. struct3507.AppId = miConfig.Cainfo
  1939. struct3507.AppSecret = miConfig.AppSecret
  1940. struct3507.Enckey = miConfig.EncKey
  1941. struct3507.SignKey = miConfig.SignKey
  1942. struct3507.SecretKey = miConfig.SecretKey
  1943. //result, result1, _ := service.FJyb3507(struct3507)
  1944. //saveLog(result, result1, "3507", "3507")
  1945. //
  1946. //var respJSON2 map[string]interface{}
  1947. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1948. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1950. // return
  1951. //}
  1952. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1953. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1954. // utils.ErrorLog("解析失败:%v", err)
  1955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1956. // return
  1957. //}
  1958. if miConfig.MdtrtareaAdmvs == "350500" {
  1959. result, result1, _ := service.FJyb3507(struct3507)
  1960. saveLog(result, result1, "3507", "3507")
  1961. var respJSON2 map[string]interface{}
  1962. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. userJSONBytes2, _ := json.Marshal(respJSON2)
  1968. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1969. utils.ErrorLog("解析失败:%v", err)
  1970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1971. return
  1972. }
  1973. } else {
  1974. data := make(map[string]interface{})
  1975. data["struct_3507s"] = struct3507
  1976. client := &http.Client{}
  1977. bytesData, _ := json.Marshal(data)
  1978. var req *http.Request
  1979. if miConfig.MdtrtareaAdmvs == "320830" {
  1980. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1981. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1982. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1983. } else {
  1984. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1985. }
  1986. resp, _ := client.Do(req)
  1987. defer resp.Body.Close()
  1988. body, ioErr := ioutil.ReadAll(resp.Body)
  1989. if ioErr != nil {
  1990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1991. }
  1992. var respJSON map[string]interface{}
  1993. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1996. return
  1997. }
  1998. var resSix10265 ResultSix10265 //1101结果
  1999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2000. result, _ := json.Marshal(respJSON)
  2001. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2002. utils.ErrorLog("解析失败:%v", err)
  2003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2004. return
  2005. }
  2006. res.InfRefmsgid = resSix10265.InfRefmsgid
  2007. //res.Output = resSix10265.Output
  2008. res.ErrMsg = resSix10265.ErrMsg
  2009. res.Cainfo = resSix10265.Cainfo
  2010. res.WarnMsg = resSix10265.WarnMsg
  2011. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2012. res.Infcode = infocode
  2013. }
  2014. if res.Infcode == 0 {
  2015. item.IsSale = 0
  2016. item.SaleDate = ""
  2017. item.Bchno = ""
  2018. err2 := service.SaveDF(item)
  2019. if err2 == nil {
  2020. var struct3507_2 models.Struct3507
  2021. struct3507_2.OrgName = miConfig.OrgName
  2022. struct3507_2.AccessKey = miConfig.AccessKey
  2023. struct3507_2.RequestUrl = miConfig.Url
  2024. struct3507_2.Opter = roles.UserName
  2025. struct3507_2.FixmedinsCode = miConfig.Code
  2026. struct3507_2.Code = miConfig.Code
  2027. struct3507_2.SecretKey = miConfig.SecretKey
  2028. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2029. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2030. struct3507_2.Url = miConfig.Url
  2031. struct3507_2.AppId = miConfig.Cainfo
  2032. struct3507_2.AppSecret = miConfig.AppSecret
  2033. struct3507_2.Enckey = miConfig.EncKey
  2034. struct3507_2.SignKey = miConfig.SignKey
  2035. struct3507_2.SecretKey = miConfig.SecretKey
  2036. struct3507_2.FixmedinsBchno = item.BgBchno
  2037. struct3507_2.InvDataType = "2"
  2038. //result11, result22, _ := service.FJyb3507(struct3507_2)
  2039. //saveLog(result11, result22, "3507", "3507")
  2040. //var respJSON3 map[string]interface{}
  2041. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2042. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2044. // return
  2045. //}
  2046. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2047. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2048. // utils.ErrorLog("解析失败:%v", err)
  2049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2050. // return
  2051. //}
  2052. if miConfig.MdtrtareaAdmvs == "350500" {
  2053. result11, result22, _ := service.FJyb3507(struct3507_2)
  2054. saveLog(result11, result22, "3507", "3507")
  2055. var respJSON3 map[string]interface{}
  2056. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2059. return
  2060. }
  2061. userJSONBytes3, _ := json.Marshal(respJSON3)
  2062. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2063. utils.ErrorLog("解析失败:%v", err)
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. return
  2066. }
  2067. } else {
  2068. data := make(map[string]interface{})
  2069. data["struct_3507s"] = struct3507_2
  2070. client := &http.Client{}
  2071. bytesData, _ := json.Marshal(data)
  2072. var req *http.Request
  2073. if miConfig.MdtrtareaAdmvs == "320830" {
  2074. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2075. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2076. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2077. } else {
  2078. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2079. }
  2080. resp, _ := client.Do(req)
  2081. defer resp.Body.Close()
  2082. body, ioErr := ioutil.ReadAll(resp.Body)
  2083. if ioErr != nil {
  2084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2085. }
  2086. var respJSON map[string]interface{}
  2087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2090. return
  2091. }
  2092. var resSix10265 ResultSix10265 //1101结果
  2093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2094. result, _ := json.Marshal(respJSON)
  2095. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2096. utils.ErrorLog("解析失败:%v", err)
  2097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. return
  2099. }
  2100. res2.InfRefmsgid = resSix10265.InfRefmsgid
  2101. //res.Output = resSix10265.Output
  2102. res2.ErrMsg = resSix10265.ErrMsg
  2103. res2.Cainfo = resSix10265.Cainfo
  2104. res2.WarnMsg = resSix10265.WarnMsg
  2105. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2106. res2.Infcode = infocode
  2107. }
  2108. if res2.Infcode == 0 {
  2109. item.IsChange = 0
  2110. item.BgBchno = ""
  2111. service.SaveDF2(item)
  2112. } else {
  2113. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2114. }
  2115. }
  2116. } else {
  2117. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2118. }
  2119. }
  2120. if item.IsSale == 1 && item.IsChange == 0 {
  2121. var res FJ3507Result
  2122. var struct3507 models.Struct3507
  2123. struct3507.FixmedinsBchno = item.Bchno
  2124. struct3507.InvDataType = "4"
  2125. struct3507.Opter = roles.UserName
  2126. struct3507.FixmedinsCode = miConfig.Code
  2127. struct3507.Code = miConfig.Code
  2128. struct3507.OrgName = miConfig.OrgName
  2129. struct3507.AccessKey = miConfig.AccessKey
  2130. struct3507.RequestUrl = miConfig.Url
  2131. struct3507.SecretKey = miConfig.SecretKey
  2132. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2133. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2134. struct3507.Url = miConfig.Url
  2135. struct3507.AppId = miConfig.Cainfo
  2136. struct3507.AppSecret = miConfig.AppSecret
  2137. struct3507.Enckey = miConfig.EncKey
  2138. struct3507.SignKey = miConfig.SignKey
  2139. struct3507.SecretKey = miConfig.SecretKey
  2140. //result, result1, _ := service.FJyb3507(struct3507)
  2141. //saveLog(result, result1, "3507", "3507")
  2142. //
  2143. //var respJSON3 map[string]interface{}
  2144. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2145. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2147. // return
  2148. //}
  2149. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2150. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2151. // utils.ErrorLog("解析失败:%v", err)
  2152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2153. // return
  2154. //}
  2155. if miConfig.MdtrtareaAdmvs == "350500" {
  2156. result, result1, _ := service.FJyb3507(struct3507)
  2157. saveLog(result, result1, "3507", "3507")
  2158. var respJSON2 map[string]interface{}
  2159. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2162. return
  2163. }
  2164. userJSONBytes2, _ := json.Marshal(respJSON2)
  2165. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2166. utils.ErrorLog("解析失败:%v", err)
  2167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. return
  2169. }
  2170. } else {
  2171. data := make(map[string]interface{})
  2172. data["struct_3507s"] = struct3507
  2173. client := &http.Client{}
  2174. bytesData, _ := json.Marshal(data)
  2175. var req *http.Request
  2176. if miConfig.MdtrtareaAdmvs == "320830" {
  2177. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2178. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2179. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2180. } else {
  2181. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2182. }
  2183. resp, _ := client.Do(req)
  2184. defer resp.Body.Close()
  2185. body, ioErr := ioutil.ReadAll(resp.Body)
  2186. if ioErr != nil {
  2187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2188. }
  2189. var respJSON map[string]interface{}
  2190. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2193. return
  2194. }
  2195. var resSix10265 ResultSix10265 //1101结果
  2196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2197. result, _ := json.Marshal(respJSON)
  2198. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2199. utils.ErrorLog("解析失败:%v", err)
  2200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. return
  2202. }
  2203. res.InfRefmsgid = resSix10265.InfRefmsgid
  2204. //res.Output = resSix10265.Output
  2205. res.ErrMsg = resSix10265.ErrMsg
  2206. res.Cainfo = resSix10265.Cainfo
  2207. res.WarnMsg = resSix10265.WarnMsg
  2208. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2209. res.Infcode = infocode
  2210. }
  2211. if res.Infcode == 0 {
  2212. item.IsSale = 0
  2213. item.SaleDate = ""
  2214. service.SaveDF(item)
  2215. } else {
  2216. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2217. }
  2218. }
  2219. if item.IsSale == 2 && item.IsChange == 0 {
  2220. var res FJ3507Result
  2221. var struct3507 models.Struct3507
  2222. struct3507.FixmedinsBchno = item.Bchno
  2223. struct3507.InvDataType = "4"
  2224. struct3507.Opter = roles.UserName
  2225. struct3507.FixmedinsCode = miConfig.Code
  2226. struct3507.Code = miConfig.Code
  2227. struct3507.OrgName = miConfig.OrgName
  2228. struct3507.AccessKey = miConfig.AccessKey
  2229. struct3507.RequestUrl = miConfig.Url
  2230. struct3507.SecretKey = miConfig.SecretKey
  2231. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2232. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2233. struct3507.Url = miConfig.Url
  2234. struct3507.AppId = miConfig.Cainfo
  2235. struct3507.AppSecret = miConfig.AppSecret
  2236. struct3507.Enckey = miConfig.EncKey
  2237. struct3507.SignKey = miConfig.SignKey
  2238. struct3507.SecretKey = miConfig.SecretKey
  2239. //result, result1, _ := service.FJyb3507(struct3507)
  2240. //saveLog(result, result1, "3507", "3507")
  2241. //
  2242. //var respJSON3 map[string]interface{}
  2243. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2244. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2246. // return
  2247. //}
  2248. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2249. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2250. // utils.ErrorLog("解析失败:%v", err)
  2251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. // return
  2253. //}
  2254. if miConfig.MdtrtareaAdmvs == "350500" {
  2255. result, result1, _ := service.FJyb3507(struct3507)
  2256. saveLog(result, result1, "3507", "3507")
  2257. var respJSON2 map[string]interface{}
  2258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2261. return
  2262. }
  2263. userJSONBytes2, _ := json.Marshal(respJSON2)
  2264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2265. utils.ErrorLog("解析失败:%v", err)
  2266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2267. return
  2268. }
  2269. } else {
  2270. data := make(map[string]interface{})
  2271. data["struct_3507s"] = struct3507
  2272. client := &http.Client{}
  2273. bytesData, _ := json.Marshal(data)
  2274. var req *http.Request
  2275. if miConfig.MdtrtareaAdmvs == "320830" {
  2276. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2277. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2278. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2279. } else {
  2280. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2281. }
  2282. resp, _ := client.Do(req)
  2283. defer resp.Body.Close()
  2284. body, ioErr := ioutil.ReadAll(resp.Body)
  2285. if ioErr != nil {
  2286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2287. }
  2288. var respJSON map[string]interface{}
  2289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2292. return
  2293. }
  2294. var resSix10265 ResultSix10265 //1101结果
  2295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2296. result, _ := json.Marshal(respJSON)
  2297. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2298. utils.ErrorLog("解析失败:%v", err)
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2300. return
  2301. }
  2302. res.InfRefmsgid = resSix10265.InfRefmsgid
  2303. //res.Output = resSix10265.Output
  2304. res.ErrMsg = resSix10265.ErrMsg
  2305. res.Cainfo = resSix10265.Cainfo
  2306. res.WarnMsg = resSix10265.WarnMsg
  2307. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2308. res.Infcode = infocode
  2309. }
  2310. if res.Infcode == 0 {
  2311. item.IsSale = 0
  2312. item.SaleDate = ""
  2313. item.Bchno = ""
  2314. service.SaveDF(item)
  2315. } else {
  2316. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2317. }
  2318. }
  2319. if item.IsSale == 0 && item.IsChange == 1 {
  2320. var res FJ3507Result
  2321. var struct3507 models.Struct3507
  2322. struct3507.FixmedinsBchno = item.BgBchno
  2323. struct3507.InvDataType = "2"
  2324. struct3507.Opter = roles.UserName
  2325. struct3507.FixmedinsCode = miConfig.Code
  2326. struct3507.Code = miConfig.Code
  2327. struct3507.OrgName = miConfig.OrgName
  2328. struct3507.AccessKey = miConfig.AccessKey
  2329. struct3507.RequestUrl = miConfig.Url
  2330. struct3507.SecretKey = miConfig.SecretKey
  2331. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2332. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2333. struct3507.Url = miConfig.Url
  2334. struct3507.AppId = miConfig.Cainfo
  2335. struct3507.AppSecret = miConfig.AppSecret
  2336. struct3507.Enckey = miConfig.EncKey
  2337. struct3507.SignKey = miConfig.SignKey
  2338. struct3507.SecretKey = miConfig.SecretKey
  2339. //result, result1, _ := service.FJyb3507(struct3507)
  2340. //saveLog(result, result1, "3507", "3507")
  2341. //
  2342. //var respJSON3 map[string]interface{}
  2343. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2344. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2346. // return
  2347. //}
  2348. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2349. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2350. // utils.ErrorLog("解析失败:%v", err)
  2351. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2352. // return
  2353. //}
  2354. if miConfig.MdtrtareaAdmvs == "350500" {
  2355. result, result1, _ := service.FJyb3507(struct3507)
  2356. saveLog(result, result1, "3507", "3507")
  2357. var respJSON2 map[string]interface{}
  2358. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. return
  2362. }
  2363. userJSONBytes2, _ := json.Marshal(respJSON2)
  2364. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2365. utils.ErrorLog("解析失败:%v", err)
  2366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2367. return
  2368. }
  2369. } else {
  2370. data := make(map[string]interface{})
  2371. data["struct_3507s"] = struct3507
  2372. client := &http.Client{}
  2373. bytesData, _ := json.Marshal(data)
  2374. var req *http.Request
  2375. if miConfig.MdtrtareaAdmvs == "320830" {
  2376. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2377. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2378. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2379. } else {
  2380. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2381. }
  2382. resp, _ := client.Do(req)
  2383. defer resp.Body.Close()
  2384. body, ioErr := ioutil.ReadAll(resp.Body)
  2385. if ioErr != nil {
  2386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2387. }
  2388. var respJSON map[string]interface{}
  2389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2392. return
  2393. }
  2394. var resSix10265 ResultSix10265 //1101结果
  2395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2396. result, _ := json.Marshal(respJSON)
  2397. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2398. utils.ErrorLog("解析失败:%v", err)
  2399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2400. return
  2401. }
  2402. res.InfRefmsgid = resSix10265.InfRefmsgid
  2403. //res.Output = resSix10265.Output
  2404. res.ErrMsg = resSix10265.ErrMsg
  2405. res.Cainfo = resSix10265.Cainfo
  2406. res.WarnMsg = resSix10265.WarnMsg
  2407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2408. res.Infcode = infocode
  2409. }
  2410. if res.Infcode == 0 {
  2411. item.IsChange = 0
  2412. item.BgBchno = ""
  2413. service.SaveDF2(item)
  2414. } else {
  2415. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2416. }
  2417. }
  2418. }
  2419. if len(err) == 0 {
  2420. c.ServeSuccessJSON(map[string]interface{}{
  2421. "msg": "删除销售变更成功",
  2422. })
  2423. } else {
  2424. c.ServeSuccessJSON(map[string]interface{}{
  2425. "failed_code": -10,
  2426. "msg": err,
  2427. })
  2428. }
  2429. }
  2430. //func (c *HisApiController) BatchFJ3501AND3502() {
  2431. // //ids := c.GetString("ids")
  2432. // start_time := c.GetString("start_time")
  2433. // end_time := c.GetString("end_time")
  2434. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2435. //
  2436. //
  2437. // timeLayout := "2006-01-02"
  2438. // loc, _ := time.LoadLocation("Local")
  2439. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2440. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2441. //
  2442. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2443. // //id_arr := strings.Split(ids, ",")
  2444. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2445. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2446. // //库盘
  2447. // var errs []string
  2448. // for _, drug := range drugs {
  2449. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2450. // var res2 ResultSix
  2451. // var res3 ResultSix
  2452. //
  2453. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2454. // var struct3501 models.Struct3501
  2455. // struct3501.Code = miConfig.Code
  2456. // struct3501.OrgName = miConfig.OrgName
  2457. // struct3501.AccessKey = miConfig.AccessKey
  2458. // struct3501.Opter = roles.UserName
  2459. // struct3501.RequestUrl = miConfig.Url
  2460. // struct3501.Url = miConfig.Url
  2461. // struct3501.AppId = miConfig.Cainfo
  2462. // struct3501.AppSecret = miConfig.AppSecret
  2463. // struct3501.Enckey = miConfig.EncKey
  2464. // struct3501.SignKey = miConfig.SignKey
  2465. // struct3501.SecretKey = miConfig.SecretKey
  2466. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2467. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2468. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2469. // struct3501.RxFlag = "1"
  2470. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2471. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2472. //
  2473. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2474. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2475. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2476. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2477. // struct3501.FixmedinsBchno = number
  2478. // struct3501.DrugTracCodg = drug.DrugCode
  2479. // memo := make(map[string]interface{})
  2480. // memo["pric"] = drug.Price
  2481. // bytesData, _ := json.Marshal(memo)
  2482. // struct3501.Memo = string(bytesData)
  2483. //
  2484. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2485. //
  2486. // result1, result2, _ := service.FJyb3501(struct3501)
  2487. // saveLog(result1, result2, "3501", "3501")
  2488. // //saveLog(result, requestLog, "2201", "挂号")
  2489. //
  2490. // var respJSON2 map[string]interface{}
  2491. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2492. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2494. // return
  2495. // }
  2496. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2497. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2498. // utils.ErrorLog("解析失败:%v", err)
  2499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2500. // return
  2501. // }
  2502. //
  2503. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2504. // data := make(map[string]interface{})
  2505. // data["struct_3501s"] = struct3501
  2506. // client := &http.Client{}
  2507. // bytesData, _ := json.Marshal(data)
  2508. // var req *http.Request
  2509. // if miConfig.MdtrtareaAdmvs == "320921" {
  2510. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2511. // } else {
  2512. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2513. // }
  2514. //
  2515. // resp, _ := client.Do(req)
  2516. // defer resp.Body.Close()
  2517. // body, ioErr := ioutil.ReadAll(resp.Body)
  2518. // if ioErr != nil {
  2519. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2520. // }
  2521. // var respJSON map[string]interface{}
  2522. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2523. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2525. // return
  2526. // }
  2527. // var resSix10265 ResultSix10265 //1101结果
  2528. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2529. // result, _ := json.Marshal(respJSON)
  2530. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2531. // utils.ErrorLog("解析失败:%v", err)
  2532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. // return
  2534. // }
  2535. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2536. // res2.Output = resSix10265.Output
  2537. // res2.ErrMsg = resSix10265.ErrMsg
  2538. // res2.Cainfo = resSix10265.Cainfo
  2539. // res2.WarnMsg = resSix10265.WarnMsg
  2540. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2541. // res2.Infcode = infocode
  2542. //
  2543. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2544. // data := make(map[string]interface{})
  2545. // data["struct_3501s"] = struct3501
  2546. // client := &http.Client{}
  2547. // bytesData, _ := json.Marshal(data)
  2548. // var req *http.Request
  2549. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2550. // resp, _ := client.Do(req)
  2551. // defer resp.Body.Close()
  2552. // body, ioErr := ioutil.ReadAll(resp.Body)
  2553. // if ioErr != nil {
  2554. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2555. // }
  2556. // var respJSON map[string]interface{}
  2557. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2558. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2560. // return
  2561. // }
  2562. // var resSix10265 ResultSix10265 //1101结果
  2563. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2564. // result, _ := json.Marshal(respJSON)
  2565. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2566. // utils.ErrorLog("解析失败:%v", err)
  2567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2568. // return
  2569. // }
  2570. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2571. // res2.Output = resSix10265.Output
  2572. // res2.ErrMsg = resSix10265.ErrMsg
  2573. // res2.Cainfo = resSix10265.Cainfo
  2574. // res2.WarnMsg = resSix10265.WarnMsg
  2575. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2576. // res2.Infcode = infocode
  2577. //
  2578. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2579. // data := make(map[string]interface{})
  2580. // data["struct_3501s"] = struct3501
  2581. // client := &http.Client{}
  2582. // bytesData, _ := json.Marshal(data)
  2583. // var req *http.Request
  2584. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2585. // resp, _ := client.Do(req)
  2586. // defer resp.Body.Close()
  2587. // body, ioErr := ioutil.ReadAll(resp.Body)
  2588. // if ioErr != nil {
  2589. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2590. // }
  2591. // var respJSON map[string]interface{}
  2592. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2593. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2595. // return
  2596. // }
  2597. // var resSix10265 ResultSix10265 //1101结果
  2598. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2599. // result, _ := json.Marshal(respJSON)
  2600. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2601. // utils.ErrorLog("解析失败:%v", err)
  2602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2603. // return
  2604. // }
  2605. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2606. // res2.Output = resSix10265.Output
  2607. // res2.ErrMsg = resSix10265.ErrMsg
  2608. // res2.Cainfo = resSix10265.Cainfo
  2609. // res2.WarnMsg = resSix10265.WarnMsg
  2610. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2611. // res2.Infcode = infocode
  2612. //
  2613. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2614. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2615. // saveLog(result1, result2, "3501", "3501")
  2616. // //saveLog(result, requestLog, "2201", "挂号")
  2617. //
  2618. // var respJSON2 map[string]interface{}
  2619. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2620. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2622. // return
  2623. // }
  2624. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2625. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2626. // utils.ErrorLog("解析失败:%v", err)
  2627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. // return
  2629. // }
  2630. //
  2631. // }
  2632. //
  2633. // if res2.Infcode != -1 {
  2634. // drug.IsPc = 1
  2635. // drug.Bchno = number
  2636. // drug.PcDate = time.Now().Unix()
  2637. // err := service.SaveW(drug)
  2638. // if err == nil {
  2639. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2640. // var struct3502 models.Struct3502
  2641. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2642. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2643. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2644. // struct3502.FixmedinsCode = miConfig.Code
  2645. // struct3502.Code = miConfig.Code
  2646. //
  2647. // struct3502.RxFlag = "0"
  2648. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2649. // struct3502.OrgName = miConfig.OrgName
  2650. // struct3502.Opter = roles.UserName
  2651. // struct3502.AccessKey = miConfig.AccessKey
  2652. // struct3502.RequestUrl = miConfig.Url
  2653. // struct3502.SecretKey = miConfig.SecretKey
  2654. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2655. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2656. // struct3502.Url = miConfig.Url
  2657. // struct3502.AppId = miConfig.Cainfo
  2658. // struct3502.AppSecret = miConfig.AppSecret
  2659. // struct3502.Enckey = miConfig.EncKey
  2660. // struct3502.SignKey = miConfig.SignKey
  2661. // struct3502.SecretKey = miConfig.SecretKey
  2662. // struct3502.DrugTracCodg = drug.DrugCode
  2663. //
  2664. // struct3502.Memo = ""
  2665. // struct3502.InvChgType = "108"
  2666. // struct3502.FixmedinsBchno = bg_number
  2667. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2668. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2669. //
  2670. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2671. // result11, result22, _ := service.FJyb3502(struct3502)
  2672. // saveLog(result11, result22, "3502", "3502")
  2673. //
  2674. // var respJSON3 map[string]interface{}
  2675. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2676. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2678. // return
  2679. // }
  2680. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2681. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2682. // utils.ErrorLog("解析失败:%v", err)
  2683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2684. // return
  2685. // }
  2686. //
  2687. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2688. // data := make(map[string]interface{})
  2689. // data["struct_3502s"] = struct3502
  2690. // client := &http.Client{}
  2691. // bytesData, _ := json.Marshal(data)
  2692. // var req *http.Request
  2693. // if miConfig.MdtrtareaAdmvs == "320921" {
  2694. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2695. // } else {
  2696. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2697. // }
  2698. //
  2699. // resp, _ := client.Do(req)
  2700. // defer resp.Body.Close()
  2701. // body, ioErr := ioutil.ReadAll(resp.Body)
  2702. // if ioErr != nil {
  2703. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2704. // }
  2705. // var respJSON map[string]interface{}
  2706. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2707. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2709. // return
  2710. // }
  2711. // var resSix10265 ResultSix10265 //1101结果
  2712. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2713. // result, _ := json.Marshal(respJSON)
  2714. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2715. // utils.ErrorLog("解析失败:%v", err)
  2716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2717. // return
  2718. // }
  2719. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2720. // res3.Output = resSix10265.Output
  2721. // res3.ErrMsg = resSix10265.ErrMsg
  2722. // res3.Cainfo = resSix10265.Cainfo
  2723. // res3.WarnMsg = resSix10265.WarnMsg
  2724. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2725. // res3.Infcode = infocode
  2726. //
  2727. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2728. //
  2729. // data := make(map[string]interface{})
  2730. // data["struct_3502s"] = struct3502
  2731. // client := &http.Client{}
  2732. // bytesData, _ := json.Marshal(data)
  2733. // var req *http.Request
  2734. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2735. // resp, _ := client.Do(req)
  2736. // defer resp.Body.Close()
  2737. // body, ioErr := ioutil.ReadAll(resp.Body)
  2738. // if ioErr != nil {
  2739. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2740. // }
  2741. // var respJSON map[string]interface{}
  2742. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2743. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2745. // return
  2746. // }
  2747. // var resSix10265 ResultSix10265 //1101结果
  2748. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2749. // result, _ := json.Marshal(respJSON)
  2750. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2751. // utils.ErrorLog("解析失败:%v", err)
  2752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2753. // return
  2754. // }
  2755. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2756. // res3.Output = resSix10265.Output
  2757. // res3.ErrMsg = resSix10265.ErrMsg
  2758. // res3.Cainfo = resSix10265.Cainfo
  2759. // res3.WarnMsg = resSix10265.WarnMsg
  2760. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2761. // res3.Infcode = infocode
  2762. //
  2763. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2764. //
  2765. // data := make(map[string]interface{})
  2766. // data["struct_3501s"] = struct3501
  2767. // client := &http.Client{}
  2768. // bytesData, _ := json.Marshal(data)
  2769. // var req *http.Request
  2770. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2771. // resp, _ := client.Do(req)
  2772. // defer resp.Body.Close()
  2773. // body, ioErr := ioutil.ReadAll(resp.Body)
  2774. // if ioErr != nil {
  2775. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2776. // }
  2777. // var respJSON map[string]interface{}
  2778. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2779. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2781. // return
  2782. // }
  2783. // var resSix10265 ResultSix10265 //1101结果
  2784. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2785. // result, _ := json.Marshal(respJSON)
  2786. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2787. // utils.ErrorLog("解析失败:%v", err)
  2788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2789. // return
  2790. // }
  2791. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2792. // res2.Output = resSix10265.Output
  2793. // res2.ErrMsg = resSix10265.ErrMsg
  2794. // res2.Cainfo = resSix10265.Cainfo
  2795. // res2.WarnMsg = resSix10265.WarnMsg
  2796. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2797. // res2.Infcode = infocode
  2798. //
  2799. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2800. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2801. // saveLog(result11, result22, "3502", "3502")
  2802. //
  2803. // var respJSON3 map[string]interface{}
  2804. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2805. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2807. // return
  2808. // }
  2809. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2810. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2811. // utils.ErrorLog("解析失败:%v", err)
  2812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. // return
  2814. // }
  2815. // }
  2816. // if res3.Infcode == -1 {
  2817. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2818. // c.ServeSuccessJSON(map[string]interface{}{
  2819. // "failed_code": -10,
  2820. // "msg": res3.ErrMsg,
  2821. // })
  2822. // } else {
  2823. // drug.IsBg = 1
  2824. // drug.BgBchno = bg_number
  2825. // service.SaveW(drug)
  2826. // }
  2827. // }
  2828. // } else {
  2829. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2830. // }
  2831. // }
  2832. // //变更
  2833. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2834. // var res3 ResultSix
  2835. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2836. //
  2837. // var struct3502 models.Struct3502
  2838. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2839. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2840. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2841. // struct3502.FixmedinsCode = miConfig.Code
  2842. // struct3502.Code = miConfig.Code
  2843. //
  2844. // struct3502.Opter = roles.UserName
  2845. // struct3502.RxFlag = "0"
  2846. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2847. // struct3502.OrgName = miConfig.OrgName
  2848. // struct3502.AccessKey = miConfig.AccessKey
  2849. // struct3502.RequestUrl = miConfig.Url
  2850. // struct3502.SecretKey = miConfig.SecretKey
  2851. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2852. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2853. // struct3502.InvChgType = "108"
  2854. // struct3502.DrugTracCodg = drug.DrugCode
  2855. //
  2856. // struct3502.Url = miConfig.Url
  2857. // struct3502.AppId = miConfig.Cainfo
  2858. // struct3502.AppSecret = miConfig.AppSecret
  2859. // struct3502.Enckey = miConfig.EncKey
  2860. // struct3502.SignKey = miConfig.SignKey
  2861. // struct3502.SecretKey = miConfig.SecretKey
  2862. //
  2863. // struct3502.FixmedinsBchno = bg_number
  2864. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2865. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2866. //
  2867. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2868. // result1, result2, _ := service.FJyb3502(struct3502)
  2869. // saveLog(result1, result2, "3502", "3502")
  2870. // var respJSON3 map[string]interface{}
  2871. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2872. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. // return
  2875. // }
  2876. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2877. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2878. // utils.ErrorLog("解析失败:%v", err)
  2879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2880. // return
  2881. // }
  2882. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2883. // data := make(map[string]interface{})
  2884. // data["struct_3502s"] = struct3502
  2885. // client := &http.Client{}
  2886. // bytesData, _ := json.Marshal(data)
  2887. // var req *http.Request
  2888. // if miConfig.MdtrtareaAdmvs == "320921" {
  2889. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2890. // } else {
  2891. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2892. // }
  2893. // resp, _ := client.Do(req)
  2894. // defer resp.Body.Close()
  2895. // body, ioErr := ioutil.ReadAll(resp.Body)
  2896. // if ioErr != nil {
  2897. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2898. // }
  2899. // var respJSON map[string]interface{}
  2900. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2901. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2903. // return
  2904. // }
  2905. // var resSix10265 ResultSix10265 //1101结果
  2906. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2907. // result, _ := json.Marshal(respJSON)
  2908. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2909. // utils.ErrorLog("解析失败:%v", err)
  2910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2911. // return
  2912. // }
  2913. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2914. // res3.Output = resSix10265.Output
  2915. // res3.ErrMsg = resSix10265.ErrMsg
  2916. // res3.Cainfo = resSix10265.Cainfo
  2917. // res3.WarnMsg = resSix10265.WarnMsg
  2918. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2919. // res3.Infcode = infocode
  2920. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2921. //
  2922. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2923. //
  2924. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2925. //
  2926. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2927. //
  2928. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2929. // saveLog(result1, result2, "3501", "3501")
  2930. // //saveLog(result, requestLog, "2201", "挂号")
  2931. //
  2932. // var respJSON2 map[string]interface{}
  2933. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2936. // return
  2937. // }
  2938. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2939. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2940. // utils.ErrorLog("解析失败:%v", err)
  2941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2942. // return
  2943. // }
  2944. //
  2945. // }
  2946. // if res3.Infcode == -1 {
  2947. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2948. // } else {
  2949. // drug.IsBg = 1
  2950. // drug.BgBchno = bg_number
  2951. // service.SaveW(drug)
  2952. // }
  2953. // }
  2954. // }
  2955. //
  2956. // if len(errs) == 0 {
  2957. // c.ServeSuccessJSON(map[string]interface{}{
  2958. // "msg": "盘存变更成功",
  2959. // })
  2960. // } else {
  2961. // c.ServeSuccessJSON(map[string]interface{}{
  2962. // "failed_code": -10,
  2963. // "msg": errs,
  2964. // })
  2965. // }
  2966. //}
  2967. func (c *HisApiController) DeleteXSandBGTwo() {
  2968. id, _ := c.GetInt64("id")
  2969. admin_user_id, _ := c.GetInt64("admin_user_id")
  2970. var errs []string
  2971. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2972. //for _, item := range advicelist {
  2973. // flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2974. // flows = append(flows, flow...)
  2975. //}
  2976. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2977. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2978. for _, item := range advicelist {
  2979. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  2980. if prescription.OrderStatus != 2 {
  2981. // 将时间戳转换为time.Time类型
  2982. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2983. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2984. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法撤销上传")
  2985. }
  2986. if len(item.DrugCode) > 0 {
  2987. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2988. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2989. codes := strings.Split(item.DrugCode, ",")
  2990. for _, code := range codes {
  2991. if len(code) > 0 {
  2992. if len(code) != 20 {
  2993. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  2994. }
  2995. if IsDigit(code) == false {
  2996. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  2997. }
  2998. }
  2999. }
  3000. }
  3001. }
  3002. if len(errs) > 0 {
  3003. c.ServeSuccessJSON(map[string]interface{}{
  3004. "failed_code": -10,
  3005. "msg": errs,
  3006. })
  3007. return
  3008. }
  3009. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3010. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3011. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3012. for _, item := range advicelist {
  3013. flow, _ := service.GetNewDrugFlowInfoByPatient(item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3014. //Drug ,_ := service.GetDrugLibById( drug.DrugId)
  3015. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3016. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, flow, miConfig, roles, strconv.Itoa(int(item.ID)), item)
  3017. result111, result222 = CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, flow, miConfig, roles, flow.Bchno, item)
  3018. saveLog(result111, result222, "3506", "销售退货")
  3019. var res FJ3507Result
  3020. var res3507for10188 FJ3507ResultFor10188
  3021. //进行商品销售接口
  3022. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3023. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3024. var respJSON3 map[string]interface{}
  3025. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3028. return
  3029. }
  3030. userJSONBytes3, _ := json.Marshal(respJSON3)
  3031. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3032. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3033. utils.ErrorLog("解析失败:%v", err)
  3034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3035. return
  3036. }
  3037. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3038. res.ErrMsg = res3507for10188.ErrMsg
  3039. res.Cainfo = res3507for10188.Cainfo
  3040. res.WarnMsg = res3507for10188.WarnMsg
  3041. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3042. res.Infcode = infocode
  3043. } else {
  3044. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3045. utils.ErrorLog("解析失败:%v", err)
  3046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3047. return
  3048. }
  3049. }
  3050. if res.Infcode == 0 {
  3051. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3052. } else {
  3053. errs = append(errs, item.AdviceName+",销售退货失败:"+res.ErrMsg)
  3054. }
  3055. }
  3056. c.ServeSuccessJSON(map[string]interface{}{
  3057. "msg": "销售退货成功",
  3058. })
  3059. }
  3060. // 删除
  3061. //func (c *HisApiController) DeleteXSandBGThree() {
  3062. // id, _ := c.GetInt64("id")
  3063. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3064. //
  3065. // advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  3066. // //var flows []*models.DrugFlow
  3067. // //for _, item := range advicelist {
  3068. // // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3069. // // flows = append(flows, flow...)
  3070. // //}
  3071. //
  3072. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3073. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3074. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3075. //
  3076. // var err []string
  3077. // for _, item := range advicelist {
  3078. //
  3079. // var res FJ3507Result
  3080. //
  3081. // var struct3507 models.Struct3507
  3082. // struct3507.FixmedinsBchno = item.ID
  3083. // struct3507.InvDataType = "4"
  3084. // struct3507.Opter = roles.UserName
  3085. // struct3507.OrgName = miConfig.OrgName
  3086. // struct3507.AccessKey = miConfig.AccessKey
  3087. // struct3507.RequestUrl = miConfig.Url
  3088. // struct3507.FixmedinsCode = miConfig.Code
  3089. // struct3507.SecretKey = miConfig.SecretKey
  3090. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3091. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3092. // struct3507.Url = miConfig.Url
  3093. // struct3507.AppId = miConfig.Cainfo
  3094. // struct3507.AppSecret = miConfig.AppSecret
  3095. // struct3507.Enckey = miConfig.EncKey
  3096. // struct3507.SignKey = miConfig.SignKey
  3097. // struct3507.SecretKey = miConfig.SecretKey
  3098. //
  3099. // if miConfig.MdtrtareaAdmvs == "350500" {
  3100. // result, result1, _ := service.FJyb3507(struct3507)
  3101. // saveLog(result, result1, "3507", "3507")
  3102. // var respJSON2 map[string]interface{}
  3103. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3104. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. // return
  3107. // }
  3108. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3109. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3110. // utils.ErrorLog("解析失败:%v", err)
  3111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3112. // return
  3113. // }
  3114. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3115. // data := make(map[string]interface{})
  3116. // data["struct_3507s"] = struct3507
  3117. // client := &http.Client{}
  3118. // bytesData, _ := json.Marshal(data)
  3119. // var req *http.Request
  3120. // if miConfig.MdtrtareaAdmvs == "320830" {
  3121. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3122. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  3123. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3124. // } else {
  3125. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3126. // }
  3127. //
  3128. // resp, _ := client.Do(req)
  3129. // defer resp.Body.Close()
  3130. // body, ioErr := ioutil.ReadAll(resp.Body)
  3131. // if ioErr != nil {
  3132. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3133. // }
  3134. // var respJSON map[string]interface{}
  3135. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3136. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3138. // return
  3139. // }
  3140. // var resSix10265 ResultSix10265 //1101结果
  3141. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3142. // result, _ := json.Marshal(respJSON)
  3143. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3144. // utils.ErrorLog("解析失败:%v", err)
  3145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3146. // return
  3147. // }
  3148. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3149. // //res.Output = resSix10265.Output
  3150. // res.ErrMsg = resSix10265.ErrMsg
  3151. // res.Cainfo = resSix10265.Cainfo
  3152. // res.WarnMsg = resSix10265.WarnMsg
  3153. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3154. // res.Infcode = infocode
  3155. // } else if miConfig.MdtrtareaAdmvs == "440100" {
  3156. // result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3157. // saveLog(result2, result1, "3507", "3507")
  3158. // var respJSON2 map[string]interface{}
  3159. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3160. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3162. // return
  3163. // }
  3164. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3165. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3166. // utils.ErrorLog("解析失败:%v", err)
  3167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3168. // return
  3169. // }
  3170. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3171. // result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3172. // saveLog(result2, result1, "3507", "3507")
  3173. // var respJSON2 map[string]interface{}
  3174. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3175. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3177. // return
  3178. // }
  3179. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3180. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3181. // utils.ErrorLog("解析失败:%v", err)
  3182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3183. // return
  3184. // }
  3185. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3186. // result1, result2 := service.Jxyb3507(struct3507)
  3187. // saveLog(result2, result1, "3507", "3507")
  3188. // var respJSON2 map[string]interface{}
  3189. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3190. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3192. // return
  3193. // }
  3194. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3195. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3196. // utils.ErrorLog("解析失败:%v", err)
  3197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3198. // return
  3199. // }
  3200. // } else if miConfig.MdtrtareaAdmvs == "340699" {
  3201. // result1, result2 := service.AHyb3507(struct3507)
  3202. // saveLog(result2, result1, "3507", "3507")
  3203. // var respJSON2 map[string]interface{}
  3204. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3205. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3207. // return
  3208. // }
  3209. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3210. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3211. // utils.ErrorLog("解析失败:%v", err)
  3212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3213. // return
  3214. // }
  3215. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  3216. //
  3217. // data := make(map[string]interface{})
  3218. // data["struct_3507s"] = struct3507
  3219. // client := &http.Client{}
  3220. // bytesData, _ := json.Marshal(data)
  3221. // var req *http.Request
  3222. //
  3223. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3224. //
  3225. // resp, _ := client.Do(req)
  3226. // defer resp.Body.Close()
  3227. // body, ioErr := ioutil.ReadAll(resp.Body)
  3228. // if ioErr != nil {
  3229. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3230. // }
  3231. // var respJSON map[string]interface{}
  3232. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3233. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3234. // }
  3235. //
  3236. // var resSix10265 ResultSix10265 //1101结果
  3237. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3238. // result, _ := json.Marshal(respJSON)
  3239. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3240. // utils.ErrorLog("解析失败:%v", err)
  3241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3242. // return
  3243. // }
  3244. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3245. // res.ErrMsg = resSix10265.ErrMsg
  3246. // res.Cainfo = resSix10265.Cainfo
  3247. // res.WarnMsg = resSix10265.WarnMsg
  3248. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3249. // res.Infcode = infocode
  3250. // }
  3251. //
  3252. // if res.Infcode == 0 {
  3253. // service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3254. // item.IsSale = 0
  3255. // item.SaleDate = ""
  3256. // item.Bchno = ""
  3257. // service.SaveDF(item)
  3258. // } else {
  3259. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3260. // }
  3261. // }
  3262. //
  3263. // c.ServeSuccessJSON(map[string]interface{}{
  3264. // "msg": "删除销售数据成功",
  3265. // })
  3266. //
  3267. //}
  3268. // 获取当天起止时间戳
  3269. func GetNowTime() (int64, int64) {
  3270. t := time.Now()
  3271. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3272. timesamp := addTime.Unix()
  3273. return timesamp, timesamp + 86399
  3274. }
  3275. func (c *HisApiController) ChangeDrugfour() {
  3276. patient_id, _ := c.GetInt64("patient_id")
  3277. admin_user_id, _ := c.GetInt64("admin_user_id")
  3278. times := c.GetString("time", "")
  3279. timeLayout := "2006-01-02"
  3280. loc, _ := time.LoadLocation("Local")
  3281. var stime, etime int64
  3282. if times == "" {
  3283. stime, etime = GetNowTime()
  3284. } else {
  3285. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3286. stime = stmp.Unix()
  3287. etime = stime + 86399
  3288. }
  3289. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3290. //var flows []*models.DrugFlow
  3291. //for _, item := range advicelist {
  3292. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3293. // flows = append(flows, flow...)
  3294. //}
  3295. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3297. var err []string
  3298. for _, item := range advicelist {
  3299. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3300. if prescription.OrderStatus == 2 {
  3301. var res FJ3507Result
  3302. var res3507for10188 FJ3507ResultFor10188
  3303. number := strconv.FormatInt(item.ID, 10)
  3304. //进行商品销售接口
  3305. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number, stime)
  3306. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3307. var respJSON3 map[string]interface{}
  3308. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3311. return
  3312. }
  3313. userJSONBytes3, _ := json.Marshal(respJSON3)
  3314. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3315. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3316. utils.ErrorLog("解析失败:%v", err)
  3317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3318. return
  3319. }
  3320. //if res3507for10188.Infcode
  3321. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3322. //res.Output = resSix10265.Output
  3323. res.ErrMsg = res3507for10188.ErrMsg
  3324. res.Cainfo = res3507for10188.Cainfo
  3325. res.WarnMsg = res3507for10188.WarnMsg
  3326. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3327. res.Infcode = infocode
  3328. } else {
  3329. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3330. utils.ErrorLog("解析失败:%v", err)
  3331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3332. return
  3333. }
  3334. }
  3335. if res.Infcode == 0 {
  3336. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3337. } else {
  3338. err = append(err, item.AdviceName+",销售失败:"+res.ErrMsg)
  3339. }
  3340. } else { //还没结,提示用户去结算,并药品追溯上传
  3341. err = append(err, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3342. }
  3343. }
  3344. str := strings.Join(err, " ")
  3345. saveLog(str, str, "3505", "3505自动上传日志")
  3346. c.ServeSuccessJSON(map[string]interface{}{
  3347. "status": "1",
  3348. "msg": err,
  3349. })
  3350. }
  3351. func (c *HisApiController) ChangeDrugFive() {
  3352. id := c.GetString("id")
  3353. ids := strings.Split(id, ",")
  3354. admin_user_id, _ := c.GetInt64("admin_user_id")
  3355. var errs []string
  3356. //校验gui'ge
  3357. for _, value := range ids {
  3358. intValue, _ := strconv.ParseInt(value, 10, 64)
  3359. //file := strconv.FormatInt(int64(num), 10)
  3360. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3361. //for _, item := range advicelist {
  3362. // flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3363. // flows = append(flows, flow...)
  3364. //}
  3365. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3366. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3367. for _, item := range advicelist {
  3368. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3369. if prescription.OrderStatus != 2 {
  3370. // 将时间戳转换为time.Time类型
  3371. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3372. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3373. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法上传")
  3374. }
  3375. if len(item.DrugCode) > 0 {
  3376. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3377. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3378. codes := strings.Split(item.DrugCode, ",")
  3379. for _, code := range codes {
  3380. if len(code) > 0 {
  3381. if len(code) != 20 {
  3382. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  3383. }
  3384. if IsDigit(code) == false {
  3385. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  3386. }
  3387. }
  3388. }
  3389. }
  3390. }
  3391. }
  3392. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3393. if len(errs) > 0 {
  3394. c.ServeSuccessJSON(map[string]interface{}{
  3395. "failed_code": -10,
  3396. "msg": errs,
  3397. })
  3398. return
  3399. }
  3400. for _, value := range ids {
  3401. intValue, _ := strconv.ParseInt(value, 10, 64)
  3402. //file := strconv.FormatInt(int64(num), 10)
  3403. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3404. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3405. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3406. for _, item := range advicelist {
  3407. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3408. if prescription.OrderStatus == 2 {
  3409. var res FJ3507Result
  3410. var res3507for10188 FJ3507ResultFor10188
  3411. number := strconv.FormatInt(item.ID, 10)
  3412. //进行商品销售接口
  3413. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number, item.RecordDate)
  3414. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3415. var respJSON3 map[string]interface{}
  3416. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. return
  3420. }
  3421. userJSONBytes3, _ := json.Marshal(respJSON3)
  3422. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3423. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3424. utils.ErrorLog("解析失败:%v", err)
  3425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3426. return
  3427. }
  3428. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3429. res.ErrMsg = res3507for10188.ErrMsg
  3430. res.Cainfo = res3507for10188.Cainfo
  3431. res.WarnMsg = res3507for10188.WarnMsg
  3432. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3433. res.Infcode = infocode
  3434. } else {
  3435. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3436. utils.ErrorLog("解析失败:%v", err)
  3437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3438. return
  3439. }
  3440. }
  3441. if res.Infcode == 0 {
  3442. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3443. } else {
  3444. errs = append(errs, item.AdviceName+",销售失败:"+res.ErrMsg)
  3445. }
  3446. } else { //还没结,提示用户去结算,并药品追溯上传
  3447. errs = append(errs, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3448. }
  3449. }
  3450. str := strings.Join(errs, " ")
  3451. saveLog(str, str, "3505", "3505自动上传日志")
  3452. }
  3453. c.ServeSuccessJSON(map[string]interface{}{
  3454. "status": "1",
  3455. "msg": errs,
  3456. })
  3457. }
  3458. //func (c *HisApiController) ChangeDrugfour() {
  3459. // patient_id, _ := c.GetInt64("patient_id")
  3460. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3461. // //id_arr := strings.Split(ids, ",")
  3462. // times := c.GetString("time", "")
  3463. // timeLayout := "2006-01-02"
  3464. // loc, _ := time.LoadLocation("Local")
  3465. // var stime, etime int64
  3466. // if times == "" {
  3467. // stime, etime = GetNowTime()
  3468. // } else {
  3469. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3470. // stime = stmp.Unix()
  3471. // etime = stime + 86399
  3472. // }
  3473. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3474. // var flows []*models.DrugFlow
  3475. // for _, item := range advicelist {
  3476. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3477. // flows = append(flows, flow...)
  3478. // }
  3479. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3480. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3481. // var err []string
  3482. //
  3483. // for _, item := range flows {
  3484. // var res3 ResultSix
  3485. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3486. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3487. // if prescription.OrderStatus == 2 {
  3488. // //已经结算
  3489. // //判断是否已经销售
  3490. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3491. // //是否已经变更 1是 0否
  3492. // if item.IsChange == 0 { //没变更,进行变更操作
  3493. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3494. //
  3495. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3496. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3497. // var respJSON3 map[string]interface{}
  3498. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3499. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. // return
  3502. // }
  3503. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3504. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3505. // utils.ErrorLog("解析失败:%v", err)
  3506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. // return
  3508. // }
  3509. // if res3.Infcode == 0 {
  3510. // item.IsChange = 1
  3511. // item.BgBchno = bg_number
  3512. // service.SaveDF2(item)
  3513. // } else {
  3514. //
  3515. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3516. // }
  3517. // }
  3518. // } else { //没销售,
  3519. // var res FJ3507Result
  3520. // var res3507for10188 FJ3507ResultFor10188
  3521. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3522. //
  3523. // //进行商品销售接口
  3524. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3525. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3526. // var respJSON3 map[string]interface{}
  3527. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3528. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3530. // return
  3531. // }
  3532. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3533. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3534. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3535. // utils.ErrorLog("解析失败:%v", err)
  3536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3537. // return
  3538. // }
  3539. // //if res3507for10188.Infcode
  3540. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3541. // //res.Output = resSix10265.Output
  3542. // res.ErrMsg = res3507for10188.ErrMsg
  3543. // res.Cainfo = res3507for10188.Cainfo
  3544. // res.WarnMsg = res3507for10188.WarnMsg
  3545. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3546. // res.Infcode = infocode
  3547. // } else {
  3548. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3549. // utils.ErrorLog("解析失败:%v", err)
  3550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3551. // return
  3552. // }
  3553. //
  3554. // }
  3555. // if res.Infcode == 0 {
  3556. // item.IsSale = 1
  3557. // item.Bchno = number
  3558. // item.SaleDate = time.Now().Format("2006-01-02")
  3559. //
  3560. // err5 := service.SaveDF(item)
  3561. // if err5 == nil {
  3562. // if item.IsChange == 0 { //没变更,进行变更操作
  3563. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3564. //
  3565. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3566. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3567. //
  3568. // var respJSON3 map[string]interface{}
  3569. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3570. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3572. // return
  3573. // }
  3574. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3575. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3576. // utils.ErrorLog("解析失败:%v", err)
  3577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3578. // return
  3579. // }
  3580. // //if res3507for10188.Infcode
  3581. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3582. // //res.Output = resSix10265.Output
  3583. // res3.ErrMsg = res3507for10188.ErrMsg
  3584. // res3.Cainfo = res3507for10188.Cainfo
  3585. // res3.WarnMsg = res3507for10188.WarnMsg
  3586. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3587. // res3.Infcode = infocode
  3588. // } else {
  3589. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3590. // utils.ErrorLog("解析失败:%v", err)
  3591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3592. // return
  3593. // }
  3594. // }
  3595. // if res3.Infcode == 0 {
  3596. // item.IsChange = 1
  3597. // item.BgBchno = bg_number
  3598. // service.SaveDF2(item)
  3599. // } else {
  3600. //
  3601. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3602. // }
  3603. // }
  3604. // }
  3605. // } else {
  3606. //
  3607. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3608. // }
  3609. // }
  3610. //
  3611. // } else { //还没结,提示用户去结算,并药品追溯上传
  3612. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3613. // }
  3614. // }
  3615. // }
  3616. // if len(err) == 0 {
  3617. // c.ServeSuccessJSON(map[string]interface{}{
  3618. // "msg": "销售变更成功",
  3619. // })
  3620. // } else {
  3621. // c.ServeSuccessJSON(map[string]interface{}{
  3622. // "failed_code": -10,
  3623. // "msg": err,
  3624. // })
  3625. // }
  3626. //}
  3627. //func (c *HisApiController) ChangeDrug() {
  3628. // ids := c.GetString("ids")
  3629. // id_arr := strings.Split(ids, ",")
  3630. // flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3631. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3632. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3633. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3634. // var err []string
  3635. // for _, item := range flows {
  3636. // var res3 ResultSix
  3637. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3638. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3639. // if prescription.OrderStatus == 2 {
  3640. // //已经结算
  3641. // //判断是否已经销售
  3642. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3643. // //是否已经变更 1是 0否
  3644. // if item.IsChange == 0 { //没变更,进行变更操作
  3645. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3646. //
  3647. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3648. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3649. // var respJSON3 map[string]interface{}
  3650. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3651. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3653. // return
  3654. // }
  3655. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3656. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3657. // utils.ErrorLog("解析失败:%v", err)
  3658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3659. // return
  3660. // }
  3661. // if res3.Infcode == 0 {
  3662. // item.IsChange = 1
  3663. // item.BgBchno = bg_number
  3664. // service.SaveDF2(item)
  3665. // } else {
  3666. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3667. // }
  3668. // }
  3669. // } else { //没销售,
  3670. // var res FJ3507Result
  3671. // var res3507for10188 FJ3507ResultFor10188
  3672. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3673. //
  3674. // //进行商品销售接口
  3675. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3676. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3677. // var respJSON3 map[string]interface{}
  3678. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3679. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. // return
  3682. // }
  3683. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3684. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3685. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3686. // utils.ErrorLog("解析失败:%v", err)
  3687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3688. // return
  3689. // }
  3690. // //if res3507for10188.Infcode
  3691. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3692. // //res.Output = resSix10265.Output
  3693. // res.ErrMsg = res3507for10188.ErrMsg
  3694. // res.Cainfo = res3507for10188.Cainfo
  3695. // res.WarnMsg = res3507for10188.WarnMsg
  3696. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3697. // res.Infcode = infocode
  3698. // } else {
  3699. //
  3700. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3701. // utils.ErrorLog("解析失败:%v", err)
  3702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3703. // return
  3704. // }
  3705. //
  3706. // }
  3707. //
  3708. // if res.Infcode == 0 {
  3709. // item.IsSale = 1
  3710. // item.Bchno = number
  3711. // item.SaleDate = time.Now().Format("2006-01-02")
  3712. //
  3713. // err5 := service.SaveDF(item)
  3714. // if err5 == nil {
  3715. // if item.IsChange == 0 { //没变更,进行变更操作
  3716. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3717. //
  3718. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3719. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3720. //
  3721. // var respJSON3 map[string]interface{}
  3722. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3725. // return
  3726. // }
  3727. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3728. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3729. // utils.ErrorLog("解析失败:%v", err)
  3730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3731. // return
  3732. // }
  3733. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3734. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3735. // utils.ErrorLog("解析失败:%v", err)
  3736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3737. // return
  3738. // }
  3739. // //if res3507for10188.Infcode
  3740. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3741. // //res.Output = resSix10265.Output
  3742. // res3.ErrMsg = res3507for10188.ErrMsg
  3743. // res3.Cainfo = res3507for10188.Cainfo
  3744. // res3.WarnMsg = res3507for10188.WarnMsg
  3745. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3746. // res3.Infcode = infocode
  3747. // } else {
  3748. //
  3749. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3750. // utils.ErrorLog("解析失败:%v", err)
  3751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3752. // return
  3753. // }
  3754. //
  3755. // }
  3756. //
  3757. // if res3.Infcode == 0 {
  3758. // item.IsChange = 1
  3759. // item.BgBchno = bg_number
  3760. // service.SaveDF2(item)
  3761. // } else {
  3762. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3763. // }
  3764. // }
  3765. // }
  3766. // } else {
  3767. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3768. // }
  3769. // }
  3770. //
  3771. // } else { //还没结算
  3772. // var res3507for10188 FJ3507ResultFor10188
  3773. //
  3774. // if item.IsChange == 0 { //没变更,进行变更操作
  3775. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3776. //
  3777. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3778. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3779. //
  3780. // var respJSON3 map[string]interface{}
  3781. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3782. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3784. // return
  3785. // }
  3786. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3787. //
  3788. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3789. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3790. // utils.ErrorLog("解析失败:%v", err)
  3791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3792. // return
  3793. // }
  3794. // //if res3507for10188.Infcode
  3795. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3796. // //res.Output = resSix10265.Output
  3797. // res3.ErrMsg = res3507for10188.ErrMsg
  3798. // res3.Cainfo = res3507for10188.Cainfo
  3799. // res3.WarnMsg = res3507for10188.WarnMsg
  3800. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3801. // res3.Infcode = infocode
  3802. // } else {
  3803. //
  3804. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3805. // utils.ErrorLog("解析失败:%v", err)
  3806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3807. // return
  3808. // }
  3809. //
  3810. // }
  3811. //
  3812. // if res3.Infcode == 0 {
  3813. // item.IsChange = 1
  3814. // item.BgBchno = bg_number
  3815. // service.SaveDF2(item)
  3816. // } else {
  3817. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3818. // }
  3819. // }
  3820. // }
  3821. // } else if item.ConsumableType == 7 {
  3822. // var res3507for10188 FJ3507ResultFor10188
  3823. //
  3824. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3825. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3826. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3827. // //判断是否已经销售
  3828. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3829. // //是否已经变更 1是 0否
  3830. // if item.IsChange == 0 { //没变更,进行变更操作
  3831. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3832. //
  3833. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3834. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3835. //
  3836. // var respJSON3 map[string]interface{}
  3837. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3838. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3840. // return
  3841. // }
  3842. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3843. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3844. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3845. // utils.ErrorLog("解析失败:%v", err)
  3846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3847. // return
  3848. // }
  3849. // //if res3507for10188.Infcode
  3850. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3851. // //res.Output = resSix10265.Output
  3852. // res3.ErrMsg = res3507for10188.ErrMsg
  3853. // res3.Cainfo = res3507for10188.Cainfo
  3854. // res3.WarnMsg = res3507for10188.WarnMsg
  3855. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3856. // res3.Infcode = infocode
  3857. // } else {
  3858. //
  3859. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3860. // utils.ErrorLog("解析失败:%v", err)
  3861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3862. // return
  3863. // }
  3864. //
  3865. // }
  3866. // if res3.Infcode == 0 {
  3867. // item.IsChange = 1
  3868. // item.BgBchno = bg_number
  3869. // service.SaveDF2(item)
  3870. // } else {
  3871. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3872. // }
  3873. // }
  3874. // } else { //没销售,
  3875. // //进行商品销售退货接口
  3876. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3877. //
  3878. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3879. // saveLog(result111, result222, "3506", "销售退货")
  3880. // var res7 FJ3507Result
  3881. //
  3882. // //进行商品销售接口
  3883. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3884. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3885. // var respJSON3 map[string]interface{}
  3886. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3889. // return
  3890. // }
  3891. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3892. //
  3893. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3894. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3895. // utils.ErrorLog("解析失败:%v", err)
  3896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3897. // return
  3898. // }
  3899. // //if res3507for10188.Infcode
  3900. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3901. // //res.Output = resSix10265.Output
  3902. // res7.ErrMsg = res3507for10188.ErrMsg
  3903. // res7.Cainfo = res3507for10188.Cainfo
  3904. // res7.WarnMsg = res3507for10188.WarnMsg
  3905. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3906. // res7.Infcode = infocode
  3907. // } else {
  3908. //
  3909. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3910. // utils.ErrorLog("解析失败:%v", err)
  3911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3912. // return
  3913. // }
  3914. //
  3915. // }
  3916. // if res7.Infcode == 0 {
  3917. // item.IsSale = 2
  3918. // item.SaleDate = item.SaleDate
  3919. // item.Bchno = number
  3920. // service.SaveDF(item)
  3921. // if item.IsChange == 0 { //没变更,进行变更操作
  3922. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3923. //
  3924. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3925. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3926. //
  3927. // var respJSON3 map[string]interface{}
  3928. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3929. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3931. // return
  3932. // }
  3933. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3934. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3935. // // utils.ErrorLog("解析失败:%v", err)
  3936. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3937. // // return
  3938. // //}
  3939. //
  3940. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3941. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3942. // utils.ErrorLog("解析失败:%v", err)
  3943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3944. // return
  3945. // }
  3946. // //if res3507for10188.Infcode
  3947. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3948. // //res.Output = resSix10265.Output
  3949. // res3.ErrMsg = res3507for10188.ErrMsg
  3950. // res3.Cainfo = res3507for10188.Cainfo
  3951. // res3.WarnMsg = res3507for10188.WarnMsg
  3952. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3953. // res3.Infcode = infocode
  3954. // } else {
  3955. //
  3956. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3957. // utils.ErrorLog("解析失败:%v", err)
  3958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. // return
  3960. // }
  3961. //
  3962. // }
  3963. // if res3.Infcode == 0 {
  3964. // item.IsChange = 1
  3965. // item.BgBchno = bg_number
  3966. // service.SaveDF2(item)
  3967. // } else {
  3968. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3969. // }
  3970. // }
  3971. // } else {
  3972. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3973. // }
  3974. // }
  3975. // } else { //还没结算
  3976. // if item.IsChange == 0 { //没变更,进行变更操作
  3977. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3978. //
  3979. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3980. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3981. //
  3982. // var respJSON3 map[string]interface{}
  3983. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3984. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3985. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3986. // return
  3987. // }
  3988. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3989. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3990. // // utils.ErrorLog("解析失败:%v", err)
  3991. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3992. // // return
  3993. // //}
  3994. //
  3995. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3996. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3997. // utils.ErrorLog("解析失败:%v", err)
  3998. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3999. // return
  4000. // }
  4001. // //if res3507for10188.Infcode
  4002. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4003. // //res.Output = resSix10265.Output
  4004. // res3.ErrMsg = res3507for10188.ErrMsg
  4005. // res3.Cainfo = res3507for10188.Cainfo
  4006. // res3.WarnMsg = res3507for10188.WarnMsg
  4007. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4008. // res3.Infcode = infocode
  4009. // } else {
  4010. //
  4011. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4012. // utils.ErrorLog("解析失败:%v", err)
  4013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4014. // return
  4015. // }
  4016. //
  4017. // }
  4018. // if res3.Infcode == 0 {
  4019. // item.IsChange = 1
  4020. // item.BgBchno = bg_number
  4021. // service.SaveDF2(item)
  4022. // } else {
  4023. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4024. // }
  4025. // }
  4026. // }
  4027. // }
  4028. // }
  4029. // if len(err) == 0 {
  4030. // c.ServeSuccessJSON(map[string]interface{}{
  4031. // "msg": "销售变更成功",
  4032. // })
  4033. // } else {
  4034. // c.ServeSuccessJSON(map[string]interface{}{
  4035. // "failed_code": -10,
  4036. // "msg": err,
  4037. // })
  4038. // }
  4039. //}
  4040. //func (c *HisApiController) ChangeDrugtwo() {
  4041. //
  4042. // //ids := c.GetString("ids")
  4043. // //id_arr := strings.Split(ids, ",")
  4044. // flows, _ := service.GetNewDrugFlowInfothree123()
  4045. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4046. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4047. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4048. // var err []string
  4049. // for _, item := range flows {
  4050. // var res3 ResultSix
  4051. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4052. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4053. // if prescription.OrderStatus == 2 {
  4054. // //已经结算
  4055. // //判断是否已经销售
  4056. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4057. // // //是否已经变更 1是 0否
  4058. // // if item.IsChange == 0 { //没变更,进行变更操作
  4059. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4060. // //
  4061. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4062. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4063. // // var respJSON3 map[string]interface{}
  4064. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4065. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4066. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. // // return
  4068. // // }
  4069. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4070. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4071. // // utils.ErrorLog("解析失败:%v", err)
  4072. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4073. // // return
  4074. // // }
  4075. // // if res3.Infcode == 0 {
  4076. // // item.IsChange = 1
  4077. // // item.BgBchno = bg_number
  4078. // // service.SaveDF2(item)
  4079. // // } else {
  4080. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4081. // // }
  4082. // // }
  4083. // //}
  4084. // //else
  4085. // { //没销售,
  4086. // var res FJ3507Result
  4087. // var res3507for10188 FJ3507ResultFor10188
  4088. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4089. //
  4090. // //进行商品销售接口
  4091. // result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4092. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4093. // var respJSON3 map[string]interface{}
  4094. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4097. // return
  4098. // }
  4099. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4100. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4101. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4102. // utils.ErrorLog("解析失败:%v", err)
  4103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4104. // return
  4105. // }
  4106. // //if res3507for10188.Infcode
  4107. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4108. // //res.Output = resSix10265.Output
  4109. // res.ErrMsg = res3507for10188.ErrMsg
  4110. // res.Cainfo = res3507for10188.Cainfo
  4111. // res.WarnMsg = res3507for10188.WarnMsg
  4112. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4113. // res.Infcode = infocode
  4114. // } else {
  4115. //
  4116. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4117. // utils.ErrorLog("解析失败:%v", err)
  4118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4119. // return
  4120. // }
  4121. //
  4122. // }
  4123. //
  4124. // if res.Infcode == 0 {
  4125. // item.IsSale = 1
  4126. // item.Bchno = number
  4127. // item.SaleDate = time.Now().Format("2006-01-02")
  4128. //
  4129. // service.SaveDF(item)
  4130. // //if err5 == nil {
  4131. // // if item.IsChange == 0 { //没变更,进行变更操作
  4132. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4133. // //
  4134. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4135. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4136. // //
  4137. // // var respJSON3 map[string]interface{}
  4138. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4139. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4140. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. // // return
  4142. // // }
  4143. // //
  4144. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4145. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4146. // // utils.ErrorLog("解析失败:%v", err)
  4147. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4148. // // return
  4149. // // }
  4150. // // //if res3507for10188.Infcode
  4151. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4152. // // //res.Output = resSix10265.Output
  4153. // // res3.ErrMsg = res3507for10188.ErrMsg
  4154. // // res3.Cainfo = res3507for10188.Cainfo
  4155. // // res3.WarnMsg = res3507for10188.WarnMsg
  4156. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4157. // // res3.Infcode = infocode
  4158. // // } else {
  4159. // //
  4160. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4161. // // utils.ErrorLog("解析失败:%v", err)
  4162. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4163. // // return
  4164. // // }
  4165. // //
  4166. // // }
  4167. // //
  4168. // // if res3.Infcode == 0 {
  4169. // // item.IsChange = 1
  4170. // // item.BgBchno = bg_number
  4171. // // service.SaveDF2(item)
  4172. // // } else {
  4173. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4174. // // }
  4175. // // }
  4176. // //}
  4177. // } else {
  4178. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4179. // }
  4180. // }
  4181. //
  4182. // } else { //还没结算
  4183. // var res3507for10188 FJ3507ResultFor10188
  4184. //
  4185. // if item.IsChange == 0 { //没变更,进行变更操作
  4186. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4187. //
  4188. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4189. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4190. //
  4191. // var respJSON3 map[string]interface{}
  4192. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4195. // return
  4196. // }
  4197. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4198. //
  4199. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4200. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4201. // utils.ErrorLog("解析失败:%v", err)
  4202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4203. // return
  4204. // }
  4205. // //if res3507for10188.Infcode
  4206. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4207. // //res.Output = resSix10265.Output
  4208. // res3.ErrMsg = res3507for10188.ErrMsg
  4209. // res3.Cainfo = res3507for10188.Cainfo
  4210. // res3.WarnMsg = res3507for10188.WarnMsg
  4211. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4212. // res3.Infcode = infocode
  4213. // } else {
  4214. //
  4215. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4216. // utils.ErrorLog("解析失败:%v", err)
  4217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4218. // return
  4219. // }
  4220. //
  4221. // }
  4222. //
  4223. // if res3.Infcode == 0 {
  4224. // item.IsChange = 1
  4225. // item.BgBchno = bg_number
  4226. // service.SaveDF2(item)
  4227. // } else {
  4228. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4229. // }
  4230. // }
  4231. // }
  4232. // }
  4233. // //if item.ConsumableType == 7 {
  4234. // // var res3507for10188 FJ3507ResultFor10188
  4235. // //
  4236. // // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4237. // // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4238. // // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4239. // // //判断是否已经销售
  4240. // // if item.IsSale == 2 { //是否已经销售,1是 0否
  4241. // // //是否已经变更 1是 0否
  4242. // // if item.IsChange == 0 { //没变更,进行变更操作
  4243. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4244. // //
  4245. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4246. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4247. // //
  4248. // // var respJSON3 map[string]interface{}
  4249. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4250. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4251. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. // // return
  4253. // // }
  4254. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4255. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4256. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4257. // // utils.ErrorLog("解析失败:%v", err)
  4258. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4259. // // return
  4260. // // }
  4261. // // //if res3507for10188.Infcode
  4262. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4263. // // //res.Output = resSix10265.Output
  4264. // // res3.ErrMsg = res3507for10188.ErrMsg
  4265. // // res3.Cainfo = res3507for10188.Cainfo
  4266. // // res3.WarnMsg = res3507for10188.WarnMsg
  4267. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4268. // // res3.Infcode = infocode
  4269. // // } else {
  4270. // //
  4271. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4272. // // utils.ErrorLog("解析失败:%v", err)
  4273. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4274. // // return
  4275. // // }
  4276. // //
  4277. // // }
  4278. // // if res3.Infcode == 0 {
  4279. // // item.IsChange = 1
  4280. // // item.BgBchno = bg_number
  4281. // // service.SaveDF2(item)
  4282. // // } else {
  4283. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4284. // // }
  4285. // // }
  4286. // // } else { //没销售,
  4287. // // //进行商品销售退货接口
  4288. // // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4289. // //
  4290. // // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4291. // // saveLog(result111, result222, "3506", "销售退货")
  4292. // // var res7 FJ3507Result
  4293. // //
  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. // //
  4305. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4306. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4307. // // utils.ErrorLog("解析失败:%v", err)
  4308. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. // // return
  4310. // // }
  4311. // // //if res3507for10188.Infcode
  4312. // // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4313. // // //res.Output = resSix10265.Output
  4314. // // res7.ErrMsg = res3507for10188.ErrMsg
  4315. // // res7.Cainfo = res3507for10188.Cainfo
  4316. // // res7.WarnMsg = res3507for10188.WarnMsg
  4317. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4318. // // res7.Infcode = infocode
  4319. // // } else {
  4320. // //
  4321. // // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4322. // // utils.ErrorLog("解析失败:%v", err)
  4323. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4324. // // return
  4325. // // }
  4326. // //
  4327. // // }
  4328. // // if res7.Infcode == 0 {
  4329. // // item.IsSale = 2
  4330. // // item.SaleDate = item.SaleDate
  4331. // // item.Bchno = number
  4332. // // service.SaveDF(item)
  4333. // // if item.IsChange == 0 { //没变更,进行变更操作
  4334. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4335. // //
  4336. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4337. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4338. // //
  4339. // // var respJSON3 map[string]interface{}
  4340. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4341. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4342. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. // // return
  4344. // // }
  4345. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4346. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4347. // // // utils.ErrorLog("解析失败:%v", err)
  4348. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. // // // return
  4350. // // //}
  4351. // //
  4352. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4353. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4354. // // utils.ErrorLog("解析失败:%v", err)
  4355. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. // // return
  4357. // // }
  4358. // // //if res3507for10188.Infcode
  4359. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4360. // // //res.Output = resSix10265.Output
  4361. // // res3.ErrMsg = res3507for10188.ErrMsg
  4362. // // res3.Cainfo = res3507for10188.Cainfo
  4363. // // res3.WarnMsg = res3507for10188.WarnMsg
  4364. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4365. // // res3.Infcode = infocode
  4366. // // } else {
  4367. // //
  4368. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4369. // // utils.ErrorLog("解析失败:%v", err)
  4370. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4371. // // return
  4372. // // }
  4373. // //
  4374. // // }
  4375. // // if res3.Infcode == 0 {
  4376. // // item.IsChange = 1
  4377. // // item.BgBchno = bg_number
  4378. // // service.SaveDF2(item)
  4379. // // } else {
  4380. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4381. // // }
  4382. // // }
  4383. // // } else {
  4384. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4385. // // }
  4386. // // }
  4387. // // } else { //还没结算
  4388. // // if item.IsChange == 0 { //没变更,进行变更操作
  4389. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4390. // //
  4391. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4392. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4393. // //
  4394. // // var respJSON3 map[string]interface{}
  4395. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4396. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4397. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. // // return
  4399. // // }
  4400. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4401. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4402. // // // utils.ErrorLog("解析失败:%v", err)
  4403. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. // // // return
  4405. // // //}
  4406. // //
  4407. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4408. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4409. // // utils.ErrorLog("解析失败:%v", err)
  4410. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4411. // // return
  4412. // // }
  4413. // // //if res3507for10188.Infcode
  4414. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4415. // // //res.Output = resSix10265.Output
  4416. // // res3.ErrMsg = res3507for10188.ErrMsg
  4417. // // res3.Cainfo = res3507for10188.Cainfo
  4418. // // res3.WarnMsg = res3507for10188.WarnMsg
  4419. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4420. // // res3.Infcode = infocode
  4421. // // } else {
  4422. // //
  4423. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4424. // // utils.ErrorLog("解析失败:%v", err)
  4425. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4426. // // return
  4427. // // }
  4428. // //
  4429. // // }
  4430. // // if res3.Infcode == 0 {
  4431. // // item.IsChange = 1
  4432. // // item.BgBchno = bg_number
  4433. // // service.SaveDF2(item)
  4434. // // } else {
  4435. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4436. // // }
  4437. // // }
  4438. // // }
  4439. // //}
  4440. // }
  4441. // if len(err) == 0 {
  4442. // c.ServeSuccessJSON(map[string]interface{}{
  4443. // "msg": "销售变更成功",
  4444. // })
  4445. // } else {
  4446. // c.ServeSuccessJSON(map[string]interface{}{
  4447. // "failed_code": -10,
  4448. // "msg": err,
  4449. // })
  4450. // }
  4451. //}
  4452. //
  4453. //func (c *HisApiController) ChangeDrugthree() {
  4454. //
  4455. // //ids := c.GetString("ids")
  4456. // //id_arr := strings.Split(ids, ",")
  4457. // flows, _ := service.GetNewDrugFlowInfothree()
  4458. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4459. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4460. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4461. // var err []string
  4462. // for _, item := range flows {
  4463. // var res3 ResultSix
  4464. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  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. // var res FJ3507Result
  4498. // var res3507for10188 FJ3507ResultFor10188
  4499. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4500. //
  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 == 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 {
  4526. //
  4527. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4528. // utils.ErrorLog("解析失败:%v", err)
  4529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. // return
  4531. // }
  4532. //
  4533. // }
  4534. //
  4535. // if res.Infcode == 0 {
  4536. // item.IsSale = 1
  4537. // item.Bchno = number
  4538. // item.SaleDate = time.Now().Format("2006-01-02")
  4539. //
  4540. // err5 := service.SaveDF(item)
  4541. // if err5 == nil {
  4542. // if item.IsChange == 0 { //没变更,进行变更操作
  4543. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4544. //
  4545. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4546. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4547. //
  4548. // var respJSON3 map[string]interface{}
  4549. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4552. // return
  4553. // }
  4554. //
  4555. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4556. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4557. // utils.ErrorLog("解析失败:%v", err)
  4558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4559. // return
  4560. // }
  4561. // //if res3507for10188.Infcode
  4562. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4563. // //res.Output = resSix10265.Output
  4564. // res3.ErrMsg = res3507for10188.ErrMsg
  4565. // res3.Cainfo = res3507for10188.Cainfo
  4566. // res3.WarnMsg = res3507for10188.WarnMsg
  4567. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4568. // res3.Infcode = infocode
  4569. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4570. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4571. // utils.ErrorLog("解析失败:%v", err)
  4572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. // return
  4574. // }
  4575. // //if res3507for10188.Infcode
  4576. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4577. // //res.Output = resSix10265.Output
  4578. // res3.ErrMsg = res3507for10188.ErrMsg
  4579. // res3.Cainfo = res3507for10188.Cainfo
  4580. // res3.WarnMsg = res3507for10188.WarnMsg
  4581. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4582. // res3.Infcode = infocode
  4583. //
  4584. // } else {
  4585. //
  4586. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4587. // utils.ErrorLog("解析失败:%v", err)
  4588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4589. // return
  4590. // }
  4591. //
  4592. // }
  4593. //
  4594. // if res3.Infcode == 0 {
  4595. // item.IsChange = 1
  4596. // item.BgBchno = bg_number
  4597. // service.SaveDF2(item)
  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 { //还没结算
  4609. // var res3507for10188 FJ3507ResultFor10188
  4610. //
  4611. // if item.IsChange == 0 { //没变更,进行变更操作
  4612. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4613. //
  4614. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4615. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4616. //
  4617. // var respJSON3 map[string]interface{}
  4618. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4619. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. // return
  4622. // }
  4623. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4624. //
  4625. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4626. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4627. // utils.ErrorLog("解析失败:%v", err)
  4628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4629. // return
  4630. // }
  4631. // //if res3507for10188.Infcode
  4632. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4633. // //res.Output = resSix10265.Output
  4634. // res3.ErrMsg = res3507for10188.ErrMsg
  4635. // res3.Cainfo = res3507for10188.Cainfo
  4636. // res3.WarnMsg = res3507for10188.WarnMsg
  4637. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4638. // res3.Infcode = infocode
  4639. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4640. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4641. // utils.ErrorLog("解析失败:%v", err)
  4642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4643. // return
  4644. // }
  4645. // //if res3507for10188.Infcode
  4646. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4647. // //res.Output = resSix10265.Output
  4648. // res3.ErrMsg = res3507for10188.ErrMsg
  4649. // res3.Cainfo = res3507for10188.Cainfo
  4650. // res3.WarnMsg = res3507for10188.WarnMsg
  4651. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4652. // res3.Infcode = infocode
  4653. //
  4654. // } else {
  4655. //
  4656. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4657. // utils.ErrorLog("解析失败:%v", err)
  4658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4659. // return
  4660. // }
  4661. //
  4662. // }
  4663. //
  4664. // if res3.Infcode == 0 {
  4665. // item.IsChange = 1
  4666. // item.BgBchno = bg_number
  4667. // service.SaveDF2(item)
  4668. // } else {
  4669. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4670. // }
  4671. // }
  4672. // }
  4673. // } else if item.ConsumableType == 7 {
  4674. // var res3507for10188 FJ3507ResultFor10188
  4675. //
  4676. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4677. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4678. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4679. // //判断是否已经销售
  4680. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4681. // //是否已经变更 1是 0否
  4682. // if item.IsChange == 0 { //没变更,进行变更操作
  4683. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4684. //
  4685. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4686. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4687. //
  4688. // var respJSON3 map[string]interface{}
  4689. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4690. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4692. // return
  4693. // }
  4694. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4695. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4696. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4697. // utils.ErrorLog("解析失败:%v", err)
  4698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4699. // return
  4700. // }
  4701. // //if res3507for10188.Infcode
  4702. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4703. // //res.Output = resSix10265.Output
  4704. // res3.ErrMsg = res3507for10188.ErrMsg
  4705. // res3.Cainfo = res3507for10188.Cainfo
  4706. // res3.WarnMsg = res3507for10188.WarnMsg
  4707. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4708. // res3.Infcode = infocode
  4709. // } else {
  4710. //
  4711. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4712. // utils.ErrorLog("解析失败:%v", err)
  4713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. // return
  4715. // }
  4716. //
  4717. // }
  4718. // if res3.Infcode == 0 {
  4719. // item.IsChange = 1
  4720. // item.BgBchno = bg_number
  4721. // service.SaveDF2(item)
  4722. // } else {
  4723. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4724. // }
  4725. // }
  4726. // } else { //没销售,
  4727. // //进行商品销售退货接口
  4728. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4729. //
  4730. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4731. // saveLog(result111, result222, "3506", "销售退货")
  4732. // var res7 FJ3507Result
  4733. //
  4734. // //进行商品销售接口
  4735. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4736. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4737. // var respJSON3 map[string]interface{}
  4738. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4739. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4741. // return
  4742. // }
  4743. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4744. //
  4745. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4746. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4747. // utils.ErrorLog("解析失败:%v", err)
  4748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4749. // return
  4750. // }
  4751. // //if res3507for10188.Infcode
  4752. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4753. // //res.Output = resSix10265.Output
  4754. // res7.ErrMsg = res3507for10188.ErrMsg
  4755. // res7.Cainfo = res3507for10188.Cainfo
  4756. // res7.WarnMsg = res3507for10188.WarnMsg
  4757. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4758. // res7.Infcode = infocode
  4759. // } else {
  4760. //
  4761. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4762. // utils.ErrorLog("解析失败:%v", err)
  4763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4764. // return
  4765. // }
  4766. //
  4767. // }
  4768. // if res7.Infcode == 0 {
  4769. // item.IsSale = 2
  4770. // item.SaleDate = item.SaleDate
  4771. // item.Bchno = number
  4772. // service.SaveDF(item)
  4773. // if item.IsChange == 0 { //没变更,进行变更操作
  4774. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4775. //
  4776. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4777. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4778. //
  4779. // var respJSON3 map[string]interface{}
  4780. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4781. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. // return
  4784. // }
  4785. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4786. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4787. // // utils.ErrorLog("解析失败:%v", err)
  4788. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4789. // // return
  4790. // //}
  4791. //
  4792. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4793. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4794. // utils.ErrorLog("解析失败:%v", err)
  4795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4796. // return
  4797. // }
  4798. // //if res3507for10188.Infcode
  4799. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4800. // //res.Output = resSix10265.Output
  4801. // res3.ErrMsg = res3507for10188.ErrMsg
  4802. // res3.Cainfo = res3507for10188.Cainfo
  4803. // res3.WarnMsg = res3507for10188.WarnMsg
  4804. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4805. // res3.Infcode = infocode
  4806. // } else {
  4807. //
  4808. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4809. // utils.ErrorLog("解析失败:%v", err)
  4810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4811. // return
  4812. // }
  4813. //
  4814. // }
  4815. // if res3.Infcode == 0 {
  4816. // item.IsChange = 1
  4817. // item.BgBchno = bg_number
  4818. // service.SaveDF2(item)
  4819. // } else {
  4820. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4821. // }
  4822. // }
  4823. // } else {
  4824. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4825. // }
  4826. // }
  4827. // } else { //还没结算
  4828. // if item.IsChange == 0 { //没变更,进行变更操作
  4829. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4830. //
  4831. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4832. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4833. //
  4834. // var respJSON3 map[string]interface{}
  4835. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4836. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4838. // return
  4839. // }
  4840. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4841. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4842. // // utils.ErrorLog("解析失败:%v", err)
  4843. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. // // return
  4845. // //}
  4846. //
  4847. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4848. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4849. // utils.ErrorLog("解析失败:%v", err)
  4850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4851. // return
  4852. // }
  4853. // //if res3507for10188.Infcode
  4854. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4855. // //res.Output = resSix10265.Output
  4856. // res3.ErrMsg = res3507for10188.ErrMsg
  4857. // res3.Cainfo = res3507for10188.Cainfo
  4858. // res3.WarnMsg = res3507for10188.WarnMsg
  4859. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4860. // res3.Infcode = infocode
  4861. // } else {
  4862. //
  4863. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4864. // utils.ErrorLog("解析失败:%v", err)
  4865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4866. // return
  4867. // }
  4868. //
  4869. // }
  4870. // if res3.Infcode == 0 {
  4871. // item.IsChange = 1
  4872. // item.BgBchno = bg_number
  4873. // service.SaveDF2(item)
  4874. // } else {
  4875. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4876. // }
  4877. // }
  4878. // }
  4879. // }
  4880. // }
  4881. // if len(err) == 0 {
  4882. // c.ServeSuccessJSON(map[string]interface{}{
  4883. // "msg": "销售变更成功",
  4884. // })
  4885. // } else {
  4886. // c.ServeSuccessJSON(map[string]interface{}{
  4887. // "failed_code": -10,
  4888. // "msg": err,
  4889. // })
  4890. // }
  4891. //}
  4892. //func (c *HisApiController) ChangeDrugTen() {
  4893. // start_time_str := c.GetString("start_time")
  4894. // end_time_str := c.GetString("end_time")
  4895. // //ids := c.GetString("ids")
  4896. // //id_arr := strings.Split(ids, ",")
  4897. // timeLayout := "2006-01-02"
  4898. // loc, _ := time.LoadLocation("Local")
  4899. // theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4900. //
  4901. // recordStartTime := theStartTime.Unix()
  4902. //
  4903. // theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4904. //
  4905. // recordEndTime := theEndTime.Unix()
  4906. //
  4907. // //timestamp := int64(1729612800)
  4908. // flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4909. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4910. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4911. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4912. // var err []string
  4913. // for _, item := range flows {
  4914. // var res3 ResultSix
  4915. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4916. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4917. // continue
  4918. // }
  4919. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4920. // continue
  4921. // }
  4922. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4923. //
  4924. // if prescription.OrderStatus == 2 {
  4925. // //已经结算
  4926. // //判断 是否已经销售
  4927. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4928. // ////是否已经变更 1是 0否
  4929. // //if item.IsChange == 0 { //没变更,进行变更操作
  4930. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4931. // //
  4932. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4933. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4934. // // var respJSON3 map[string]interface{}
  4935. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4936. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4937. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4938. // // return
  4939. // // }
  4940. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4941. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4942. // // utils.ErrorLog("解析失败:%v", err)
  4943. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4944. // // return
  4945. // // }
  4946. // // if res3.Infcode == 0 {
  4947. // // item.IsChange = 1
  4948. // // item.BgBchno = bg_number
  4949. // // service.SaveDF2(item)
  4950. // // } else {
  4951. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4952. // // }
  4953. // //}
  4954. //
  4955. // //} else
  4956. // if item.IsSale == 0 { //没销售,
  4957. // var res FJ3507Result
  4958. // var res3507for10188 FJ3507ResultFor10188
  4959. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4960. //
  4961. // //进行商品销售接口
  4962. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4963. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4964. // var respJSON3 map[string]interface{}
  4965. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4966. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4968. // return
  4969. // }
  4970. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4971. // if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  4972. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4973. // utils.ErrorLog("解析失败:%v", err)
  4974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4975. // return
  4976. // }
  4977. // //if res3507for10188.Infcode
  4978. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4979. // //res.Output = resSix10265.Output
  4980. // res.ErrMsg = res3507for10188.ErrMsg
  4981. // res.Cainfo = res3507for10188.Cainfo
  4982. // res.WarnMsg = res3507for10188.WarnMsg
  4983. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4984. // res.Infcode = infocode
  4985. // } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4986. //
  4987. // } else {
  4988. //
  4989. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4990. // utils.ErrorLog("解析失败:%v", err)
  4991. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. // return
  4993. // }
  4994. //
  4995. // }
  4996. //
  4997. // if res.Infcode == 0 {
  4998. // item.IsSale = 1
  4999. // item.Bchno = number
  5000. // item.SaleDate = time.Now().Format("2006-01-02")
  5001. // service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  5002. //
  5003. // err5 := service.SaveDF(item)
  5004. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  5005. // //if err5 == nil {
  5006. // //
  5007. // // if item.IsChange == 1 { //没变更,进行变更操作
  5008. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5009. // //
  5010. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5011. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5012. // //
  5013. // // var respJSON3 map[string]interface{}
  5014. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5015. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5016. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5017. // // return
  5018. // // }
  5019. // //
  5020. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  5021. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5022. // // utils.ErrorLog("解析失败:%v", err)
  5023. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5024. // // return
  5025. // // }
  5026. // // //if res3507for10188.Infcode
  5027. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5028. // // //res.Output = resSix10265.Output
  5029. // // res3.ErrMsg = res3507for10188.ErrMsg
  5030. // // res3.Cainfo = res3507for10188.Cainfo
  5031. // // res3.WarnMsg = res3507for10188.WarnMsg
  5032. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5033. // // res3.Infcode = infocode
  5034. // // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5035. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5036. // // utils.ErrorLog("解析失败:%v", err)
  5037. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5038. // // return
  5039. // // }
  5040. // // //if res3507for10188.Infcode
  5041. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5042. // // //res.Output = resSix10265.Output
  5043. // // res3.ErrMsg = res3507for10188.ErrMsg
  5044. // // res3.Cainfo = res3507for10188.Cainfo
  5045. // // res3.WarnMsg = res3507for10188.WarnMsg
  5046. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5047. // // res3.Infcode = infocode
  5048. // //
  5049. // // } else {
  5050. // //
  5051. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5052. // // utils.ErrorLog("解析失败:%v", err)
  5053. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5054. // // return
  5055. // // }
  5056. // //
  5057. // // }
  5058. // //
  5059. // // if res3.Infcode == 0 {
  5060. // // item.IsChange = 1
  5061. // // item.BgBchno = bg_number
  5062. // // service.SaveDF2(item)
  5063. // // return
  5064. // // } else {
  5065. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5066. // // }
  5067. // // }
  5068. // //}
  5069. // } else {
  5070. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5071. // }
  5072. // }
  5073. //
  5074. // }
  5075. // } else if item.ConsumableType == 7 {
  5076. // var res3507for10188 FJ3507ResultFor10188
  5077. //
  5078. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5079. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  5080. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  5081. // //判断是否已经销售
  5082. // if item.IsSale == 2 { //是否已经销售,1是 0否
  5083. // //是否已经变更 1是 0否
  5084. // if item.IsChange == 0 { //没变更,进行变更操作
  5085. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5086. //
  5087. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5088. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5089. //
  5090. // var respJSON3 map[string]interface{}
  5091. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5092. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5094. // return
  5095. // }
  5096. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5097. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5098. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5099. // utils.ErrorLog("解析失败:%v", err)
  5100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5101. // return
  5102. // }
  5103. // //if res3507for10188.Infcode
  5104. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5105. // //res.Output = resSix10265.Output
  5106. // res3.ErrMsg = res3507for10188.ErrMsg
  5107. // res3.Cainfo = res3507for10188.Cainfo
  5108. // res3.WarnMsg = res3507for10188.WarnMsg
  5109. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5110. // res3.Infcode = infocode
  5111. // } else {
  5112. //
  5113. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5114. // utils.ErrorLog("解析失败:%v", err)
  5115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5116. // return
  5117. // }
  5118. //
  5119. // }
  5120. // if res3.Infcode == 0 {
  5121. // item.IsChange = 1
  5122. // item.BgBchno = bg_number
  5123. // service.SaveDF2(item)
  5124. // } else {
  5125. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5126. // }
  5127. // }
  5128. // } else { //没销售,
  5129. // //进行商品销售退货接口
  5130. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  5131. //
  5132. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  5133. // saveLog(result111, result222, "3506", "销售退货")
  5134. // var res7 FJ3507Result
  5135. //
  5136. // //进行商品销售接口
  5137. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5138. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5139. // var respJSON3 map[string]interface{}
  5140. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5141. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5142. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5143. // return
  5144. // }
  5145. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5146. //
  5147. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5148. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5149. // utils.ErrorLog("解析失败:%v", err)
  5150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5151. // return
  5152. // }
  5153. // //if res3507for10188.Infcode
  5154. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5155. // //res.Output = resSix10265.Output
  5156. // res7.ErrMsg = res3507for10188.ErrMsg
  5157. // res7.Cainfo = res3507for10188.Cainfo
  5158. // res7.WarnMsg = res3507for10188.WarnMsg
  5159. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5160. // res7.Infcode = infocode
  5161. // } else {
  5162. //
  5163. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5164. // utils.ErrorLog("解析失败:%v", err)
  5165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. // return
  5167. // }
  5168. //
  5169. // }
  5170. // if res7.Infcode == 0 {
  5171. // item.IsSale = 2
  5172. // item.SaleDate = item.SaleDate
  5173. // item.Bchno = number
  5174. // service.SaveDF(item)
  5175. // if item.IsChange == 0 { //没变更,进行变更操作
  5176. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5177. //
  5178. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5179. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5180. //
  5181. // var respJSON3 map[string]interface{}
  5182. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5183. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. // return
  5186. // }
  5187. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5188. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5189. // // utils.ErrorLog("解析失败:%v", err)
  5190. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5191. // // return
  5192. // //}
  5193. //
  5194. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5195. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5196. // utils.ErrorLog("解析失败:%v", err)
  5197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. // return
  5199. // }
  5200. // //if res3507for10188.Infcode
  5201. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5202. // //res.Output = resSix10265.Output
  5203. // res3.ErrMsg = res3507for10188.ErrMsg
  5204. // res3.Cainfo = res3507for10188.Cainfo
  5205. // res3.WarnMsg = res3507for10188.WarnMsg
  5206. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5207. // res3.Infcode = infocode
  5208. // } else {
  5209. //
  5210. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5211. // utils.ErrorLog("解析失败:%v", err)
  5212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5213. // return
  5214. // }
  5215. //
  5216. // }
  5217. // if res3.Infcode == 0 {
  5218. // item.IsChange = 1
  5219. // item.BgBchno = bg_number
  5220. // service.SaveDF2(item)
  5221. // } else {
  5222. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5223. // }
  5224. // }
  5225. // } else {
  5226. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5227. // }
  5228. // }
  5229. // } else { //还没结算
  5230. // if item.IsChange == 0 { //没变更,进行变更操作
  5231. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5232. //
  5233. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5234. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5235. //
  5236. // var respJSON3 map[string]interface{}
  5237. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5238. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5240. // return
  5241. // }
  5242. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5243. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5244. // // utils.ErrorLog("解析失败:%v", err)
  5245. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5246. // // return
  5247. // //}
  5248. //
  5249. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5250. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5251. // utils.ErrorLog("解析失败:%v", err)
  5252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5253. // return
  5254. // }
  5255. // //if res3507for10188.Infcode
  5256. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5257. // //res.Output = resSix10265.Output
  5258. // res3.ErrMsg = res3507for10188.ErrMsg
  5259. // res3.Cainfo = res3507for10188.Cainfo
  5260. // res3.WarnMsg = res3507for10188.WarnMsg
  5261. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5262. // res3.Infcode = infocode
  5263. // } else {
  5264. //
  5265. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5266. // utils.ErrorLog("解析失败:%v", err)
  5267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. // return
  5269. // }
  5270. //
  5271. // }
  5272. // if res3.Infcode == 0 {
  5273. // item.IsChange = 1
  5274. // item.BgBchno = bg_number
  5275. // service.SaveDF2(item)
  5276. // } else {
  5277. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5278. // }
  5279. // }
  5280. // }
  5281. // }
  5282. // }
  5283. // if len(err) == 0 {
  5284. // c.ServeSuccessJSON(map[string]interface{}{
  5285. // "msg": "销售变更成功",
  5286. // })
  5287. // } else {
  5288. // c.ServeSuccessJSON(map[string]interface{}{
  5289. // "failed_code": -10,
  5290. // "msg": err,
  5291. // })
  5292. // }
  5293. //}
  5294. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5295. var struct3502 models.Struct3502
  5296. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5297. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5298. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5299. struct3502.FixmedinsCode = miConfig.Code
  5300. struct3502.Code = miConfig.Code
  5301. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5302. struct3502.Opter = role.UserName
  5303. struct3502.RxFlag = "1"
  5304. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5305. struct3502.OrgName = miConfig.OrgName
  5306. struct3502.AccessKey = miConfig.AccessKey
  5307. struct3502.RequestUrl = miConfig.Url
  5308. struct3502.SecretKey = miConfig.SecretKey
  5309. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5310. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5311. struct3502.Url = miConfig.Url
  5312. struct3502.AppId = miConfig.Cainfo
  5313. struct3502.AppSecret = miConfig.AppSecret
  5314. struct3502.Enckey = miConfig.EncKey
  5315. struct3502.SignKey = miConfig.SignKey
  5316. struct3502.SecretKey = miConfig.SecretKey
  5317. struct3502.InvChgType = chgType
  5318. struct3502.FixmedinsBchno = number
  5319. struct3502.Cnt = strconv.FormatInt(count, 10)
  5320. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5321. //result1, result2, _ := service.FJyb3502(struct3502)
  5322. if miConfig.MdtrtareaAdmvs == "350500" {
  5323. result1, result2, _ := service.FJyb3502(struct3502)
  5324. //saveLog(result1, result2, "3502", "3502")
  5325. return result1, result2
  5326. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5327. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5328. return result1, result2
  5329. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5330. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5331. return result1, result2
  5332. } else {
  5333. data := make(map[string]interface{})
  5334. data["struct_3502s"] = struct3502
  5335. client := &http.Client{}
  5336. bytesData, _ := json.Marshal(data)
  5337. var req *http.Request
  5338. if miConfig.MdtrtareaAdmvs == "320830" {
  5339. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5340. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5341. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5342. } else {
  5343. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5344. }
  5345. resp, _ := client.Do(req)
  5346. defer resp.Body.Close()
  5347. body, ioErr := ioutil.ReadAll(resp.Body)
  5348. if ioErr != nil {
  5349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5350. }
  5351. var respJSON map[string]interface{}
  5352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5354. }
  5355. //var resSix10265 ResultSix10265 //1101结果
  5356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5357. result, _ := json.Marshal(respJSON)
  5358. return string(result), ""
  5359. }
  5360. }
  5361. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string, stime int64) (string, string) {
  5362. flow, _ := service.GetNewDrugFlowInfoByPatient(drug.DrugId, stime, org_id)
  5363. Drug, _ := service.GetDrugLibById(drug.DrugId)
  5364. var struct3505 models.Struct3505
  5365. struct3505.MedListCodg = Drug.MedicalInsuranceNumber
  5366. struct3505.FixmedinsHilistId = Drug.MedicalInsuranceNumber
  5367. struct3505.FixmedinsHilistName = Drug.DrugName
  5368. struct3505.FixmedinsBchno = number
  5369. struct3505.Opter = role.UserName
  5370. struct3505.Bchno = "---"
  5371. struct3505.FixmedinsCode = miConfig.Code
  5372. struct3505.Code = miConfig.Code
  5373. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.Price, 'f', -1, 64)
  5374. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5375. struct3505.PrscDrName = roles.UserName
  5376. if org_id == 10191 {
  5377. struct3505.PharName = "刘水山"
  5378. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5379. }
  5380. if org_id == 10188 {
  5381. struct3505.PharName = "李汉清"
  5382. struct3505.PharPracCertNo = "30220200932022010034"
  5383. }
  5384. if org_id == 10217 {
  5385. struct3505.PharName = "张敏"
  5386. struct3505.PharPracCertNo = "30220230432090100108"
  5387. }
  5388. if org_id == 10318 {
  5389. struct3505.PharName = "邹刘阳"
  5390. struct3505.PharPracCertNo = "210441200001378"
  5391. }
  5392. if org_id == 10402 {
  5393. struct3505.PharName = "刘韶健"
  5394. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5395. }
  5396. if org_id == 9919 {
  5397. struct3505.PharName = "周君权"
  5398. struct3505.PharPracCertNo = "089644396094401375"
  5399. }
  5400. if org_id == 10644 {
  5401. struct3505.PharName = "陈金娣"
  5402. struct3505.PharPracCertNo = "20181441500320100066"
  5403. }
  5404. if org_id == 10567 {
  5405. struct3505.PharName = "范小兰"
  5406. struct3505.PharPracCertNo = "0200102079485"
  5407. }
  5408. if org_id == 10721 {
  5409. struct3505.PharName = "孙莉侠"
  5410. struct3505.PharPracCertNo = "060399"
  5411. }
  5412. if org_id == 10726 {
  5413. struct3505.PharName = "彭建福"
  5414. struct3505.PharPracCertNo = "D445281006261"
  5415. }
  5416. if org_id == 10697 {
  5417. struct3505.PharName = "陶海兰"
  5418. struct3505.PharPracCertNo = "0010933"
  5419. }
  5420. if org_id == 10265 {
  5421. struct3505.PharName = "李彩星"
  5422. struct3505.PharPracCertNo = "20171110600110100019"
  5423. }
  5424. if org_id == 10028 {
  5425. struct3505.PharName = "曾细平"
  5426. struct3505.PharPracCertNo = "D440307022134"
  5427. }
  5428. if org_id == 10138 {
  5429. struct3505.PharName = "彭斯遥"
  5430. struct3505.PharPracCertNo = "30220200943042010052"
  5431. }
  5432. if org_id == 10278 {
  5433. struct3505.PharName = "彭斯遥"
  5434. struct3505.PharPracCertNo = "30220200943042010052"
  5435. }
  5436. if org_id == 10610 {
  5437. struct3505.PharName = "彭斯遥"
  5438. struct3505.PharPracCertNo = "30220200943042010052"
  5439. }
  5440. if org_id == 10537 {
  5441. struct3505.PharName = "彭斯遥"
  5442. struct3505.PharPracCertNo = "30220200943042010052"
  5443. }
  5444. if org_id == 9504 {
  5445. struct3505.PharName = "资美红"
  5446. struct3505.PharPracCertNo = "D440904006635"
  5447. }
  5448. if org_id == 10480 {
  5449. struct3505.PharName = "陈思"
  5450. struct3505.PharPracCertNo = "30220240434110010470"
  5451. }
  5452. if org_id == 10653 {
  5453. struct3505.PharName = "邓树英"
  5454. struct3505.PharPracCertNo = "201910026440004734"
  5455. }
  5456. if org_id == 10571 {
  5457. struct3505.PharName = "廖志平"
  5458. struct3505.PharPracCertNo = "0136425"
  5459. }
  5460. if org_id == 10387 {
  5461. struct3505.PharName = "易圣"
  5462. struct3505.PharPracCertNo = "D430726002209"
  5463. }
  5464. if org_id == 10633 {
  5465. struct3505.PharName = "王敏"
  5466. struct3505.PharPracCertNo = "342222199107214042"
  5467. }
  5468. if org_id == 9478 {
  5469. struct3505.PharName = "祁仲钰"
  5470. struct3505.PharPracCertNo = "D440111043488"
  5471. }
  5472. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5473. struct3505.SetlId = order.SetlId
  5474. struct3505.MdtrtSn = order.MdtrtId
  5475. struct3505.ManuLotnum = flow.BatchNumber
  5476. struct3505.ManuDate = time.Unix(flow.ProductDate, 0).Format("2006-01-02")
  5477. struct3505.ExpyEnd = time.Unix(flow.ExpireDate, 0).Format("2006-01-02")
  5478. struct3505.RxFlag = "1"
  5479. if drug.PrescribingNumberUnit != drug.BaseDrugLib.MinUnit {
  5480. struct3505.TrdnFlag = "0"
  5481. } else {
  5482. struct3505.TrdnFlag = "1"
  5483. }
  5484. if drug.ZeroFlag == 1 {
  5485. struct3505.TrdnFlag = "1"
  5486. }
  5487. if drug.ZeroFlag == 2 {
  5488. struct3505.TrdnFlag = "0"
  5489. }
  5490. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 || org_id == 9478 {
  5491. if Drug.IsZeroFlag == 1 {
  5492. struct3505.TrdnFlag = "1"
  5493. }
  5494. if Drug.IsZeroFlag == 2 {
  5495. struct3505.TrdnFlag = "0"
  5496. }
  5497. }
  5498. struct3505.RtalDocno = order.Number
  5499. struct3505.PsnCertType = "01"
  5500. struct3505.CertNo = order.Certno
  5501. struct3505.PsnNo = order.PsnNo
  5502. struct3505.PsnName = order.PsnName
  5503. struct3505.Url = miConfig.Url
  5504. struct3505.AppId = miConfig.Cainfo
  5505. struct3505.AppSecret = miConfig.AppSecret
  5506. struct3505.Enckey = miConfig.EncKey
  5507. struct3505.SignKey = miConfig.SignKey
  5508. struct3505.SecretKey = miConfig.SecretKey
  5509. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  5510. struct3505.SelRetnCnt = strValue
  5511. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5512. struct3505.SelRetnOpterName = role.UserName
  5513. if order.IsMedicineInsurance == 1 {
  5514. struct3505.MdtrtSetlType = "1"
  5515. } else {
  5516. struct3505.MdtrtSetlType = "2"
  5517. }
  5518. struct3505.OrgName = miConfig.OrgName
  5519. struct3505.AccessKey = miConfig.AccessKey
  5520. struct3505.RequestUrl = miConfig.Url
  5521. struct3505.SecretKey = miConfig.SecretKey
  5522. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5523. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5524. struct3505.Cainfo = miConfig.Cainfo
  5525. struct3505.DrugTracCodg = drug.DrugCode
  5526. if miConfig.MdtrtareaAdmvs == "350500" {
  5527. result1, result2, _ := service.FJyb3505(struct3505)
  5528. return result1, result2
  5529. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5530. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5531. return result1, result2
  5532. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5533. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5534. return result1, result2
  5535. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5536. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5537. return result1, result2
  5538. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5539. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5540. return result1, result2
  5541. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5542. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5543. return result1, result2
  5544. } else if miConfig.MdtrtareaAdmvs == "150404" {
  5545. data := make(map[string]interface{})
  5546. data["struct_3505s"] = struct3505
  5547. client := &http.Client{}
  5548. bytesData, _ := json.Marshal(data)
  5549. var req *http.Request
  5550. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5551. resp, _ := client.Do(req)
  5552. defer resp.Body.Close()
  5553. body, ioErr := ioutil.ReadAll(resp.Body)
  5554. if ioErr != nil {
  5555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5556. }
  5557. var respJSON map[string]interface{}
  5558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5560. }
  5561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5562. result, _ := json.Marshal(respJSON)
  5563. return string(result), ""
  5564. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5565. data := make(map[string]interface{})
  5566. data["struct_3505s"] = struct3505
  5567. client := &http.Client{}
  5568. bytesData, _ := json.Marshal(data)
  5569. var req *http.Request
  5570. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5571. resp, _ := client.Do(req)
  5572. defer resp.Body.Close()
  5573. body, ioErr := ioutil.ReadAll(resp.Body)
  5574. if ioErr != nil {
  5575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5576. }
  5577. var respJSON map[string]interface{}
  5578. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5580. }
  5581. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5582. if status == "0" {
  5583. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5584. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5585. }
  5586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5587. result, _ := json.Marshal(respJSON)
  5588. return string(result), ""
  5589. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5590. result1, result2 := service.Hnyb3505(struct3505)
  5591. return result1, result2
  5592. } else {
  5593. data := make(map[string]interface{})
  5594. data["struct_3505s"] = struct3505
  5595. client := &http.Client{}
  5596. bytesData, _ := json.Marshal(data)
  5597. var req *http.Request
  5598. if miConfig.MdtrtareaAdmvs == "320830" {
  5599. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5600. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5601. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5602. } else {
  5603. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5604. }
  5605. resp, _ := client.Do(req)
  5606. defer resp.Body.Close()
  5607. body, ioErr := ioutil.ReadAll(resp.Body)
  5608. if ioErr != nil {
  5609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5610. }
  5611. var respJSON map[string]interface{}
  5612. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5614. }
  5615. //var resSix10265 ResultSix10265 //1101结果
  5616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5617. result, _ := json.Marshal(respJSON)
  5618. return string(result), ""
  5619. }
  5620. }
  5621. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5622. var struct3505 models.Struct3505
  5623. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5624. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5625. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5626. struct3505.FixmedinsBchno = number
  5627. struct3505.Opter = role.UserName
  5628. struct3505.FixmedinsCode = miConfig.Code
  5629. struct3505.Code = miConfig.Code
  5630. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5631. struct3505.PrscDrName = roles.UserName
  5632. if org_id == 10191 {
  5633. struct3505.PharName = "刘水山"
  5634. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5635. }
  5636. if org_id == 10188 {
  5637. struct3505.PharName = "李汉清"
  5638. struct3505.PharPracCertNo = "30220200932022010034"
  5639. }
  5640. if org_id == 10217 {
  5641. struct3505.PharName = "张敏"
  5642. struct3505.PharPracCertNo = "30220230432090100108"
  5643. }
  5644. if org_id == 10318 {
  5645. struct3505.PharName = "邹刘阳"
  5646. struct3505.PharPracCertNo = "210441200001378"
  5647. }
  5648. if org_id == 10402 {
  5649. struct3505.PharName = "刘韶健"
  5650. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5651. }
  5652. if org_id == 9919 {
  5653. struct3505.PharName = "周君权"
  5654. struct3505.PharPracCertNo = "089644396094401375"
  5655. }
  5656. if org_id == 10644 {
  5657. struct3505.PharName = "陈金娣"
  5658. struct3505.PharPracCertNo = "20181441500320100066"
  5659. }
  5660. if org_id == 10567 {
  5661. struct3505.PharName = "范小兰"
  5662. struct3505.PharPracCertNo = "0200102079485"
  5663. }
  5664. if org_id == 10721 {
  5665. struct3505.PharName = "孙莉侠"
  5666. struct3505.PharPracCertNo = "060399"
  5667. }
  5668. if org_id == 10726 {
  5669. struct3505.PharName = "彭建福"
  5670. struct3505.PharPracCertNo = "D445281006261"
  5671. }
  5672. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5673. struct3505.SetlId = order.SetlId
  5674. struct3505.MdtrtSn = order.MdtrtId
  5675. struct3505.ManuLotnum = drug.Number
  5676. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5677. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5678. struct3505.RxFlag = "1"
  5679. struct3505.TrdnFlag = "0"
  5680. struct3505.RtalDocno = order.Number
  5681. struct3505.PsnCertType = "01"
  5682. struct3505.CertNo = order.Certno
  5683. struct3505.PsnNo = order.PsnNo
  5684. struct3505.PsnName = order.PsnName
  5685. struct3505.Url = miConfig.Url
  5686. struct3505.AppId = miConfig.Cainfo
  5687. struct3505.AppSecret = miConfig.AppSecret
  5688. struct3505.Enckey = miConfig.EncKey
  5689. struct3505.SignKey = miConfig.SignKey
  5690. struct3505.SecretKey = miConfig.SecretKey
  5691. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5692. struct3505.SelRetnCnt = strValue
  5693. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5694. struct3505.SelRetnOpterName = role.UserName
  5695. if order.IsMedicineInsurance == 1 {
  5696. struct3505.MdtrtSetlType = "1"
  5697. } else {
  5698. struct3505.MdtrtSetlType = "2"
  5699. }
  5700. struct3505.OrgName = miConfig.OrgName
  5701. struct3505.AccessKey = miConfig.AccessKey
  5702. struct3505.RequestUrl = miConfig.Url
  5703. struct3505.SecretKey = miConfig.SecretKey
  5704. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5705. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5706. struct3505.Cainfo = miConfig.Cainfo
  5707. struct3505.DrugTracCodg = drug.DrugCode
  5708. if miConfig.MdtrtareaAdmvs == "350500" {
  5709. result1, result2, _ := service.FJyb3505(struct3505)
  5710. return result1, result2
  5711. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5712. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5713. return result1, result2
  5714. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5715. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5716. return result1, result2
  5717. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5718. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5719. return result1, result2
  5720. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5721. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5722. return result1, result2
  5723. } else {
  5724. data := make(map[string]interface{})
  5725. data["struct_3505s"] = struct3505
  5726. client := &http.Client{}
  5727. bytesData, _ := json.Marshal(data)
  5728. var req *http.Request
  5729. if miConfig.MdtrtareaAdmvs == "320830" {
  5730. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5731. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5732. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5733. } else {
  5734. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5735. }
  5736. resp, _ := client.Do(req)
  5737. defer resp.Body.Close()
  5738. body, ioErr := ioutil.ReadAll(resp.Body)
  5739. if ioErr != nil {
  5740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5741. }
  5742. var respJSON map[string]interface{}
  5743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5745. }
  5746. //var resSix10265 ResultSix10265 //1101结果
  5747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5748. result, _ := json.Marshal(respJSON)
  5749. return string(result), ""
  5750. }
  5751. }
  5752. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, role models.UserAdminRole, number string, doc *models.HisDoctorAdviceInfo) (string, string) {
  5753. var struct3506 models.Struct3506
  5754. struct3506.MedListCodg = doc.BaseDrugLib.MedicalInsuranceNumber
  5755. struct3506.FixmedinsHilistId = doc.BaseDrugLib.MedicalInsuranceNumber
  5756. struct3506.FixmedinsHilistName = doc.BaseDrugLib.DrugName
  5757. struct3506.FixmedinsCode = miConfig.Code
  5758. struct3506.Code = miConfig.Code
  5759. struct3506.FixmedinsBchno = number
  5760. struct3506.Opter = role.UserName
  5761. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5762. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5763. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5764. struct3506.MdtrtSn = order.MdtrtId
  5765. struct3506.ExpyEnd = ""
  5766. struct3506.RxFlag = "0"
  5767. if doc.PrescribingNumberUnit != doc.BaseDrugLib.MinUnit {
  5768. struct3506.TrdnFlag = "0"
  5769. } else {
  5770. struct3506.TrdnFlag = "1"
  5771. }
  5772. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 || org_id == 9478 {
  5773. if doc.BaseDrugLib.IsZeroFlag == 1 {
  5774. struct3506.TrdnFlag = "1"
  5775. }
  5776. if doc.BaseDrugLib.IsZeroFlag == 2 {
  5777. struct3506.TrdnFlag = "0"
  5778. }
  5779. }
  5780. struct3506.TrdnFlag = "1"
  5781. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5782. struct3506.SelRetnCnt = strValue
  5783. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5784. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5785. struct3506.SelRetnOpterName = role.UserName
  5786. struct3506.OrgName = miConfig.OrgName
  5787. struct3506.AccessKey = miConfig.AccessKey
  5788. struct3506.RequestUrl = miConfig.Url
  5789. struct3506.SecretKey = miConfig.SecretKey
  5790. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5791. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5792. struct3506.Url = miConfig.Url
  5793. struct3506.AppId = miConfig.Cainfo
  5794. struct3506.AppSecret = miConfig.AppSecret
  5795. struct3506.Enckey = miConfig.EncKey
  5796. struct3506.SignKey = miConfig.SignKey
  5797. struct3506.SecretKey = miConfig.SecretKey
  5798. struct3506.DrugTracCodg = drug.DrugCode
  5799. if miConfig.MdtrtareaAdmvs == "350500" {
  5800. result1, result2, _ := service.FJyb3506(struct3506)
  5801. return result1, result2
  5802. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5803. result1, result2 := service.Gzyb3506(struct3506, struct3506.SecretKey)
  5804. return result1, result2
  5805. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5806. result1, result2 := service.Gdyb3506(struct3506, struct3506.SecretKey)
  5807. return result1, result2
  5808. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5809. result1, result2 := service.JXyb3506(struct3506, struct3506.SecretKey, struct3506.AccessKey, struct3506.RequestUrl)
  5810. return result1, result2
  5811. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5812. result1, result2 := service.JXyb3506(struct3506, struct3506.SecretKey, struct3506.AccessKey, struct3506.RequestUrl)
  5813. return result1, result2
  5814. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5815. result1, result2 := service.AHyb3506(struct3506, struct3506.SecretKey, struct3506.RequestUrl)
  5816. return result1, result2
  5817. } else if miConfig.MdtrtareaAdmvs == "150404" {
  5818. data := make(map[string]interface{})
  5819. data["struct_3506s"] = struct3506
  5820. client := &http.Client{}
  5821. bytesData, _ := json.Marshal(data)
  5822. var req *http.Request
  5823. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3506", bytes.NewReader(bytesData))
  5824. resp, _ := client.Do(req)
  5825. defer resp.Body.Close()
  5826. body, ioErr := ioutil.ReadAll(resp.Body)
  5827. if ioErr != nil {
  5828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5829. }
  5830. var respJSON map[string]interface{}
  5831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5833. }
  5834. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5835. result, _ := json.Marshal(respJSON)
  5836. return string(result), ""
  5837. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5838. data := make(map[string]interface{})
  5839. data["struct_3506s"] = struct3506
  5840. client := &http.Client{}
  5841. bytesData, _ := json.Marshal(data)
  5842. var req *http.Request
  5843. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3506", bytes.NewReader(bytesData))
  5844. resp, _ := client.Do(req)
  5845. defer resp.Body.Close()
  5846. body, ioErr := ioutil.ReadAll(resp.Body)
  5847. if ioErr != nil {
  5848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5849. }
  5850. var respJSON map[string]interface{}
  5851. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5853. }
  5854. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5855. if status == "0" {
  5856. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5857. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5858. }
  5859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5860. result, _ := json.Marshal(respJSON)
  5861. return string(result), ""
  5862. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5863. result1, result2 := service.Hnyb3506(struct3506)
  5864. return result1, result2
  5865. } else {
  5866. data := make(map[string]interface{})
  5867. data["struct_3506s"] = struct3506
  5868. client := &http.Client{}
  5869. bytesData, _ := json.Marshal(data)
  5870. var req *http.Request
  5871. if miConfig.MdtrtareaAdmvs == "320830" {
  5872. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5873. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5874. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5875. } else {
  5876. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5877. }
  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. }
  5884. var respJSON map[string]interface{}
  5885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5887. }
  5888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5889. result, _ := json.Marshal(respJSON)
  5890. return string(result), ""
  5891. }
  5892. }
  5893. func (c *HisApiController) Get1318() {
  5894. adminUser := c.GetAdminUserInfo()
  5895. admin_user_id, _ := c.GetInt64("admin_user_id")
  5896. code := c.GetString("code")
  5897. code = ""
  5898. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5899. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5900. api := ""
  5901. if miConfig.MdtrtareaAdmvs == "320830" {
  5902. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5903. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5904. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5905. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5906. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5907. } else {
  5908. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5909. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5910. }
  5911. resp, requestErr := http.Get(api)
  5912. if requestErr != nil {
  5913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5914. return
  5915. }
  5916. body, ioErr := ioutil.ReadAll(resp.Body)
  5917. if ioErr != nil {
  5918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5920. return
  5921. }
  5922. var respJSON map[string]interface{}
  5923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5926. return
  5927. }
  5928. //var res Result2406
  5929. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5930. result, _ := json.Marshal(respJSON)
  5931. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5932. utils.ErrorLog("解析失败:%v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. if res.Infcode == "0" {
  5937. c.ServeSuccessJSON(map[string]interface{}{
  5938. "result": "",
  5939. })
  5940. } else {
  5941. c.ServeSuccessJSON(map[string]interface{}{
  5942. "failed_code": -10,
  5943. "msg": res.ErrMsg,
  5944. })
  5945. */return
  5946. //}
  5947. }
  5948. func (c *HisApiController) Get2503() {
  5949. adminUser := c.GetAdminUserInfo()
  5950. admin_user_id, _ := c.GetInt64("admin_user_id")
  5951. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5952. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5953. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5954. }
  5955. func (c *HisApiController) Get2406() {
  5956. id, _ := c.GetInt64("id")
  5957. record_time := c.GetString("record_time")
  5958. his_patient_id, _ := c.GetInt64("his_patient_id")
  5959. admin_user_id, _ := c.GetInt64("admin_user_id")
  5960. diagnosis_id := c.GetString("diagnosis")
  5961. timeLayout := "2006-01-02"
  5962. loc, _ := time.LoadLocation("Local")
  5963. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5964. if err != nil {
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5966. return
  5967. }
  5968. recordDateTime := theTime.Unix()
  5969. adminUser := c.GetAdminUserInfo()
  5970. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5971. var config []*models.HisXtDiagnoseConfig
  5972. for _, item := range diagnosis_ids {
  5973. id, _ := strconv.ParseInt(item, 10, 64)
  5974. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5975. config = append(config, &diagnosisConfig)
  5976. }
  5977. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5978. fmt.Println(his_patient_id)
  5979. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5980. //timestamp := time.Now().Unix()
  5981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5982. var patientPrescription models.HisPrescriptionInfo
  5983. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5984. if patientPrescription.ID == 0 {
  5985. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5986. }
  5987. var res2 Result2406
  5988. if miConfig.MdtrtareaAdmvs == "341203" {
  5989. data := make(map[string]interface{})
  5990. client := &http.Client{}
  5991. data["psn_no"] = his.PsnNo
  5992. data["mdtrt_id"] = his.Number
  5993. data["operator"] = roles.UserName
  5994. data["cert_no"] = his.IdCardNo
  5995. data["org_name"] = miConfig.OrgName
  5996. data["psn_name"] = his.Name
  5997. data["ipt_otp_no"] = his.IptOtpNo
  5998. data["ipt_psn_sp_flag_type"] = "0901"
  5999. data["ipt_psn_sp_flag"] = "1"
  6000. data["fixmedins_code"] = miConfig.Code
  6001. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6002. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6003. data["url"] = miConfig.Url
  6004. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6005. bytesData, _ := json.Marshal(data)
  6006. var req *http.Request
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6008. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6009. resp, _ := client.Do(req)
  6010. defer resp.Body.Close()
  6011. body, ioErr := ioutil.ReadAll(resp.Body)
  6012. if ioErr != nil {
  6013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. return
  6016. }
  6017. var respJSON map[string]interface{}
  6018. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6021. return
  6022. }
  6023. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6024. if status == "0" {
  6025. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6026. c.ServeSuccessJSON(map[string]interface{}{
  6027. "failed_code": -10,
  6028. "msg": err_msg,
  6029. })
  6030. return
  6031. }
  6032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6033. userJSONBytes, _ := json.Marshal(respJSON)
  6034. fmt.Println("log")
  6035. fmt.Println(string(userJSONBytes))
  6036. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6037. utils.ErrorLog("解析失败:%v", err)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. return
  6040. }
  6041. } else if miConfig.MdtrtareaAdmvs == "340699" {
  6042. data := make(map[string]interface{})
  6043. client := &http.Client{}
  6044. data["psn_no"] = his.PsnNo
  6045. data["mdtrt_id"] = his.Number
  6046. data["operator"] = roles.UserName
  6047. data["cert_no"] = his.IdCardNo
  6048. data["org_name"] = miConfig.OrgName
  6049. data["psn_name"] = his.Name
  6050. data["ipt_otp_no"] = his.IptOtpNo
  6051. data["ipt_psn_sp_flag_type"] = "0901"
  6052. data["ipt_psn_sp_flag"] = "1"
  6053. data["fixmedins_code"] = miConfig.Code
  6054. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6055. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6056. data["url"] = miConfig.Url
  6057. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6058. bytesData, _ := json.Marshal(data)
  6059. var req *http.Request
  6060. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6061. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6062. resp, _ := client.Do(req)
  6063. defer resp.Body.Close()
  6064. body, ioErr := ioutil.ReadAll(resp.Body)
  6065. if ioErr != nil {
  6066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6068. return
  6069. }
  6070. var respJSON map[string]interface{}
  6071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6074. return
  6075. }
  6076. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6077. if status == "0" {
  6078. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6079. c.ServeSuccessJSON(map[string]interface{}{
  6080. "failed_code": -10,
  6081. "msg": err_msg,
  6082. })
  6083. return
  6084. }
  6085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6086. userJSONBytes, _ := json.Marshal(respJSON)
  6087. fmt.Println("log")
  6088. fmt.Println(string(userJSONBytes))
  6089. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6090. utils.ErrorLog("解析失败:%v", err)
  6091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6092. return
  6093. }
  6094. }
  6095. if res2.Infcode != 0 {
  6096. adminUser := c.GetAdminUserInfo()
  6097. errlog := &models.HisOrderError{
  6098. UserOrgId: adminUser.CurrentOrgId,
  6099. Ctime: time.Now().Unix(),
  6100. Mtime: time.Now().Unix(),
  6101. ErrMsg: res2.ErrMsg,
  6102. Status: 1,
  6103. PatientId: id,
  6104. RecordTime: recordDateTime,
  6105. Stage: 3,
  6106. }
  6107. service.CreateErrMsgLog(errlog)
  6108. c.ServeSuccessJSON(map[string]interface{}{
  6109. "failed_code": -10,
  6110. "msg": res2.ErrMsg,
  6111. })
  6112. return
  6113. } else {
  6114. c.ServeSuccessJSON(map[string]interface{}{
  6115. "msg": "上传成功",
  6116. })
  6117. return
  6118. }
  6119. }
  6120. func (c *HisApiController) Get4105() {
  6121. }
  6122. func (c *HisApiController) Post5302() {
  6123. patient_id, _ := c.GetInt64("id")
  6124. admin_user_id, _ := c.GetInt64("admin_user_id")
  6125. p, _ := service.GetHisPatientById(patient_id)
  6126. adminUser := c.GetAdminUserInfo()
  6127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6128. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6129. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6130. }
  6131. func (c *HisApiController) Get4104() {
  6132. }
  6133. type Output struct {
  6134. CertNo string `json:"certno"`
  6135. PsnName string `json:"psn_name"`
  6136. CardNo string `json:"card_no"`
  6137. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6138. CardSN string `json:"card_sn"`
  6139. PsnCertType string `json:"psn_cert_type"`
  6140. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6141. MdtrtCertType string `json:"mdtrt_cert_type"`
  6142. QRCode string `json:"qrCode"`
  6143. EcToken string `json:"ecToken"`
  6144. }
  6145. type AHResponse struct {
  6146. Body AHBody `json:"body"`
  6147. Code int `json:"code"`
  6148. CSBCode int `json:"csbCode"`
  6149. Message string `json:"message"`
  6150. RequestID string `json:"requestId"`
  6151. State struct{} `json:"state"`
  6152. }
  6153. type AHBody struct {
  6154. ErrMsg string `json:"err_msg"`
  6155. InfRefMsgID string `json:"inf_refmsgid"`
  6156. InfCode int `json:"infcode"`
  6157. Output struct {
  6158. Result []struct {
  6159. BasMednFlag string `json:"bas_medn_flag"`
  6160. ChldMedcFlag string `json:"chld_medc_flag"`
  6161. ChrgitmLv string `json:"chrgitm_lv"`
  6162. Cnt float64 `json:"cnt"`
  6163. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6164. DrtReimFlag string `json:"drt_reim_flag"`
  6165. FeedetlSn string `json:"feedetl_sn"`
  6166. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6167. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6168. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6169. ListSpItemFlag string `json:"list_sp_item_flag"`
  6170. LmtUsedFlag string `json:"lmt_used_flag"`
  6171. MedChrgitmType string `json:"med_chrgitm_type"`
  6172. Memo string `json:"memo"`
  6173. OverlmtAmt float64 `json:"overlmt_amt"`
  6174. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6175. Pric float64 `json:"pric"`
  6176. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6177. SelfpayProp float64 `json:"selfpay_prop"`
  6178. } `json:"result"`
  6179. } `json:"output"`
  6180. }
  6181. type Response struct {
  6182. Output Output `json:"output"`
  6183. Infcode int `json:"infcode"`
  6184. InfRefMsgID string `json:"inf_refmsgid"`
  6185. RefMsgTime string `json:"refmsg_time"`
  6186. RespondTime string `json:"respond_time"`
  6187. ErrMsg string `json:"err_msg"`
  6188. WarnMsg string `json:"warn_msg"`
  6189. SignType string `json:"signtype"`
  6190. CAInfo string `json:"cainfo"`
  6191. }
  6192. func (c *HisApiController) Getquerydata() {
  6193. query_type, _ := c.GetInt64("type")
  6194. refd_setl_flag := c.GetString("refd_setl_flag")
  6195. med_type := c.GetString("med_type")
  6196. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6197. cert_no := c.GetString("cert_no")
  6198. psn_no := c.GetString("psn_no")
  6199. start_time := c.GetString("start_time")
  6200. end_time := c.GetString("end_time")
  6201. page, _ := c.GetInt64("page")
  6202. limit, _ := c.GetInt64("limit")
  6203. var bp models.BusinessParams5262
  6204. bp.RefdSetlFlag = refd_setl_flag
  6205. bp.MedType = med_type
  6206. bp.Certno = cert_no
  6207. bp.Psnno = psn_no
  6208. bp.QBegntime = start_time
  6209. bp.QEndtime = end_time
  6210. if query_type == 1 { //本地
  6211. Post5262(c, bp, page, limit)
  6212. } else { //异地
  6213. Post5267(c, bp, page, limit)
  6214. }
  6215. }
  6216. func (c *HisApiController) Drugscheck() {
  6217. admin_user_id, _ := c.GetInt64("admin_user_id")
  6218. adminUser := c.GetAdminUserInfo()
  6219. var queryResult []QueryResult
  6220. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6221. for _, item := range drugs {
  6222. result := QueryResult{
  6223. ID: item.ID,
  6224. Name: item.DrugName,
  6225. Code: item.MedicalInsuranceNumber,
  6226. List_type_code: "101",
  6227. }
  6228. queryResult = append(queryResult, result)
  6229. }
  6230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6231. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6232. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6233. for _, item := range queryResult {
  6234. 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)
  6235. }
  6236. }
  6237. func (c *HisApiController) Goodcheck() {
  6238. admin_user_id, _ := c.GetInt64("admin_user_id")
  6239. adminUser := c.GetAdminUserInfo()
  6240. var queryResult []QueryResult
  6241. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6242. for _, item := range goods {
  6243. result := QueryResult{
  6244. ID: item.ID,
  6245. Name: item.GoodName,
  6246. Code: item.SocialSecurityDirectoryCode,
  6247. List_type_code: "301",
  6248. }
  6249. queryResult = append(queryResult, result)
  6250. }
  6251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6252. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6253. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6254. for _, item := range queryResult {
  6255. 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)
  6256. //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)
  6257. }
  6258. }
  6259. func (c *HisApiController) Projectcheck() {
  6260. admin_user_id, _ := c.GetInt64("admin_user_id")
  6261. adminUser := c.GetAdminUserInfo()
  6262. var queryResult []QueryResult
  6263. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6264. for _, item := range projects {
  6265. result := QueryResult{
  6266. ID: item.ID,
  6267. Name: item.ProjectName,
  6268. Code: item.MedicalCode,
  6269. List_type_code: "201",
  6270. }
  6271. queryResult = append(queryResult, result)
  6272. }
  6273. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6274. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6275. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6276. for _, item := range queryResult {
  6277. 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)
  6278. }
  6279. }
  6280. //func (c *HisApiController)CancleDia(){
  6281. //
  6282. // id, _ := c.GetInt64("id")
  6283. // record_time := c.GetString("record_time")
  6284. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6285. //
  6286. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6287. //
  6288. // diagnosis_id := c.GetString("diagnosis")
  6289. // sick_type, _ := c.GetInt64("sick_type")
  6290. // reg_type, _ := c.GetInt64("p_type")
  6291. // begin_time := c.GetString("begin_time")
  6292. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6293. //
  6294. //
  6295. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6296. //
  6297. // fmt.Println(acct_used_flag)
  6298. //
  6299. //
  6300. // timeLayout := "2006-01-02"
  6301. // loc, _ := time.LoadLocation("Local")
  6302. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6303. // if err != nil {
  6304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6305. // return
  6306. // }
  6307. // recordDateTime := theTime.Unix()
  6308. // adminUser := c.GetAdminUserInfo()
  6309. //
  6310. //
  6311. //
  6312. //
  6313. //
  6314. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6315. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6316. // var patientPrescription models.HisPrescriptionInfo
  6317. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6318. // if patientPrescription.ID == 0 {
  6319. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6320. // }
  6321. // //if patientPrescription.Do
  6322. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6323. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6324. //
  6325. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6326. //
  6327. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6328. //
  6329. // var config []*models.HisXtDiagnoseConfig
  6330. // for _, item := range diagnosis_ids {
  6331. // id, _ := strconv.ParseInt(item, 10, 64)
  6332. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6333. // config = append(config, &diagnosisConfig)
  6334. // }
  6335. //
  6336. // sickConfig, _ := service.FindSickById(sick_type)
  6337. //
  6338. //
  6339. // data := make(map[string]interface{})
  6340. // client := &http.Client{}
  6341. // data["psn_no"] = his.PsnNo
  6342. // data["mdtrt_id"] = his.Number
  6343. // data["doctor"] = roles.UserName
  6344. // data["department"] = department.Name
  6345. // data["org_name"] = miConfig.OrgName
  6346. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6347. // data["doctor_id"] = doctor_info.DoctorNumber
  6348. // data["new_doctor_name"] = doctor_info.UserName
  6349. // data["fixmedins_code"] = miConfig.Code
  6350. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6351. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6352. // data["secret_key"] = miConfig.SecretKey
  6353. // data["sick_code"] = sickConfig.CountryCode
  6354. // data["sick_name"] = sickConfig.ClassName
  6355. // data["url"] = miConfig.Url
  6356. // data["ak"] = miConfig.AccessKey
  6357. // data["begin_time"] = begin_time
  6358. // data["cainfo"] = miConfig.Cainfo
  6359. // data["is_vaild"] = "0"
  6360. //
  6361. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6362. // data["config"] = config
  6363. // bytesData, _ := json.Marshal(data)
  6364. //
  6365. // var req *http.Request
  6366. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6367. // resp, _ := client.Do(req)
  6368. // defer resp.Body.Close()
  6369. // body, ioErr := ioutil.ReadAll(resp.Body)
  6370. // if ioErr != nil {
  6371. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6373. // return
  6374. // }
  6375. // var respJSON map[string]interface{}
  6376. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. // return
  6380. // }
  6381. //
  6382. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6383. // userJSONBytes, _ := json.Marshal(respJSON)
  6384. // fmt.Println("log")
  6385. // fmt.Println(string(userJSONBytes))
  6386. //
  6387. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6388. // utils.ErrorLog("解析失败:%v", err)
  6389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6390. // return
  6391. // }
  6392. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6393. // res2.Output = ressix10265.Output
  6394. // res2.ErrMsg = ressix10265.ErrMsg
  6395. // res2.Cainfo = ressix10265.Cainfo
  6396. // res2.WarnMsg = ressix10265.WarnMsg
  6397. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6398. // res2.Infcode = infocode
  6399. //
  6400. //}
  6401. func (c *HisApiController) Get4102() {
  6402. order_id, _ := c.GetInt64("order_id")
  6403. admin_user_id, _ := c.GetInt64("admin_user_id")
  6404. stas_type := c.GetString("stas_type")
  6405. order, _ := service.GetHisOrderByIDTwo(order_id)
  6406. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6407. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6408. var pp models.PublicParams
  6409. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6410. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6411. pp.FixmedinsName = miConfig.OrgName
  6412. pp.FixmedinsCode = miConfig.Code
  6413. pp.RequestUrl = miConfig.Url
  6414. pp.Cainfo = miConfig.Cainfo
  6415. pp.SecretKey = miConfig.SecretKey
  6416. pp.AccessKey = miConfig.AccessKey
  6417. pp.OpterName = curRoles.UserName
  6418. if miConfig.MdtrtareaAdmvs == "350500" {
  6419. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6420. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6421. saveLog(result, request, "4102", "清单确认")
  6422. var dat map[string]interface{}
  6423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6424. fmt.Println(dat)
  6425. } else {
  6426. fmt.Println(err)
  6427. }
  6428. var empty ResultFourteen
  6429. userJSONBytes, _ := json.Marshal(dat)
  6430. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6431. utils.ErrorLog("解析失败:%v", err)
  6432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6433. return
  6434. }
  6435. if empty.Infcode == 0 {
  6436. c.ServeSuccessJSON(map[string]interface{}{
  6437. "msg": "确认成功",
  6438. })
  6439. return
  6440. }
  6441. } else {
  6442. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6443. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6444. result3, request3 := service.Jxyb4105(pp)
  6445. saveLog(result, request, "4102", "清单确认")
  6446. saveLog(result2, request2, "4103", "清单确认")
  6447. saveLog(result3, request3, "4105", "清单统计")
  6448. var dat map[string]interface{}
  6449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6450. fmt.Println(dat)
  6451. } else {
  6452. fmt.Println(err)
  6453. }
  6454. var empty ResultFourteen
  6455. userJSONBytes, _ := json.Marshal(dat)
  6456. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6457. utils.ErrorLog("解析失败:%v", err)
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6459. return
  6460. }
  6461. if empty.Infcode == 0 {
  6462. c.ServeSuccessJSON(map[string]interface{}{
  6463. "msg": "确认成功",
  6464. })
  6465. return
  6466. }
  6467. }
  6468. }
  6469. // 对账权限查询
  6470. func (c *HisApiController) Get3260() {
  6471. admin_user_id, _ := c.GetInt64("admin_user_id")
  6472. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6473. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6474. var api string
  6475. var res models.JSResult3260
  6476. if miConfig.MdtrtareaAdmvs == "320830" {
  6477. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6478. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6479. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6480. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6481. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6482. } else {
  6483. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6484. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6485. }
  6486. resp, requestErr := http.Get(api)
  6487. if requestErr != nil {
  6488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6489. return
  6490. }
  6491. body, ioErr := ioutil.ReadAll(resp.Body)
  6492. if ioErr != nil {
  6493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. return
  6496. }
  6497. var respJSON map[string]interface{}
  6498. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6501. return
  6502. }
  6503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6504. result, _ := json.Marshal(respJSON)
  6505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6506. utils.ErrorLog("解析失败:%v", err)
  6507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6508. return
  6509. }
  6510. if res.Infcode == "0" {
  6511. c.ServeSuccessJSON(map[string]interface{}{
  6512. "result": res.Output.Data,
  6513. })
  6514. } else {
  6515. c.ServeSuccessJSON(map[string]interface{}{
  6516. "failed_code": -10,
  6517. "msg": res.ErrMsg,
  6518. })
  6519. return
  6520. }
  6521. }
  6522. func (c *HisApiController) Get3261() {
  6523. admin_user_id, _ := c.GetInt64("admin_user_id")
  6524. //month := c.GetString("month")
  6525. startTime := c.GetString("start_time")
  6526. //endTime, _ := c.GetString("end_time")
  6527. times := strings.Split(startTime, "-")
  6528. stmt_mon := times[0] + times[1]
  6529. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6531. var api string
  6532. var res models.JSResult3261
  6533. //var res10265 Result5301For10265
  6534. if miConfig.MdtrtareaAdmvs == "320830" {
  6535. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6536. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6537. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6538. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6539. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6540. } else {
  6541. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6542. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6543. }
  6544. resp, requestErr := http.Get(api)
  6545. if requestErr != nil {
  6546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6547. return
  6548. }
  6549. body, ioErr := ioutil.ReadAll(resp.Body)
  6550. if ioErr != nil {
  6551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. return
  6554. }
  6555. var respJSON map[string]interface{}
  6556. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6559. return
  6560. }
  6561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6562. result, _ := json.Marshal(respJSON)
  6563. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6564. utils.ErrorLog("解析失败:%v", err)
  6565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6566. return
  6567. }
  6568. if res.Infcode == "0" {
  6569. c.ServeSuccessJSON(map[string]interface{}{
  6570. "result": res.Output,
  6571. })
  6572. } else {
  6573. c.ServeSuccessJSON(map[string]interface{}{
  6574. "failed_code": -10,
  6575. "msg": res.ErrMsg,
  6576. })
  6577. return
  6578. }
  6579. }
  6580. type TempFun struct {
  6581. FundKey string
  6582. FundCode string
  6583. }
  6584. func (c *HisApiController) Get3262() {
  6585. admin_user_id, _ := c.GetInt64("admin_user_id")
  6586. startTime := c.GetString("start_time")
  6587. endTime := c.GetString("end_time")
  6588. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6589. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6590. //timeLayout := "2006-01-02"
  6591. //loc, _ := time.LoadLocation("Local")
  6592. //var theStartTIme int64
  6593. //if len(startTime) > 0 {
  6594. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6595. // if err != nil {
  6596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6597. // return
  6598. // }
  6599. // theStartTIme = theTime.Unix()
  6600. //}
  6601. //var theEndtTIme int64
  6602. //if len(endTime) > 0 {
  6603. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6604. // if err != nil {
  6605. // utils.ErrorLog(err.Error())
  6606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6607. // return
  6608. // }
  6609. // theEndtTIme = theTime.Unix()
  6610. //}
  6611. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6612. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6613. for _, team := range datas {
  6614. fmt.Println(team.PsnTime)
  6615. for _, team_two := range datas_two {
  6616. fmt.Println(team_two.PsnTime)
  6617. if team.FundKey == team_two.FundKey {
  6618. fmt.Println(team_two.PsnTime)
  6619. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6620. fmt.Println(team.PsnTime)
  6621. }
  6622. }
  6623. }
  6624. fmt.Println("1111")
  6625. fmt.Println(datas)
  6626. fmt.Println("1111")
  6627. var twos []models.FixMonRecDetailFileInTwo
  6628. for _, team := range datas {
  6629. var two models.FixMonRecDetailFileInTwo
  6630. two.MedType = team.MedType
  6631. two.Insutype = team.Insutype
  6632. two.PsnType = team.PsnType
  6633. two.MedType = team.MedType
  6634. two.FixBlngAdmdvs = "999999"
  6635. two.InsuAdmdvs = "555555"
  6636. two.PsnTime = team.PsnTime
  6637. two.PsnCnt = team.PsnCnt
  6638. two.FundKey = team.FundKey
  6639. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6640. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6641. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6642. two.MedfeeSumAmt = ms
  6643. two.InscpAmt = ia
  6644. two.FundPaySumAmt = fps
  6645. twos = append(twos, two)
  6646. }
  6647. //startTime := c.GetString("start_time")
  6648. //endTime, _ := c.GetString("end_time")
  6649. times := strings.Split(startTime, "-")
  6650. stmt_mon := times[0] + times[1]
  6651. var funs []models.FundDetail
  6652. for _, item := range datas {
  6653. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6654. funs = append(funs, fun...)
  6655. }
  6656. var funInfos []models.Fund
  6657. //for _, item := range funs {
  6658. // var rf []models.FundInfo
  6659. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6660. // for _, subitem := range rf {
  6661. // var fund models.Fund
  6662. // fund.FundCode = subitem.FundPayType
  6663. // fund.FundName = subitem.FundPayTypeName
  6664. // fund.FundAmt = subitem.FundPayAmt
  6665. // fund.FundKey = item.FundKey
  6666. // fund.InsuAdmdvs = "555555"
  6667. // fund.FixBlngAdmdvs = "999999"
  6668. // funInfos = append(funInfos, fund)
  6669. // }
  6670. //}
  6671. var tempFuns []TempFun
  6672. for _, funInfo := range funInfos {
  6673. var tempFun TempFun
  6674. tempFun.FundKey = funInfo.FundKey
  6675. tempFun.FundCode = funInfo.FundCode
  6676. tempFuns = append(tempFuns, tempFun)
  6677. }
  6678. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6679. fmt.Println(tempFuns)
  6680. var funInfosTwo []models.Fund
  6681. decimal.DivisionPrecision = 2
  6682. for _, item := range tempFuns {
  6683. var fund models.Fund
  6684. for _, subItem := range funInfos {
  6685. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6686. fund.FundKey = subItem.FundKey
  6687. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6688. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6689. fund.FundName = subItem.FundName
  6690. fund.FundCode = subItem.FundCode
  6691. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6692. }
  6693. }
  6694. funInfosTwo = append(funInfosTwo, fund)
  6695. }
  6696. fmt.Println("funInfosTwo")
  6697. fmt.Println(funInfosTwo)
  6698. var upld_btch string
  6699. var empty models.JSResultEmpty
  6700. data := make(map[string]interface{})
  6701. data["org_name"] = miConfig.OrgName
  6702. data["doctor"] = curRoles.UserName
  6703. data["doctor_name"] = curRoles.UserName
  6704. data["fixmedins_code"] = miConfig.Code
  6705. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6706. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6707. data["secret_key"] = miConfig.SecretKey
  6708. data["url"] = miConfig.Url
  6709. data["ak"] = miConfig.AccessKey
  6710. data["cainfo"] = miConfig.Cainfo
  6711. data["datas"] = twos
  6712. data["fund"] = funInfosTwo
  6713. fmt.Println(twos)
  6714. month := time.Unix(1557042972, 0).Format("1")
  6715. year := time.Now().Format("2006")
  6716. month = time.Now().Format("01")
  6717. day := time.Now().Format("02")
  6718. hour := time.Now().Format("15")
  6719. min := time.Now().Format("04")
  6720. sec := time.Now().Format("05")
  6721. fix_fill_date := year + month + day + hour + min + sec
  6722. data["fix_fill_dept"] = miConfig.OrgName
  6723. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6724. data["fix_fill_psn"] = curRoles.UserName
  6725. data["fix_fill_date"] = fix_fill_date
  6726. data["stmt_loc"] = "2"
  6727. data["setl_mon"] = stmt_mon
  6728. upld_btch = "0"
  6729. data["upld_btch"] = upld_btch
  6730. //fmt.Println(data)
  6731. client := &http.Client{}
  6732. bytesData, _ := json.Marshal(data)
  6733. var req *http.Request
  6734. if miConfig.MdtrtareaAdmvs == "320830" {
  6735. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6736. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6737. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6738. } else {
  6739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6740. }
  6741. resp, _ := client.Do(req)
  6742. defer resp.Body.Close()
  6743. body, ioErr := ioutil.ReadAll(resp.Body)
  6744. if ioErr != nil {
  6745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6747. }
  6748. var respJSON map[string]interface{}
  6749. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. }
  6753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6754. //fmt.Println(respJSON)
  6755. result, _ := json.Marshal(respJSON)
  6756. //fmt.Println(result)
  6757. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6758. utils.ErrorLog("解析失败:%v", err)
  6759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6760. }
  6761. if empty.Infcode != "0" {
  6762. c.ServeSuccessJSON(map[string]interface{}{
  6763. "failed_code": -10,
  6764. "msg": empty.ErrMsg,
  6765. })
  6766. return
  6767. } else {
  6768. c.ServeSuccessJSON(map[string]interface{}{
  6769. "msg": "上传成功",
  6770. })
  6771. return
  6772. }
  6773. }
  6774. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6775. newArr = make([]TempFun, 0)
  6776. for i := 0; i < len(arr); i++ {
  6777. repeat := false
  6778. for j := i + 1; j < len(arr); j++ {
  6779. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6780. repeat = true
  6781. break
  6782. }
  6783. }
  6784. if !repeat {
  6785. newArr = append(newArr, arr[i])
  6786. }
  6787. }
  6788. return
  6789. }
  6790. func (c *HisApiController) Get3263() {
  6791. admin_user_id, _ := c.GetInt64("admin_user_id")
  6792. startTime := c.GetString("start_time")
  6793. //endTime, _ := c.GetString("end_time")
  6794. times := strings.Split(startTime, "-")
  6795. setl_mon := times[0] + times[1]
  6796. upld_btch := "0"
  6797. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6798. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6799. var result3263 models.JSResult3263
  6800. data := make(map[string]interface{})
  6801. data["org_name"] = miConfig.OrgName
  6802. data["doctor"] = curRoles.UserName
  6803. data["doctor_name"] = curRoles.UserName
  6804. data["fixmedins_code"] = miConfig.Code
  6805. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6806. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6807. data["secret_key"] = miConfig.SecretKey
  6808. data["url"] = miConfig.Url
  6809. data["ak"] = miConfig.AccessKey
  6810. data["cainfo"] = miConfig.Cainfo
  6811. data["setl_mon"] = setl_mon
  6812. data["stmt_loc"] = "2"
  6813. data["upld_btch"] = upld_btch
  6814. client := &http.Client{}
  6815. bytesData, _ := json.Marshal(data)
  6816. var req *http.Request
  6817. if miConfig.MdtrtareaAdmvs == "320830" {
  6818. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6819. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6821. } else {
  6822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6823. }
  6824. resp, _ := client.Do(req)
  6825. defer resp.Body.Close()
  6826. body, ioErr := ioutil.ReadAll(resp.Body)
  6827. if ioErr != nil {
  6828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. }
  6831. var respJSON map[string]interface{}
  6832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6835. }
  6836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6837. fmt.Println(respJSON)
  6838. result, _ := json.Marshal(respJSON)
  6839. fmt.Println(result)
  6840. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6841. utils.ErrorLog("解析失败:%v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. }
  6844. if result3263.Infcode != "0" {
  6845. c.ServeSuccessJSON(map[string]interface{}{
  6846. "failed_code": -10,
  6847. "msg": result3263.ErrMsg,
  6848. })
  6849. return
  6850. } else {
  6851. c.ServeSuccessJSON(map[string]interface{}{
  6852. "list": result3263.Output,
  6853. })
  6854. return
  6855. }
  6856. }
  6857. func (c *HisApiController) Get3264() {
  6858. admin_user_id, _ := c.GetInt64("admin_user_id")
  6859. startTime := c.GetString("start_time")
  6860. //endTime, _ := c.GetString("end_time")
  6861. times := strings.Split(startTime, "-")
  6862. setl_mon := times[0] + times[1]
  6863. upld_btch := "0"
  6864. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6865. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6866. //solidify_id := []
  6867. var result3263 models.JSResult3263
  6868. data := make(map[string]interface{})
  6869. data["org_name"] = miConfig.OrgName
  6870. data["doctor"] = curRoles.UserName
  6871. data["doctor_name"] = curRoles.UserName
  6872. data["fixmedins_code"] = miConfig.Code
  6873. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6874. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6875. data["secret_key"] = miConfig.SecretKey
  6876. data["url"] = miConfig.Url
  6877. data["ak"] = miConfig.AccessKey
  6878. data["cainfo"] = miConfig.Cainfo
  6879. data["setl_mon"] = setl_mon
  6880. data["stmt_loc"] = "2"
  6881. data["upld_btch"] = upld_btch
  6882. client := &http.Client{}
  6883. bytesData, _ := json.Marshal(data)
  6884. var req3263 *http.Request
  6885. if miConfig.MdtrtareaAdmvs == "320830" {
  6886. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6887. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6888. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6889. } else {
  6890. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6891. }
  6892. resp, _ := client.Do(req3263)
  6893. defer resp.Body.Close()
  6894. body, ioErr := ioutil.ReadAll(resp.Body)
  6895. if ioErr != nil {
  6896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. }
  6899. var respJSON3263 map[string]interface{}
  6900. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. }
  6904. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6905. fmt.Println(respJSON3263)
  6906. result, _ := json.Marshal(respJSON3263)
  6907. fmt.Println(result)
  6908. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6909. utils.ErrorLog("解析失败:%v", err)
  6910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6911. }
  6912. var ids []string
  6913. for _, item := range result3263.Output {
  6914. ids = append(ids, item.SolidifyID)
  6915. }
  6916. var empty models.JSResultEmpty
  6917. data2 := make(map[string]interface{})
  6918. data2["org_name"] = miConfig.OrgName
  6919. data2["doctor"] = curRoles.UserName
  6920. data2["doctor_name"] = curRoles.UserName
  6921. data2["fixmedins_code"] = miConfig.Code
  6922. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6923. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6924. data2["secret_key"] = miConfig.SecretKey
  6925. data2["url"] = miConfig.Url
  6926. data2["ak"] = miConfig.AccessKey
  6927. data2["cainfo"] = miConfig.Cainfo
  6928. data2["setl_mon"] = setl_mon
  6929. data2["stmt_loc"] = "2"
  6930. data2["upld_btch"] = upld_btch
  6931. data2["solidify_id"] = ids
  6932. client2 := &http.Client{}
  6933. bytesData2, _ := json.Marshal(data2)
  6934. var req *http.Request
  6935. if miConfig.MdtrtareaAdmvs == "320830" {
  6936. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6937. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6938. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6939. } else {
  6940. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6941. }
  6942. resp2, _ := client2.Do(req)
  6943. defer resp.Body.Close()
  6944. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6945. if ioErr2 != nil {
  6946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. }
  6949. var respJSON map[string]interface{}
  6950. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6953. }
  6954. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6955. fmt.Println(respJSON)
  6956. result2, _ := json.Marshal(respJSON)
  6957. fmt.Println(result2)
  6958. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6959. utils.ErrorLog("解析失败:%v", err)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. }
  6962. if empty.Infcode != "0" {
  6963. c.ServeSuccessJSON(map[string]interface{}{
  6964. "failed_code": -10,
  6965. "msg": empty.ErrMsg,
  6966. })
  6967. return
  6968. } else {
  6969. c.ServeSuccessJSON(map[string]interface{}{
  6970. "msg": "",
  6971. })
  6972. return
  6973. }
  6974. }
  6975. func (c *HisApiController) Get3265() {
  6976. admin_user_id, _ := c.GetInt64("admin_user_id")
  6977. startTime := c.GetString("start_time")
  6978. //endTime, _ := c.GetString("end_time")
  6979. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6980. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6981. times := strings.Split(startTime, "-")
  6982. setl_mon := times[0] + times[1]
  6983. var upld_btch string
  6984. upld_btch = "0"
  6985. //var empty models.JSResultEmpty
  6986. var result3265 models.JSResult3264
  6987. var result3263 models.JSResult3263
  6988. data2 := make(map[string]interface{})
  6989. data2["org_name"] = miConfig.OrgName
  6990. data2["doctor"] = curRoles.UserName
  6991. data2["doctor_name"] = curRoles.UserName
  6992. data2["fixmedins_code"] = miConfig.Code
  6993. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6994. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6995. data2["secret_key"] = miConfig.SecretKey
  6996. data2["url"] = miConfig.Url
  6997. data2["ak"] = miConfig.AccessKey
  6998. data2["cainfo"] = miConfig.Cainfo
  6999. data2["setl_mon"] = setl_mon
  7000. data2["stmt_loc"] = "2"
  7001. data2["upld_btch"] = upld_btch
  7002. client2 := &http.Client{}
  7003. bytesData2, _ := json.Marshal(data2)
  7004. var req3263 *http.Request
  7005. if miConfig.MdtrtareaAdmvs == "320830" {
  7006. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  7007. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7008. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7009. } else {
  7010. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7011. }
  7012. resp2, _ := client2.Do(req3263)
  7013. defer resp2.Body.Close()
  7014. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7015. if ioErr2 != nil {
  7016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. }
  7019. var respJSON3263 map[string]interface{}
  7020. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7023. }
  7024. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7025. fmt.Println(respJSON3263)
  7026. result2, _ := json.Marshal(respJSON3263)
  7027. fmt.Println(result2)
  7028. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7029. utils.ErrorLog("解析失败:%v", err)
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7031. }
  7032. var ids []string
  7033. for _, item := range result3263.Output {
  7034. ids = append(ids, item.SolidifyID)
  7035. }
  7036. data := make(map[string]interface{})
  7037. data["org_name"] = miConfig.OrgName
  7038. data["doctor"] = curRoles.UserName
  7039. data["doctor_name"] = curRoles.UserName
  7040. data["fixmedins_code"] = miConfig.Code
  7041. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7042. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7043. data["secret_key"] = miConfig.SecretKey
  7044. data["url"] = miConfig.Url
  7045. data["ak"] = miConfig.AccessKey
  7046. data["cainfo"] = miConfig.Cainfo
  7047. data["setl_mon"] = setl_mon
  7048. data["solidify_id"] = ids
  7049. month := time.Unix(1557042972, 0).Format("1")
  7050. year := time.Now().Format("2006")
  7051. month = time.Now().Format("01")
  7052. day := time.Now().Format("02")
  7053. hour := time.Now().Format("15")
  7054. min := time.Now().Format("04")
  7055. sec := time.Now().Format("05")
  7056. fix_fill_date := year + month + day + hour + min + sec
  7057. data["fix_fill_dept"] = miConfig.OrgName
  7058. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7059. data["fix_fill_psn"] = curRoles.UserName
  7060. data["fix_fill_date"] = fix_fill_date
  7061. data["stmt_loc"] = "2"
  7062. data["upld_btch"] = upld_btch
  7063. client := &http.Client{}
  7064. bytesData, _ := json.Marshal(data)
  7065. var req *http.Request
  7066. if miConfig.MdtrtareaAdmvs == "320830" {
  7067. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  7068. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7069. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7070. } else {
  7071. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7072. }
  7073. resp, _ := client.Do(req)
  7074. defer resp.Body.Close()
  7075. body, ioErr := ioutil.ReadAll(resp.Body)
  7076. if ioErr != nil {
  7077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7079. }
  7080. var respJSON map[string]interface{}
  7081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. }
  7085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7086. fmt.Println(respJSON)
  7087. result, _ := json.Marshal(respJSON)
  7088. fmt.Println(result)
  7089. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7090. utils.ErrorLog("解析失败:%v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. }
  7093. if result3265.Infcode != "0" {
  7094. c.ServeSuccessJSON(map[string]interface{}{
  7095. "failed_code": -10,
  7096. "msg": result3265.ErrMsg,
  7097. })
  7098. return
  7099. } else {
  7100. c.ServeSuccessJSON(map[string]interface{}{
  7101. "info": result3265.Output,
  7102. })
  7103. return
  7104. }
  7105. }
  7106. func (c *HisApiController) Get3266() {
  7107. admin_user_id, _ := c.GetInt64("admin_user_id")
  7108. startTime := c.GetString("start_time")
  7109. //endTime, _ := c.GetString("end_time")
  7110. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7112. times := strings.Split(startTime, "-")
  7113. stmt_mon := times[0] + times[1]
  7114. var upld_btch string
  7115. //var empty models.JSResultEmpty
  7116. var result3265 models.JSResult3264
  7117. data := make(map[string]interface{})
  7118. data["org_name"] = miConfig.OrgName
  7119. data["doctor"] = curRoles.UserName
  7120. data["doctor_name"] = curRoles.UserName
  7121. data["fixmedins_code"] = miConfig.Code
  7122. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7123. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7124. data["secret_key"] = miConfig.SecretKey
  7125. data["url"] = miConfig.Url
  7126. data["ak"] = miConfig.AccessKey
  7127. data["cainfo"] = miConfig.Cainfo
  7128. data["setl_mon"] = stmt_mon
  7129. month := time.Unix(1557042972, 0).Format("1")
  7130. year := time.Now().Format("2006")
  7131. month = time.Now().Format("01")
  7132. day := time.Now().Format("02")
  7133. hour := time.Now().Format("15")
  7134. min := time.Now().Format("04")
  7135. sec := time.Now().Format("05")
  7136. fix_fill_date := year + month + day + hour + min + sec
  7137. data["fix_fill_dept"] = miConfig.OrgName
  7138. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7139. data["fix_fill_psn"] = curRoles.UserName
  7140. data["fix_fill_date"] = fix_fill_date
  7141. data["stmt_loc"] = "2"
  7142. upld_btch = "0"
  7143. data["upld_btch"] = upld_btch
  7144. client := &http.Client{}
  7145. bytesData, _ := json.Marshal(data)
  7146. var req *http.Request
  7147. if miConfig.MdtrtareaAdmvs == "320830" {
  7148. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7149. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7150. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7151. } else {
  7152. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7153. }
  7154. resp, _ := client.Do(req)
  7155. defer resp.Body.Close()
  7156. body, ioErr := ioutil.ReadAll(resp.Body)
  7157. if ioErr != nil {
  7158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7160. }
  7161. var respJSON map[string]interface{}
  7162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. }
  7166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7167. fmt.Println(respJSON)
  7168. result, _ := json.Marshal(respJSON)
  7169. fmt.Println(result)
  7170. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7171. utils.ErrorLog("解析失败:%v", err)
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. }
  7174. if result3265.Infcode != "0" {
  7175. c.ServeSuccessJSON(map[string]interface{}{
  7176. "failed_code": -10,
  7177. "msg": result3265.ErrMsg,
  7178. })
  7179. return
  7180. } else {
  7181. c.ServeSuccessJSON(map[string]interface{}{
  7182. "info": result3265.Output,
  7183. })
  7184. return
  7185. }
  7186. }
  7187. func (c *HisApiController) Get3267() {
  7188. admin_user_id, _ := c.GetInt64("admin_user_id")
  7189. startTime := c.GetString("start_time")
  7190. //endTime, _ := c.GetString("end_time")
  7191. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7193. times := strings.Split(startTime, "-")
  7194. setl_mon := times[0] + times[1]
  7195. var upld_btch string
  7196. //var empty models.JSResultEmpty
  7197. var result3265 models.JSResult3264
  7198. upld_btch = "0"
  7199. data := make(map[string]interface{})
  7200. data["org_name"] = miConfig.OrgName
  7201. data["doctor"] = curRoles.UserName
  7202. data["doctor_name"] = curRoles.UserName
  7203. data["fixmedins_code"] = miConfig.Code
  7204. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7206. data["secret_key"] = miConfig.SecretKey
  7207. data["url"] = miConfig.Url
  7208. data["ak"] = miConfig.AccessKey
  7209. data["cainfo"] = miConfig.Cainfo
  7210. data["setl_mon"] = setl_mon
  7211. data["stmt_loc"] = "2"
  7212. data["upld_btch"] = upld_btch
  7213. client := &http.Client{}
  7214. bytesData, _ := json.Marshal(data)
  7215. var req *http.Request
  7216. if miConfig.MdtrtareaAdmvs == "320830" {
  7217. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7218. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7219. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7220. } else {
  7221. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7222. }
  7223. resp, _ := client.Do(req)
  7224. defer resp.Body.Close()
  7225. body, ioErr := ioutil.ReadAll(resp.Body)
  7226. if ioErr != nil {
  7227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. }
  7230. var respJSON map[string]interface{}
  7231. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7234. }
  7235. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7236. fmt.Println(respJSON)
  7237. result, _ := json.Marshal(respJSON)
  7238. fmt.Println(result)
  7239. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7240. utils.ErrorLog("解析失败:%v", err)
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7242. }
  7243. if result3265.Infcode != "0" {
  7244. c.ServeSuccessJSON(map[string]interface{}{
  7245. "failed_code": -10,
  7246. "msg": result3265.ErrMsg,
  7247. })
  7248. return
  7249. } else {
  7250. c.ServeSuccessJSON(map[string]interface{}{
  7251. "info": result3265.Output.Data,
  7252. })
  7253. return
  7254. }
  7255. }
  7256. func (c *HisApiController) Get3268() {
  7257. admin_user_id, _ := c.GetInt64("admin_user_id")
  7258. startTime := c.GetString("start_time")
  7259. endTime := c.GetString("end_time")
  7260. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7262. times := strings.Split(startTime, "-")
  7263. setl_mon := times[0] + times[1]
  7264. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7265. var twos []models.FixMonRecDetailFileInTwo
  7266. var funs []models.FundDetail
  7267. for _, item := range datas {
  7268. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7269. funs = append(funs, fun...)
  7270. }
  7271. var funInfos []models.Fund
  7272. //for _, item := range funs {
  7273. // var rf []models.FundInfo
  7274. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7275. // for _, subitem := range rf {
  7276. // var fund models.Fund
  7277. // fund.FundCode = subitem.FundPayType
  7278. // fund.FundName = subitem.FundPayTypeName
  7279. // fund.FundAmt = subitem.FundPayAmt
  7280. // fund.FundKey = item.FundKey
  7281. // fund.InsuAdmdvs = "555555"
  7282. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7283. // funInfos = append(funInfos, fund)
  7284. // }
  7285. //}
  7286. for _, team := range datas {
  7287. var two models.FixMonRecDetailFileInTwo
  7288. two.SetlDate = time.Now().Format("2006-01-02")
  7289. two.MedType = team.MedType
  7290. two.Insutype = team.Insutype
  7291. two.PsnType = team.PsnType
  7292. two.MedType = team.MedType
  7293. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7294. two.InsuAdmdvs = team.InsuAdmdvs
  7295. two.PsnTime = team.PsnTime
  7296. two.PsnCnt = team.PsnCnt
  7297. two.FundKey = team.FundKey
  7298. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7299. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7300. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7301. two.MedfeeSumAmt = ms
  7302. two.InscpAmt = ia
  7303. two.FundPaySumAmt = fps
  7304. twos = append(twos, two)
  7305. }
  7306. var upld_btch string
  7307. upld_btch = "0"
  7308. var empty models.JSResultEmpty
  7309. data := make(map[string]interface{})
  7310. data["org_name"] = miConfig.OrgName
  7311. data["doctor"] = curRoles.UserName
  7312. data["doctor_name"] = curRoles.UserName
  7313. data["fixmedins_code"] = miConfig.Code
  7314. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7315. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7316. data["secret_key"] = miConfig.SecretKey
  7317. data["url"] = miConfig.Url
  7318. data["ak"] = miConfig.AccessKey
  7319. data["cainfo"] = miConfig.Cainfo
  7320. data["datas"] = twos
  7321. data["fund"] = funInfos
  7322. data["setl_mon"] = setl_mon
  7323. month := time.Unix(1557042972, 0).Format("1")
  7324. year := time.Now().Format("2006")
  7325. month = time.Now().Format("01")
  7326. day := time.Now().Format("02")
  7327. hour := time.Now().Format("15")
  7328. min := time.Now().Format("04")
  7329. sec := time.Now().Format("05")
  7330. fix_fill_date := year + month + day + hour + min + sec
  7331. data["fix_fill_dept"] = miConfig.OrgName
  7332. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7333. data["fix_fill_psn"] = curRoles.UserName
  7334. data["fix_fill_date"] = fix_fill_date
  7335. data["stmt_loc"] = "2"
  7336. data["upld_btch"] = upld_btch
  7337. client := &http.Client{}
  7338. bytesData, _ := json.Marshal(data)
  7339. var req *http.Request
  7340. if miConfig.MdtrtareaAdmvs == "320830" {
  7341. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7342. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7343. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7344. } else {
  7345. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7346. }
  7347. resp, _ := client.Do(req)
  7348. defer resp.Body.Close()
  7349. body, ioErr := ioutil.ReadAll(resp.Body)
  7350. if ioErr != nil {
  7351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. }
  7354. var respJSON map[string]interface{}
  7355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. }
  7359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7360. fmt.Println(respJSON)
  7361. result, _ := json.Marshal(respJSON)
  7362. fmt.Println(result)
  7363. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7364. utils.ErrorLog("解析失败:%v", err)
  7365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7366. }
  7367. if empty.Infcode != "0" {
  7368. c.ServeSuccessJSON(map[string]interface{}{
  7369. "failed_code": -10,
  7370. "msg": empty.ErrMsg,
  7371. })
  7372. return
  7373. } else {
  7374. c.ServeSuccessJSON(map[string]interface{}{
  7375. "msg": "上传成功",
  7376. })
  7377. return
  7378. }
  7379. }
  7380. func (c *HisApiController) Get3269() {
  7381. admin_user_id, _ := c.GetInt64("admin_user_id")
  7382. startTime := c.GetString("start_time")
  7383. //endTime, _ := c.GetString("end_time")
  7384. times := strings.Split(startTime, "-")
  7385. setl_mon := times[0] + times[1]
  7386. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7387. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7388. var result3263 models.JSResult3263
  7389. data := make(map[string]interface{})
  7390. data["org_name"] = miConfig.OrgName
  7391. data["doctor"] = curRoles.UserName
  7392. data["doctor_name"] = curRoles.UserName
  7393. data["fixmedins_code"] = miConfig.Code
  7394. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7395. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7396. data["secret_key"] = miConfig.SecretKey
  7397. data["url"] = miConfig.Url
  7398. data["ak"] = miConfig.AccessKey
  7399. data["cainfo"] = miConfig.Cainfo
  7400. data["setl_mon"] = setl_mon
  7401. data["stmt_loc"] = "2"
  7402. client := &http.Client{}
  7403. bytesData, _ := json.Marshal(data)
  7404. var req *http.Request
  7405. if miConfig.MdtrtareaAdmvs == "320830" {
  7406. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7407. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7408. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7409. } else {
  7410. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7411. }
  7412. resp, _ := client.Do(req)
  7413. defer resp.Body.Close()
  7414. body, ioErr := ioutil.ReadAll(resp.Body)
  7415. if ioErr != nil {
  7416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7418. }
  7419. var respJSON map[string]interface{}
  7420. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. }
  7424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7425. fmt.Println(respJSON)
  7426. result, _ := json.Marshal(respJSON)
  7427. fmt.Println(result)
  7428. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7429. utils.ErrorLog("解析失败:%v", err)
  7430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7431. }
  7432. if result3263.Infcode != "0" {
  7433. c.ServeSuccessJSON(map[string]interface{}{
  7434. "failed_code": -10,
  7435. "msg": result3263.ErrMsg,
  7436. })
  7437. return
  7438. } else {
  7439. c.ServeSuccessJSON(map[string]interface{}{
  7440. "msg": "上传成功",
  7441. })
  7442. return
  7443. }
  7444. }
  7445. func (c *HisApiController) Get3270() {
  7446. admin_user_id, _ := c.GetInt64("admin_user_id")
  7447. startTime := c.GetString("start_time")
  7448. //endTime, _ := c.GetString("end_time")
  7449. times := strings.Split(startTime, "-")
  7450. setl_mon := times[0] + times[1]
  7451. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7453. var result3263 models.JSResult3263
  7454. data2 := make(map[string]interface{})
  7455. data2["org_name"] = miConfig.OrgName
  7456. data2["doctor"] = curRoles.UserName
  7457. data2["doctor_name"] = curRoles.UserName
  7458. data2["fixmedins_code"] = miConfig.Code
  7459. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7460. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7461. data2["secret_key"] = miConfig.SecretKey
  7462. data2["url"] = miConfig.Url
  7463. data2["ak"] = miConfig.AccessKey
  7464. data2["cainfo"] = miConfig.Cainfo
  7465. data2["setl_mon"] = setl_mon
  7466. data2["stmt_loc"] = "2"
  7467. client2 := &http.Client{}
  7468. bytesData2, _ := json.Marshal(data2)
  7469. var req3263 *http.Request
  7470. if miConfig.MdtrtareaAdmvs == "320830" {
  7471. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7472. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7473. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7474. } else {
  7475. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7476. }
  7477. resp2, _ := client2.Do(req3263)
  7478. defer resp2.Body.Close()
  7479. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7480. if ioErr2 != nil {
  7481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7483. }
  7484. var respJSON3263 map[string]interface{}
  7485. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7488. }
  7489. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7490. fmt.Println(respJSON3263)
  7491. result2, _ := json.Marshal(respJSON3263)
  7492. fmt.Println(result2)
  7493. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7494. utils.ErrorLog("解析失败:%v", err)
  7495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7496. }
  7497. var ids []string
  7498. for _, item := range result3263.Output {
  7499. ids = append(ids, item.SolidifyID)
  7500. }
  7501. var result3264 models.JSResult3264
  7502. data := make(map[string]interface{})
  7503. data["org_name"] = miConfig.OrgName
  7504. data["doctor"] = curRoles.UserName
  7505. data["doctor_name"] = curRoles.UserName
  7506. data["fixmedins_code"] = miConfig.Code
  7507. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7508. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7509. data["secret_key"] = miConfig.SecretKey
  7510. data["url"] = miConfig.Url
  7511. data["ak"] = miConfig.AccessKey
  7512. data["cainfo"] = miConfig.Cainfo
  7513. data["setl_mon"] = setl_mon
  7514. data["stmt_loc"] = "2"
  7515. data["solidify_id"] = ids
  7516. client := &http.Client{}
  7517. bytesData, _ := json.Marshal(data)
  7518. var req *http.Request
  7519. if miConfig.MdtrtareaAdmvs == "320830" {
  7520. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7521. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7522. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7523. } else {
  7524. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7525. }
  7526. resp, _ := client.Do(req)
  7527. defer resp.Body.Close()
  7528. body, ioErr := ioutil.ReadAll(resp.Body)
  7529. if ioErr != nil {
  7530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7532. }
  7533. var respJSON map[string]interface{}
  7534. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7537. }
  7538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7539. fmt.Println(respJSON)
  7540. result, _ := json.Marshal(respJSON)
  7541. fmt.Println(result)
  7542. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7543. utils.ErrorLog("解析失败:%v", err)
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. }
  7546. if result3264.Infcode != "0" {
  7547. c.ServeSuccessJSON(map[string]interface{}{
  7548. "failed_code": -10,
  7549. "msg": result3264.ErrMsg,
  7550. })
  7551. return
  7552. } else {
  7553. c.ServeSuccessJSON(map[string]interface{}{
  7554. "info": result3264.Output,
  7555. })
  7556. return
  7557. }
  7558. }
  7559. func (c *HisApiController) Get3271() {
  7560. admin_user_id, _ := c.GetInt64("admin_user_id")
  7561. startTime := c.GetString("start_time")
  7562. //endTime, _ := c.GetString("end_time")
  7563. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7565. times := strings.Split(startTime, "-")
  7566. setl_mon := times[0] + times[1]
  7567. //var empty models.JSResultEmpty
  7568. var result3265 models.JSResult3264
  7569. var result3263 models.JSResult3263
  7570. data2 := make(map[string]interface{})
  7571. data2["org_name"] = miConfig.OrgName
  7572. data2["doctor"] = curRoles.UserName
  7573. data2["doctor_name"] = curRoles.UserName
  7574. data2["fixmedins_code"] = miConfig.Code
  7575. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7576. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7577. data2["secret_key"] = miConfig.SecretKey
  7578. data2["url"] = miConfig.Url
  7579. data2["ak"] = miConfig.AccessKey
  7580. data2["cainfo"] = miConfig.Cainfo
  7581. data2["setl_mon"] = setl_mon
  7582. data2["stmt_loc"] = "2"
  7583. client2 := &http.Client{}
  7584. bytesData2, _ := json.Marshal(data2)
  7585. var req3263 *http.Request
  7586. if miConfig.MdtrtareaAdmvs == "320830" {
  7587. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7588. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7589. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7590. } else {
  7591. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7592. }
  7593. resp2, _ := client2.Do(req3263)
  7594. defer resp2.Body.Close()
  7595. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7596. if ioErr2 != nil {
  7597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. }
  7600. var respJSON3263 map[string]interface{}
  7601. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7604. }
  7605. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7606. fmt.Println(respJSON3263)
  7607. result2, _ := json.Marshal(respJSON3263)
  7608. fmt.Println(result2)
  7609. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7610. utils.ErrorLog("解析失败:%v", err)
  7611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7612. }
  7613. var ids []string
  7614. for _, item := range result3263.Output {
  7615. ids = append(ids, item.SolidifyID)
  7616. }
  7617. data := make(map[string]interface{})
  7618. data["org_name"] = miConfig.OrgName
  7619. data["doctor"] = curRoles.UserName
  7620. data["doctor_name"] = curRoles.UserName
  7621. data["fixmedins_code"] = miConfig.Code
  7622. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7623. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7624. data["secret_key"] = miConfig.SecretKey
  7625. data["url"] = miConfig.Url
  7626. data["ak"] = miConfig.AccessKey
  7627. data["cainfo"] = miConfig.Cainfo
  7628. data["setl_mon"] = setl_mon
  7629. data["solidify_id"] = ids
  7630. month := time.Unix(1557042972, 0).Format("1")
  7631. year := time.Now().Format("2006")
  7632. month = time.Now().Format("01")
  7633. day := time.Now().Format("02")
  7634. hour := time.Now().Format("15")
  7635. min := time.Now().Format("04")
  7636. sec := time.Now().Format("05")
  7637. fix_fill_date := year + month + day + hour + min + sec
  7638. data["fix_fill_dept"] = miConfig.OrgName
  7639. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7640. data["fix_fill_psn"] = curRoles.UserName
  7641. data["fix_fill_date"] = fix_fill_date
  7642. data["stmt_loc"] = "2"
  7643. client := &http.Client{}
  7644. bytesData, _ := json.Marshal(data)
  7645. var req *http.Request
  7646. if miConfig.MdtrtareaAdmvs == "320830" {
  7647. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7648. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7649. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7650. } else {
  7651. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7652. }
  7653. resp, _ := client.Do(req)
  7654. defer resp.Body.Close()
  7655. body, ioErr := ioutil.ReadAll(resp.Body)
  7656. if ioErr != nil {
  7657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7659. }
  7660. var respJSON map[string]interface{}
  7661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7664. }
  7665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7666. fmt.Println(respJSON)
  7667. result, _ := json.Marshal(respJSON)
  7668. fmt.Println(result)
  7669. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7670. utils.ErrorLog("解析失败:%v", err)
  7671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7672. }
  7673. if result3265.Infcode != "0" {
  7674. c.ServeSuccessJSON(map[string]interface{}{
  7675. "failed_code": -10,
  7676. "msg": result3265.ErrMsg,
  7677. })
  7678. return
  7679. } else {
  7680. c.ServeSuccessJSON(map[string]interface{}{
  7681. "info": result3265.Output.Data,
  7682. })
  7683. return
  7684. }
  7685. }
  7686. func (c *HisApiController) Get3272() {
  7687. admin_user_id, _ := c.GetInt64("admin_user_id")
  7688. startTime := c.GetString("start_time")
  7689. //endTime, _ := c.GetString("end_time")
  7690. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7692. times := strings.Split(startTime, "-")
  7693. setl_mon := times[0] + times[1]
  7694. var upld_btch string
  7695. //var empty models.JSResultEmpty
  7696. var result3265 models.JSResult3264
  7697. data := make(map[string]interface{})
  7698. data["org_name"] = miConfig.OrgName
  7699. data["doctor"] = curRoles.UserName
  7700. data["doctor_name"] = curRoles.UserName
  7701. data["fixmedins_code"] = miConfig.Code
  7702. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7703. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7704. data["secret_key"] = miConfig.SecretKey
  7705. data["url"] = miConfig.Url
  7706. data["ak"] = miConfig.AccessKey
  7707. data["cainfo"] = miConfig.Cainfo
  7708. data["setl_mon"] = setl_mon
  7709. month := time.Unix(1557042972, 0).Format("1")
  7710. year := time.Now().Format("2006")
  7711. month = time.Now().Format("01")
  7712. day := time.Now().Format("02")
  7713. hour := time.Now().Format("15")
  7714. min := time.Now().Format("04")
  7715. sec := time.Now().Format("05")
  7716. fix_fill_date := year + month + day + hour + min + sec
  7717. data["fix_fill_dept"] = miConfig.OrgName
  7718. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7719. data["fix_fill_psn"] = curRoles.UserName
  7720. data["fix_fill_date"] = fix_fill_date
  7721. data["stmt_loc"] = "2"
  7722. data["upld_btch"] = upld_btch
  7723. client := &http.Client{}
  7724. bytesData, _ := json.Marshal(data)
  7725. var req *http.Request
  7726. if miConfig.MdtrtareaAdmvs == "320830" {
  7727. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7728. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7729. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7730. } else {
  7731. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7732. }
  7733. resp, _ := client.Do(req)
  7734. defer resp.Body.Close()
  7735. body, ioErr := ioutil.ReadAll(resp.Body)
  7736. if ioErr != nil {
  7737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7739. }
  7740. var respJSON map[string]interface{}
  7741. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. }
  7745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7746. fmt.Println(respJSON)
  7747. result, _ := json.Marshal(respJSON)
  7748. fmt.Println(result)
  7749. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7750. utils.ErrorLog("解析失败:%v", err)
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. }
  7753. if result3265.Infcode != "0" {
  7754. c.ServeSuccessJSON(map[string]interface{}{
  7755. "failed_code": -10,
  7756. "msg": result3265.ErrMsg,
  7757. })
  7758. return
  7759. } else {
  7760. c.ServeSuccessJSON(map[string]interface{}{
  7761. "info": result3265.Output,
  7762. })
  7763. return
  7764. }
  7765. }
  7766. func (c *HisApiController) Get3273() {
  7767. admin_user_id, _ := c.GetInt64("admin_user_id")
  7768. startTime := c.GetString("start_time")
  7769. //endTime, _ := c.GetString("end_time")
  7770. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7771. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7772. times := strings.Split(startTime, "-")
  7773. setl_mon := times[0] + times[1]
  7774. var result3265 models.JSResult3264
  7775. data := make(map[string]interface{})
  7776. data["org_name"] = miConfig.OrgName
  7777. data["doctor"] = curRoles.UserName
  7778. data["doctor_name"] = curRoles.UserName
  7779. data["fixmedins_code"] = miConfig.Code
  7780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7782. data["secret_key"] = miConfig.SecretKey
  7783. data["url"] = miConfig.Url
  7784. data["ak"] = miConfig.AccessKey
  7785. data["cainfo"] = miConfig.Cainfo
  7786. data["setl_mon"] = setl_mon
  7787. data["stmt_loc"] = "2"
  7788. client := &http.Client{}
  7789. bytesData, _ := json.Marshal(data)
  7790. var req *http.Request
  7791. if miConfig.MdtrtareaAdmvs == "320921" {
  7792. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7793. } else {
  7794. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7795. }
  7796. resp, _ := client.Do(req)
  7797. defer resp.Body.Close()
  7798. body, ioErr := ioutil.ReadAll(resp.Body)
  7799. if ioErr != nil {
  7800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7802. }
  7803. var respJSON map[string]interface{}
  7804. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. }
  7808. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7809. fmt.Println(respJSON)
  7810. result, _ := json.Marshal(respJSON)
  7811. fmt.Println(result)
  7812. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7813. utils.ErrorLog("解析失败:%v", err)
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. }
  7816. if result3265.Infcode != "0" {
  7817. c.ServeSuccessJSON(map[string]interface{}{
  7818. "failed_code": -10,
  7819. "msg": result3265.ErrMsg,
  7820. })
  7821. return
  7822. } else {
  7823. c.ServeSuccessJSON(map[string]interface{}{
  7824. "info": result3265.Output.Data,
  7825. })
  7826. return
  7827. }
  7828. }
  7829. func (c *HisApiController) Get3274() {
  7830. //if miConfig.MdtrtareaAdmvs == "320921" {
  7831. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7832. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7833. // "&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
  7834. //
  7835. //} else {
  7836. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7837. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7838. // "&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
  7839. //
  7840. //}
  7841. }
  7842. func (c *HisApiController) Get3275() {
  7843. //if miConfig.MdtrtareaAdmvs == "320921" {
  7844. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7845. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7846. // "&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
  7847. //
  7848. //} else {
  7849. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7850. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7851. // "&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
  7852. //
  7853. //}
  7854. }
  7855. func (c *HisApiController) Get3276() {
  7856. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7857. //month := c.GetString("month")
  7858. //
  7859. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7860. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7861. //var api string
  7862. //var res Result5301
  7863. //
  7864. //if miConfig.MdtrtareaAdmvs == "320921" {
  7865. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7866. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7867. //} else {
  7868. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7869. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7870. //}
  7871. //
  7872. //resp, requestErr := http.Get(api)
  7873. //if requestErr != nil {
  7874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7875. // return
  7876. //}
  7877. //
  7878. //body, ioErr := ioutil.ReadAll(resp.Body)
  7879. //if ioErr != nil {
  7880. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. // return
  7883. //}
  7884. //var respJSON map[string]interface{}
  7885. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7886. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7888. // return
  7889. //}
  7890. //
  7891. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7892. //result, _ := json.Marshal(respJSON)
  7893. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7894. // utils.ErrorLog("解析失败:%v", err)
  7895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. // return
  7897. //}
  7898. }
  7899. func (c *HisApiController) Get3277() {
  7900. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7901. //month := c.GetString("month")
  7902. //
  7903. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7904. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7905. //var api string
  7906. //var res Result5301
  7907. //
  7908. //if miConfig.MdtrtareaAdmvs == "320921" {
  7909. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7910. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7911. //} else {
  7912. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7913. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7914. //}
  7915. //
  7916. //resp, requestErr := http.Get(api)
  7917. //if requestErr != nil {
  7918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7919. // return
  7920. //}
  7921. //
  7922. //body, ioErr := ioutil.ReadAll(resp.Body)
  7923. //if ioErr != nil {
  7924. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7926. // return
  7927. //}
  7928. //var respJSON map[string]interface{}
  7929. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7930. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7932. // return
  7933. //}
  7934. //
  7935. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7936. //result, _ := json.Marshal(respJSON)
  7937. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7938. // utils.ErrorLog("解析失败:%v", err)
  7939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7940. // return
  7941. //}
  7942. }
  7943. func (c *HisApiController) GetCFYLJG001() {
  7944. admin_user_id, _ := c.GetInt64("admin_user_id")
  7945. patient_id, _ := c.GetInt64("patient_id")
  7946. his_patient_id, _ := c.GetInt64("his_patient_id")
  7947. record_time := c.GetString("record_time")
  7948. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7949. psn, _ := service.GetPsnByPatientId(patient_id)
  7950. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7951. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7952. var cFYLJG001 models.CFYLJG001
  7953. timeLayout := "2006-01-02"
  7954. loc, _ := time.LoadLocation("Local")
  7955. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7956. if err != nil {
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7958. return
  7959. }
  7960. recordDateTime := theTime.Unix()
  7961. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7962. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7963. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7964. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7965. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7966. for _, item := range prescriptions {
  7967. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7968. if his.IdCardType == 1 {
  7969. bas := strings.Split(psn.CardInfo, "|")
  7970. basNumber := bas[1]
  7971. fmt.Println(basNumber)
  7972. card_sn := bas[3]
  7973. card_no := bas[2]
  7974. cFYLJG001.MdtrtCertType = "03"
  7975. cFYLJG001.CardSn = card_sn
  7976. cFYLJG001.MdtrtCertNo = card_no
  7977. cFYLJG001.EcToken = ""
  7978. cFYLJG001.AuthNo = ""
  7979. } else if his.IdCardType == 2 {
  7980. cFYLJG001.MdtrtCertType = "02"
  7981. cFYLJG001.CardSn = ""
  7982. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7983. cFYLJG001.EcToken = ""
  7984. cFYLJG001.AuthNo = ""
  7985. } else if his.IdCardType == 4 {
  7986. cFYLJG001.MdtrtCertType = "01"
  7987. cFYLJG001.CardSn = ""
  7988. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7989. cFYLJG001.EcToken = psn.VerifyNumber
  7990. cFYLJG001.AuthNo = ""
  7991. }
  7992. cFYLJG001.BizTypeCode = "01"
  7993. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7994. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7995. cFYLJG001.RxTypeCode = "1"
  7996. tempTime := time.Unix(item.PreTime, 0)
  7997. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7998. cFYLJG001.PrscTime = timeFormatOne
  7999. var count float64
  8000. if item.Type == 1 {
  8001. for _, sumItem := range item.HisDoctorAdviceInfo {
  8002. count = count + sumItem.PrescribingNumber
  8003. }
  8004. }
  8005. cFYLJG001.RxDrugCnt = count
  8006. cFYLJG001.ValiDays = "2"
  8007. ts := time.Unix(item.PreTime, 0)
  8008. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  8009. tempTime3 := time.Unix(record_time2, 0)
  8010. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  8011. cFYLJG001.ValiEndTime = timeFormat3
  8012. cFYLJG001.RxCotnFlag = "0"
  8013. for _, subItem := range item.HisDoctorAdviceInfo {
  8014. var drug models.RxDrug
  8015. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8016. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8017. drug.RxItemTypeCode = "11"
  8018. drug.DrugDosform = "剂" //TODO
  8019. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  8020. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  8021. }
  8022. drug.MedcWayDscr = subItem.DeliveryWay
  8023. tempTime2 := time.Unix(subItem.StartTime, 0)
  8024. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8025. drug.MedcBegntime = timeFormatTwo
  8026. if subItem.Day > 0 {
  8027. ts := time.Unix(subItem.StartTime, 0)
  8028. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  8029. tempTime4 := time.Unix(record_time, 0)
  8030. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  8031. drug.MedcEndtime = timeFormat5
  8032. } else {
  8033. tempTime2 := time.Unix(subItem.StartTime, 0)
  8034. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8035. drug.MedcEndtime = timeFormatTwo
  8036. }
  8037. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  8038. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  8039. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  8040. drug.DrugCnt = subItem.PrescribingNumber
  8041. drug.DrugDosunt = subItem.PrescribingNumberUnit
  8042. drug.DrugGenname = subItem.AdviceName
  8043. drug.MedcWayCodg = subItem.DeliveryWay
  8044. //drug.DrugTotlcnt = subItem.PrescribingNumber
  8045. drug.SinDoscnt = subItem.SingleDose
  8046. drug.SinDosunt = subItem.SingleDoseUnit
  8047. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  8048. drug.UsedFrquName = subItem.ExecutionFrequency
  8049. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  8050. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  8051. drug.HospApprFlag = "1"
  8052. cFYLJG001.List = append(cFYLJG001.List, drug)
  8053. }
  8054. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  8055. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  8056. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  8057. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  8058. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  8059. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  8060. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  8061. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  8062. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  8063. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  8064. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8065. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  8066. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  8067. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  8068. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8069. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  8070. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  8071. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  8072. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  8073. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  8074. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  8075. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  8076. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  8077. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  8078. tempTime2 := time.Now().Unix()
  8079. tempTime6 := time.Unix(tempTime2, 0)
  8080. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  8081. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  8082. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  8083. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  8084. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  8085. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  8086. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  8087. var config []*models.HisXtDiagnoseConfig
  8088. for _, item := range diagnosis_ids {
  8089. id, _ := strconv.ParseInt(item, 10, 64)
  8090. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8091. config = append(config, &diagnosisConfig)
  8092. }
  8093. for index, subitem := range config {
  8094. if index == 0 {
  8095. var dia models.DiseInfo
  8096. dia.DiagType = "1"
  8097. dia.MaindiagFlag = "1"
  8098. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8099. dia.DiagCode = subitem.CountryCode
  8100. dia.DiagName = subitem.ClassName
  8101. dia.DiagDept = "肾内科"
  8102. dia.DiagDrNo = doctor.DoctorNumber
  8103. dia.DiagDrName = doctor.UserName
  8104. tempTime3 := time.Unix(item.PreTime, 0)
  8105. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8106. dia.DiagTime = timeFormatTwo
  8107. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8108. } else {
  8109. var dia models.DiseInfo
  8110. dia.DiagType = "1"
  8111. dia.MaindiagFlag = "0"
  8112. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8113. dia.DiagCode = subitem.CountryCode
  8114. dia.DiagName = subitem.ClassName
  8115. dia.DiagDept = "肾内科"
  8116. dia.DiagDrNo = doctor.DoctorNumber
  8117. dia.DiagDrName = doctor.UserName
  8118. tempTime3 := time.Unix(item.PreTime, 0)
  8119. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8120. dia.DiagTime = timeFormatTwo
  8121. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8122. }
  8123. }
  8124. if miConfig.MdtrtareaAdmvs == "340699" {
  8125. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8126. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8127. var res ResultCFYLJG001AH
  8128. var respJSON2 map[string]interface{}
  8129. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8132. return
  8133. }
  8134. userJSONBytes2, _ := json.Marshal(respJSON2)
  8135. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8136. utils.ErrorLog("解析失败:%v", err)
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8138. return
  8139. }
  8140. var flow models.HisPrescriptionFlow
  8141. flow.Ctime = time.Now().Unix()
  8142. flow.SignDigest = ""
  8143. flow.RxTraceCode = res.RxTraceCode
  8144. flow.HiRxno = res.HiRxno
  8145. flow.MID = his.Number
  8146. flow.Status = 1
  8147. flow.DCode = doctor_info.DoctorNumber
  8148. flow.OriginalRxFile = ""
  8149. flow.OriginalValue = ""
  8150. flow.SignCertDn = ""
  8151. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8152. flow.SignCertSn = ""
  8153. flow.Mtime = time.Now().Unix()
  8154. service.Createflow(&flow)
  8155. c.ServeSuccessJSON(map[string]interface{}{
  8156. "msg": "上传成功",
  8157. })
  8158. } else {
  8159. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8160. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8161. var res ResultCFYLJG001
  8162. var respJSON2 map[string]interface{}
  8163. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8166. return
  8167. }
  8168. userJSONBytes2, _ := json.Marshal(respJSON2)
  8169. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8170. utils.ErrorLog("解析失败:%v", err)
  8171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8172. return
  8173. }
  8174. if res.Infcode == -1 {
  8175. c.ServeSuccessJSON(map[string]interface{}{
  8176. "failed_code": -10,
  8177. "msg": res.ErrMsg,
  8178. })
  8179. return
  8180. } else {
  8181. var flow models.HisPrescriptionFlow
  8182. flow.Ctime = time.Now().Unix()
  8183. flow.SignDigest = ""
  8184. flow.RxTraceCode = res.Output.RxTraceCode
  8185. flow.HiRxno = res.Output.HiRxno
  8186. flow.MID = his.Number
  8187. flow.Status = 1
  8188. flow.DCode = doctor_info.DoctorNumber
  8189. flow.OriginalRxFile = ""
  8190. flow.OriginalValue = ""
  8191. flow.SignCertDn = ""
  8192. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8193. flow.SignCertSn = ""
  8194. flow.Mtime = time.Now().Unix()
  8195. service.Createflow(&flow)
  8196. c.ServeSuccessJSON(map[string]interface{}{
  8197. "msg": "上传成功",
  8198. })
  8199. }
  8200. }
  8201. }
  8202. }
  8203. func (c *HisApiController) GetCFYLJG12() {
  8204. admin_user_id, _ := c.GetInt64("admin_user_id")
  8205. his_patient_id, _ := c.GetInt64("his_patient_id")
  8206. record_time := c.GetString("record_time")
  8207. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8208. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8209. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8210. flow, _ := service.Getflowtwo(his.Number)
  8211. patient_id, _ := c.GetInt64("patient_id")
  8212. timeLayout := "2006-01-02"
  8213. loc, _ := time.LoadLocation("Local")
  8214. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8215. if err != nil {
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8217. return
  8218. }
  8219. recordDateTime := theTime.Unix()
  8220. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8221. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8222. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8223. dept, _ := service.GetDepartMentDetail(info.Departments)
  8224. inputData := make(map[string]interface{})
  8225. inputData["rxTraceCode"] = flow.RxTraceCode
  8226. inputData["hiRxno"] = flow.HiRxno
  8227. inputData["mdtrtId"] = flow.MID
  8228. inputData["patnName"] = his.PsnName
  8229. inputData["psnCertType"] = his.PsnCertType
  8230. inputData["certno"] = his.Certno
  8231. inputData["fixmedinsName"] = miConfig.OrgName
  8232. inputData["fixmedinsCode"] = miConfig.Code
  8233. inputData["drCode"] = doctor_info.DoctorNumber
  8234. inputData["prscDrName"] = doctor_info.UserName
  8235. inputData["pharDeptName"] = dept.Name
  8236. inputData["pharDeptCode"] = dept.Number
  8237. inputData["pharProfttlCodg"] = ""
  8238. inputData["pharProfttlName"] = ""
  8239. inputData["pharCode"] = "HY340621000425"
  8240. inputData["pharCertType"] = "01"
  8241. inputData["pharCertno"] = ""
  8242. inputData["pharName"] = "孙莉侠"
  8243. inputData["pharPracCertNo"] = ""
  8244. tempTime2 := time.Unix(info.Ctime, 0)
  8245. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8246. inputData["pharChkTime"] = timeFormatTwo
  8247. bytesData, _ := json.Marshal(inputData)
  8248. fmt.Println(string(bytesData))
  8249. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8250. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8251. if err != nil {
  8252. fmt.Println("Error reading PDF file:", err)
  8253. return
  8254. }
  8255. // 将 PDF 文件内容进行 Base64 编码
  8256. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8257. fmt.Println(err)
  8258. if miConfig.MdtrtareaAdmvs == "340699" {
  8259. data := make(map[string]interface{})
  8260. data["rx_encoded"] = rx_encoded
  8261. data["code"] = miConfig.Code
  8262. data["url"] = "http://10.66.149.64:8080/epc/api"
  8263. data["encoded"] = encoded
  8264. client := &http.Client{}
  8265. bytesData, _ := json.Marshal(data)
  8266. var req *http.Request
  8267. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8268. resp, _ := client.Do(req)
  8269. defer resp.Body.Close()
  8270. body, ioErr := ioutil.ReadAll(resp.Body)
  8271. if ioErr != nil {
  8272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8273. }
  8274. var respJSON map[string]interface{}
  8275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. return
  8279. }
  8280. var resSix10265 ResultSix10265 //1101结果
  8281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8282. result, _ := json.Marshal(respJSON)
  8283. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8284. utils.ErrorLog("解析失败:%v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8289. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8290. } else {
  8291. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8292. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8293. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8294. var res2 AhResult002
  8295. var respJSON2 map[string]interface{}
  8296. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8299. return
  8300. }
  8301. userJSONBytes2, _ := json.Marshal(respJSON2)
  8302. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8303. utils.ErrorLog("解析失败:%v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. flow.Ctime = time.Now().Unix()
  8308. flow.SignDigest = res2.SignDigest
  8309. flow.RxFile = res2.RxFile
  8310. flow.MID = his.Number
  8311. flow.Status = 1
  8312. flow.DCode = doctor_info.DoctorNumber
  8313. flow.OriginalRxFile = rx_encoded
  8314. flow.OriginalValue = encoded
  8315. flow.SignCertDn = res2.SignCertDn
  8316. flow.SignCertSn = res2.SignCertSn
  8317. flow.Mtime = time.Now().Unix()
  8318. service.Saveflow(flow)
  8319. c.ServeSuccessJSON(map[string]interface{}{
  8320. "msg": "预签名成功",
  8321. })
  8322. }
  8323. }
  8324. func (c *HisApiController) GetCFYLJG13() {
  8325. admin_user_id, _ := c.GetInt64("admin_user_id")
  8326. his_patient_id, _ := c.GetInt64("his_patient_id")
  8327. record_time := c.GetString("record_time")
  8328. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8329. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8331. flow, _ := service.Getflowtwo(his.Number)
  8332. patient_id, _ := c.GetInt64("patient_id")
  8333. timeLayout := "2006-01-02"
  8334. loc, _ := time.LoadLocation("Local")
  8335. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8336. if err != nil {
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8338. return
  8339. }
  8340. recordDateTime := theTime.Unix()
  8341. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8342. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8343. dept, _ := service.GetDepartMentDetail(info.Departments)
  8344. var cFYLJG003 models.CFYLJG003
  8345. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8346. cFYLJG003.HiRxno = flow.HiRxno
  8347. cFYLJG003.MdtrtID = flow.MID
  8348. cFYLJG003.PatnName = his.Name
  8349. cFYLJG003.Certno = his.Certno
  8350. cFYLJG003.FixmedinsName = miConfig.OrgName
  8351. cFYLJG003.FixmedinsCode = miConfig.Code
  8352. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8353. cFYLJG003.PrscDrName = doctor_info.UserName
  8354. cFYLJG003.PharDeptName = dept.Name
  8355. cFYLJG003.PharDeptCode = dept.Number
  8356. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8357. cFYLJG003.PharName = "孙莉侠"
  8358. cFYLJG003.PharPracCertNo = "060399"
  8359. cFYLJG003.PharCode = "HY340621000425"
  8360. cFYLJG003.PharCertType = "01"
  8361. cFYLJG003.PharCertno = ""
  8362. } else {
  8363. cFYLJG003.PharName = "彭斯遥"
  8364. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8365. cFYLJG003.PharCode = "HY440309002107"
  8366. cFYLJG003.PharCertType = "01"
  8367. cFYLJG003.PharCertno = "430482199408260023"
  8368. }
  8369. cFYLJG003.PsnCertType = "01"
  8370. cFYLJG003.RxFile = flow.RxFile
  8371. cFYLJG003.SignDigest = flow.SignDigest
  8372. cFYLJG003.FixmedinsCode = miConfig.Code
  8373. cFYLJG003.PsnCertType = "01"
  8374. cFYLJG003.PharProfttlCodg = dept.Name
  8375. tempTime2 := time.Unix(info.Ctime, 0)
  8376. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8377. cFYLJG003.PharChkTime = timeFormatTwo
  8378. if miConfig.MdtrtareaAdmvs == "340699" {
  8379. data := make(map[string]interface{})
  8380. data["url"] = "http://10.66.149.64:8080/epc/api"
  8381. data["13"] = cFYLJG003
  8382. client := &http.Client{}
  8383. bytesData, _ := json.Marshal(data)
  8384. var req *http.Request
  8385. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8386. resp, _ := client.Do(req)
  8387. defer resp.Body.Close()
  8388. body, ioErr := ioutil.ReadAll(resp.Body)
  8389. if ioErr != nil {
  8390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8391. }
  8392. var respJSON map[string]interface{}
  8393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. var resSix10265 ResultSix10265 //1101结果
  8399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8400. result, _ := json.Marshal(respJSON)
  8401. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8402. utils.ErrorLog("解析失败:%v", err)
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8407. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8408. } else {
  8409. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8410. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8411. var res ResultCFYLJG003
  8412. var respJSON2 map[string]interface{}
  8413. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. userJSONBytes2, _ := json.Marshal(respJSON2)
  8419. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8420. utils.ErrorLog("解析失败:%v", err)
  8421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8422. return
  8423. }
  8424. if res.Infcode == -1 {
  8425. c.ServeSuccessJSON(map[string]interface{}{
  8426. "failed_code": -10,
  8427. "msg": res.ErrMsg,
  8428. })
  8429. return
  8430. } else {
  8431. c.ServeSuccessJSON(map[string]interface{}{
  8432. "info": res.Output,
  8433. })
  8434. }
  8435. }
  8436. }
  8437. func (c *HisApiController) GetCFYLJG002() {
  8438. admin_user_id, _ := c.GetInt64("admin_user_id")
  8439. his_patient_id, _ := c.GetInt64("his_patient_id")
  8440. record_time := c.GetString("record_time")
  8441. admin_user_id = 3626
  8442. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8443. //id, _ := c.GetInt64("id")
  8444. admin_user_id = 3626
  8445. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8446. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8447. flow, _ := service.Getflowtwo(his.Number)
  8448. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8449. //record_time := c.GetString("record_time")
  8450. patient_id, _ := c.GetInt64("patient_id")
  8451. //patient_id = 23834
  8452. //record_time = "2023-09-18"
  8453. timeLayout := "2006-01-02"
  8454. loc, _ := time.LoadLocation("Local")
  8455. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8456. if err != nil {
  8457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8458. return
  8459. }
  8460. recordDateTime := theTime.Unix()
  8461. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8462. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8463. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8464. dept, _ := service.GetDepartMentDetail(info.Departments)
  8465. inputData := make(map[string]interface{})
  8466. inputData["rxTraceCode"] = flow.RxTraceCode
  8467. inputData["hiRxno"] = flow.HiRxno
  8468. inputData["mdtrtId"] = flow.MID
  8469. inputData["patnName"] = his.PsnName
  8470. inputData["psnCertType"] = his.PsnCertType
  8471. inputData["certno"] = his.Certno
  8472. inputData["fixmedinsName"] = miConfig.OrgName
  8473. inputData["fixmedinsCode"] = miConfig.Code
  8474. inputData["drCode"] = doctor_info.DoctorNumber
  8475. inputData["prscDrName"] = doctor_info.UserName
  8476. inputData["pharDeptName"] = dept.Name
  8477. inputData["pharDeptCode"] = dept.Number
  8478. inputData["pharProfttlCodg"] = ""
  8479. inputData["pharProfttlName"] = ""
  8480. inputData["pharCode"] = "HY340621000425"
  8481. inputData["pharCertType"] = "01"
  8482. inputData["pharCertno"] = ""
  8483. inputData["pharName"] = "孙莉侠"
  8484. inputData["pharPracCertNo"] = "060399"
  8485. tempTime2 := time.Unix(info.Ctime, 0)
  8486. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8487. inputData["pharChkTime"] = timeFormatTwo
  8488. bytesData, _ := json.Marshal(inputData)
  8489. fmt.Println(string(bytesData))
  8490. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8491. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8492. if err != nil {
  8493. fmt.Println("Error reading PDF file:", err)
  8494. return
  8495. }
  8496. // 将 PDF 文件内容进行 Base64 编码
  8497. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8498. fmt.Println(err)
  8499. if miConfig.MdtrtareaAdmvs == "340699" {
  8500. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8501. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8502. var res2 AhResult002
  8503. var respJSON2 map[string]interface{}
  8504. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. userJSONBytes2, _ := json.Marshal(respJSON2)
  8510. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8511. utils.ErrorLog("解析失败:%v", err)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. flow.Ctime = time.Now().Unix()
  8516. flow.SignDigest = res2.SignDigest
  8517. flow.RxFile = res2.RxFile
  8518. flow.MID = his.Number
  8519. flow.Status = 1
  8520. flow.DCode = doctor_info.DoctorNumber
  8521. flow.OriginalRxFile = rx_encoded
  8522. flow.OriginalValue = encoded
  8523. flow.SignCertDn = res2.SignCertDn
  8524. flow.SignCertSn = res2.SignCertSn
  8525. flow.Mtime = time.Now().Unix()
  8526. service.Saveflow(flow)
  8527. c.ServeSuccessJSON(map[string]interface{}{
  8528. "msg": "预签名成功",
  8529. })
  8530. } else {
  8531. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8532. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8533. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8534. var res2 Result002
  8535. var respJSON2 map[string]interface{}
  8536. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8539. return
  8540. }
  8541. userJSONBytes2, _ := json.Marshal(respJSON2)
  8542. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8543. utils.ErrorLog("解析失败:%v", err)
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. if res2.Infcode == 0 {
  8548. flow.Ctime = time.Now().Unix()
  8549. flow.SignDigest = res2.Output.SignDigest
  8550. flow.RxFile = res2.Output.RxFile
  8551. flow.MID = his.Number
  8552. flow.Status = 1
  8553. flow.DCode = doctor_info.DoctorNumber
  8554. flow.OriginalRxFile = rx_encoded
  8555. flow.OriginalValue = encoded
  8556. flow.SignCertDn = res2.Output.SignCertDn
  8557. flow.SignCertSn = res2.Output.SignCertSn
  8558. flow.Mtime = time.Now().Unix()
  8559. service.Saveflow(flow)
  8560. c.ServeSuccessJSON(map[string]interface{}{
  8561. "msg": "预签名成功",
  8562. })
  8563. } else {
  8564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8565. return
  8566. }
  8567. }
  8568. }
  8569. func (c *HisApiController) GetCFYLJG003() {
  8570. admin_user_id, _ := c.GetInt64("admin_user_id")
  8571. his_patient_id, _ := c.GetInt64("his_patient_id")
  8572. record_time := c.GetString("record_time")
  8573. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8574. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8575. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8576. flow, _ := service.Getflowtwo(his.Number)
  8577. patient_id, _ := c.GetInt64("patient_id")
  8578. timeLayout := "2006-01-02"
  8579. loc, _ := time.LoadLocation("Local")
  8580. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8581. if err != nil {
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8583. return
  8584. }
  8585. recordDateTime := theTime.Unix()
  8586. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8587. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8588. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8589. dept, _ := service.GetDepartMentDetail(info.Departments)
  8590. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8591. var cFYLJG003 models.CFYLJG003
  8592. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8593. cFYLJG003.HiRxno = flow.HiRxno
  8594. cFYLJG003.MdtrtID = flow.MID
  8595. cFYLJG003.PatnName = his.PsnName
  8596. cFYLJG003.Certno = his.Certno
  8597. cFYLJG003.FixmedinsName = miConfig.OrgName
  8598. cFYLJG003.FixmedinsCode = miConfig.Code
  8599. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8600. cFYLJG003.PrscDrName = doctor_info.UserName
  8601. cFYLJG003.PharDeptName = dept.Name
  8602. cFYLJG003.PharDeptCode = dept.Number
  8603. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8604. cFYLJG003.PharName = "孙莉侠"
  8605. cFYLJG003.PharPracCertNo = "060399"
  8606. cFYLJG003.PharCode = "HY340621000425"
  8607. cFYLJG003.PharCertType = "01"
  8608. cFYLJG003.PharCertno = ""
  8609. } else {
  8610. cFYLJG003.PharName = "彭斯遥"
  8611. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8612. cFYLJG003.PharCode = "HY440309002107"
  8613. cFYLJG003.PharCertType = "01"
  8614. cFYLJG003.PharCertno = "430482199408260023"
  8615. }
  8616. cFYLJG003.RxFile = flow.RxFile
  8617. cFYLJG003.SignDigest = flow.SignDigest
  8618. cFYLJG003.FixmedinsCode = miConfig.Code
  8619. cFYLJG003.PsnCertType = his.PsnCertType
  8620. tempTime2 := time.Unix(info.Ctime, 0)
  8621. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8622. cFYLJG003.PharChkTime = timeFormatTwo
  8623. if miConfig.MdtrtareaAdmvs == "340699" {
  8624. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8625. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8626. var res AHResult003
  8627. var respJSON2 map[string]interface{}
  8628. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8631. return
  8632. }
  8633. userJSONBytes2, _ := json.Marshal(respJSON2)
  8634. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8635. utils.ErrorLog("解析失败:%v", err)
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8637. return
  8638. }
  8639. {
  8640. c.ServeSuccessJSON(map[string]interface{}{
  8641. "info": res,
  8642. })
  8643. }
  8644. } else {
  8645. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8646. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8647. var res ResultCFYLJG003
  8648. var respJSON2 map[string]interface{}
  8649. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8652. return
  8653. }
  8654. userJSONBytes2, _ := json.Marshal(respJSON2)
  8655. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8656. utils.ErrorLog("解析失败:%v", err)
  8657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8658. return
  8659. }
  8660. if res.Infcode == -1 {
  8661. c.ServeSuccessJSON(map[string]interface{}{
  8662. "failed_code": -10,
  8663. "msg": res.ErrMsg,
  8664. })
  8665. return
  8666. } else {
  8667. c.ServeSuccessJSON(map[string]interface{}{
  8668. "info": res.Output,
  8669. })
  8670. }
  8671. }
  8672. }
  8673. func (c *HisApiController) GetCFYLJG004() {
  8674. admin_user_id, _ := c.GetInt64("admin_user_id")
  8675. his_patient_id, _ := c.GetInt64("his_patient_id")
  8676. record_time := c.GetString("record_time")
  8677. admin_user_id = 3626
  8678. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8679. //id, _ := c.GetInt64("id")
  8680. admin_user_id = 3626
  8681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8683. flow, _ := service.Getflowtwo(his.Number)
  8684. //id = 3
  8685. patient_id, _ := c.GetInt64("patient_id")
  8686. //patient_id = 23834
  8687. //record_time = "2023-09-18"
  8688. timeLayout := "2006-01-02"
  8689. loc, _ := time.LoadLocation("Local")
  8690. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8691. if err != nil {
  8692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8693. return
  8694. }
  8695. recordDateTime := theTime.Unix()
  8696. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8697. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8698. var cFYLJG004 models.CFYLJG004
  8699. cFYLJG004.HiRxno = flow.HiRxno
  8700. cFYLJG004.FixmedinsCode = miConfig.Code
  8701. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8702. cFYLJG004.UndoDrCertType = "01"
  8703. cFYLJG004.UndoRea = "撤销处方"
  8704. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8705. cFYLJG004.UndoDrName = doctor_info.UserName
  8706. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8707. if miConfig.MdtrtareaAdmvs == "340699" {
  8708. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8709. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8710. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8711. } else {
  8712. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8713. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8714. var res ResultCFYLJG004
  8715. var respJSON2 map[string]interface{}
  8716. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8719. return
  8720. }
  8721. userJSONBytes2, _ := json.Marshal(respJSON2)
  8722. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8723. utils.ErrorLog("解析失败:%v", err)
  8724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8725. return
  8726. }
  8727. if res.Infcode == -1 {
  8728. c.ServeSuccessJSON(map[string]interface{}{
  8729. "failed_code": -10,
  8730. "msg": res.ErrMsg,
  8731. })
  8732. return
  8733. } else {
  8734. flow.Status = 0
  8735. service.Saveflow(flow)
  8736. c.ServeSuccessJSON(map[string]interface{}{
  8737. "msg": "撤销成功",
  8738. })
  8739. return
  8740. }
  8741. }
  8742. }
  8743. func (c *HisApiController) GetCFYLJG005() {
  8744. admin_user_id, _ := c.GetInt64("admin_user_id")
  8745. his_patient_id, _ := c.GetInt64("his_patient_id")
  8746. //record_time := c.GetString("record_time")
  8747. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8748. //id, _ := c.GetInt64("id")
  8749. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8751. flow, _ := service.Getflowtwo(his.Number)
  8752. //id = 3
  8753. var cFYLJG005 models.CFYLJG005
  8754. //patient_id, _ := c.GetInt64("patient_id")
  8755. cFYLJG005.HiRxno = flow.HiRxno
  8756. cFYLJG005.MdtrtID = flow.MID
  8757. cFYLJG005.EcToken = ""
  8758. cFYLJG005.PsnName = his.Name
  8759. cFYLJG005.PsnCertType = "01"
  8760. cFYLJG005.Certno = his.IdCardNo
  8761. if miConfig.MdtrtareaAdmvs == "340699" {
  8762. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8763. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8764. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8765. } else {
  8766. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8767. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8768. var res ResultCFYLJG005
  8769. var respJSON2 map[string]interface{}
  8770. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. userJSONBytes2, _ := json.Marshal(respJSON2)
  8776. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8777. utils.ErrorLog("解析失败:%v", err)
  8778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8779. return
  8780. }
  8781. if res.Infcode == -1 {
  8782. c.ServeSuccessJSON(map[string]interface{}{
  8783. "failed_code": -10,
  8784. "msg": res.ErrMsg,
  8785. })
  8786. return
  8787. } else {
  8788. c.ServeSuccessJSON(map[string]interface{}{
  8789. "info": res.Output,
  8790. })
  8791. return
  8792. }
  8793. }
  8794. }
  8795. func (c *HisApiController) GetCFYLJG006() {
  8796. admin_user_id, _ := c.GetInt64("admin_user_id")
  8797. his_patient_id, _ := c.GetInt64("his_patient_id")
  8798. admin_user_id = 3626
  8799. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8800. //id, _ := c.GetInt64("id")
  8801. admin_user_id = 3626
  8802. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8803. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8804. flow, _ := service.Getflowtwo(his.Number)
  8805. //id = 3
  8806. patient_id, _ := c.GetInt64("patient_id")
  8807. var cFYLJG006 models.CFYLJG006
  8808. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8809. cFYLJG006.HiRxno = flow.HiRxno
  8810. cFYLJG006.MdtrtID = flow.MID
  8811. cFYLJG006.PsnName = patient.Name
  8812. cFYLJG006.PsnCertType = "01"
  8813. cFYLJG006.Certno = patient.IdCardNo
  8814. if miConfig.MdtrtareaAdmvs == "340699" {
  8815. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8816. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8817. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8818. } else {
  8819. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8820. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8821. var res ResultCFYLJG006
  8822. var respJSON2 map[string]interface{}
  8823. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8826. return
  8827. }
  8828. userJSONBytes2, _ := json.Marshal(respJSON2)
  8829. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8830. utils.ErrorLog("解析失败:%v", err)
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8832. return
  8833. }
  8834. if res.Infcode == -1 {
  8835. c.ServeSuccessJSON(map[string]interface{}{
  8836. "failed_code": -10,
  8837. "msg": res.ErrMsg,
  8838. })
  8839. return
  8840. } else {
  8841. c.ServeSuccessJSON(map[string]interface{}{
  8842. "info": res.Output,
  8843. })
  8844. return
  8845. }
  8846. }
  8847. }
  8848. func (c *HisApiController) GetCFYLJG007() {
  8849. admin_user_id, _ := c.GetInt64("admin_user_id")
  8850. his_patient_id, _ := c.GetInt64("his_patient_id")
  8851. admin_user_id = 3626
  8852. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8853. //id, _ := c.GetInt64("id")
  8854. admin_user_id = 3626
  8855. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8857. flow, _ := service.Getflowtwo(his.Number)
  8858. //id = 3
  8859. patient_id, _ := c.GetInt64("patient_id")
  8860. var cFYLJG007 models.CFYLJG007
  8861. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8862. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8863. cFYLJG007.HiRxno = flow.HiRxno
  8864. cFYLJG007.MdtrtID = flow.MID
  8865. cFYLJG007.PsnNo = his.PsnNo
  8866. cFYLJG007.PsnCertType = "01"
  8867. cFYLJG007.Certno = patient.IdCardNo
  8868. cFYLJG007.PsnName = patient.Name
  8869. if miConfig.MdtrtareaAdmvs == "340699" {
  8870. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8871. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8872. } else {
  8873. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8874. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8875. var res ResultCFYLJG007
  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, &res); err != nil {
  8884. utils.ErrorLog("解析失败:%v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. if res.Infcode == -1 {
  8889. c.ServeSuccessJSON(map[string]interface{}{
  8890. "failed_code": -10,
  8891. "msg": res.ErrMsg,
  8892. })
  8893. return
  8894. } else {
  8895. c.ServeSuccessJSON(map[string]interface{}{
  8896. "info": res,
  8897. })
  8898. return
  8899. }
  8900. }
  8901. }
  8902. func (c *HisApiController) GetCFYLJG008() {
  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. var cFYLJG008 models.CFYLJG008
  8907. //id, _ := c.GetInt64("id")
  8908. patient_id, _ := c.GetInt64("patient_id")
  8909. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8910. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8911. //id = 3
  8912. //flow, _ := service.Getflow(id)
  8913. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8914. //
  8915. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8916. //patient_id, _ := c.GetInt64("patient_id")
  8917. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8918. record_time := c.GetString("record_time")
  8919. admin_user_id = 3626
  8920. patient_id = 19424
  8921. //his_patient_id = 263947
  8922. record_time = "2023-08-29"
  8923. timeLayout := "2006-01-02"
  8924. loc, _ := time.LoadLocation("Local")
  8925. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8926. if err != nil {
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8928. return
  8929. }
  8930. recordDateTime := theTime.Unix()
  8931. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8932. cFYLJG008.FixmedinsName = ""
  8933. cFYLJG008.Lat = ""
  8934. cFYLJG008.Lng = ""
  8935. cFYLJG008.OrderType = "1"
  8936. cFYLJG008.PoolareaNo = ""
  8937. cFYLJG008.Lng = ""
  8938. cFYLJG008.PageNum = 1
  8939. cFYLJG008.PageSize = 10
  8940. var MPI models.MedinsProdInvChgDDTO
  8941. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8942. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8943. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8944. if miConfig.MdtrtareaAdmvs == "340699" {
  8945. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8946. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8947. } else {
  8948. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8949. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8950. var res ResultCFYLJG008
  8951. var respJSON2 map[string]interface{}
  8952. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8955. return
  8956. }
  8957. userJSONBytes2, _ := json.Marshal(respJSON2)
  8958. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8959. utils.ErrorLog("解析失败:%v", err)
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8961. return
  8962. }
  8963. if res.Infcode == -1 {
  8964. c.ServeSuccessJSON(map[string]interface{}{
  8965. "failed_code": -10,
  8966. "msg": res.ErrMsg,
  8967. })
  8968. return
  8969. } else {
  8970. c.ServeSuccessJSON(map[string]interface{}{
  8971. "info": res.Output,
  8972. })
  8973. return
  8974. }
  8975. }
  8976. }
  8977. func (c *HisApiController) GetBL4201A() {
  8978. order_id, _ := c.GetInt64("order_id")
  8979. admin_user_id, _ := c.GetInt64("admin_user_id")
  8980. order, _ := service.GetHisOrderByIDTwo(order_id)
  8981. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8982. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8983. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8984. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8985. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8986. department, _ := service.GetDepartMentDetail(his.Departments)
  8987. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8988. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8989. if order.ID == 0 {
  8990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8991. return
  8992. }
  8993. var struct4201A models.Struct4201A
  8994. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8995. for _, items := range order_info {
  8996. memo := make(map[string]interface{})
  8997. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8998. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8999. fsiOPFLD.MedType = "14"
  9000. fsiOPFLD.BkkpSn = items.FeedetlSn
  9001. fsiOPFLD.FixmedinsCode = miConfig.Code
  9002. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9003. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9004. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9005. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9006. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9007. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9008. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9009. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9010. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9011. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9012. fsiOPFLD.BilgDeptName = department.Name
  9013. fsiOPFLD.BilgDeptCodg = department.Number
  9014. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9015. fsiOPFLD.BilgDrName = doctor.UserName
  9016. fsiOPFLD.MedChrgitmType = "09"
  9017. memo["hosp_appr_flag"] = "1"
  9018. memo["invoice_no"] = order.MdtrtId
  9019. memo["memo"] = "自费"
  9020. bytesData, _ := json.Marshal(memo)
  9021. fsiOPFLD.Memo = string(bytesData)
  9022. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9023. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9024. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9025. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9026. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9027. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9028. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9029. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9030. fsiOPFLD.BilgDeptName = department.Name
  9031. fsiOPFLD.BilgDeptCodg = department.Number
  9032. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9033. fsiOPFLD.BilgDrName = doctor.UserName
  9034. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9035. case 0:
  9036. break
  9037. case 1:
  9038. fsiOPFLD.MedChrgitmType = "14"
  9039. break
  9040. case 2:
  9041. fsiOPFLD.MedChrgitmType = "05"
  9042. break
  9043. case 3:
  9044. fsiOPFLD.MedChrgitmType = "03"
  9045. break
  9046. case 4:
  9047. fsiOPFLD.MedChrgitmType = "03"
  9048. break
  9049. case 5:
  9050. fsiOPFLD.MedChrgitmType = "08"
  9051. break
  9052. case 6:
  9053. fsiOPFLD.MedChrgitmType = "14"
  9054. break
  9055. case 7:
  9056. fsiOPFLD.MedChrgitmType = "14"
  9057. break
  9058. case 8:
  9059. fsiOPFLD.MedChrgitmType = "03"
  9060. break
  9061. case 9:
  9062. fsiOPFLD.MedChrgitmType = "14"
  9063. break
  9064. case 10:
  9065. fsiOPFLD.MedChrgitmType = "14"
  9066. break
  9067. case 11:
  9068. fsiOPFLD.MedChrgitmType = "06"
  9069. break
  9070. case 12:
  9071. fsiOPFLD.MedChrgitmType = "12"
  9072. break
  9073. case 13:
  9074. fsiOPFLD.MedChrgitmType = "01"
  9075. break
  9076. case 14:
  9077. fsiOPFLD.MedChrgitmType = "04"
  9078. break
  9079. case 15:
  9080. fsiOPFLD.MedChrgitmType = "14"
  9081. break
  9082. }
  9083. memo["hosp_appr_flag"] = "1"
  9084. memo["invoice_no"] = order.MdtrtId
  9085. memo["memo"] = "自费"
  9086. bytesData, _ := json.Marshal(memo)
  9087. fsiOPFLD.Memo = string(bytesData)
  9088. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9089. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9090. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9091. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9092. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9093. fsiOPFLD.BilgDeptName = department.Name
  9094. fsiOPFLD.BilgDeptCodg = department.Number
  9095. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9096. fsiOPFLD.BilgDrName = doctor.UserName
  9097. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9098. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9099. fsiOPFLD.MedChrgitmType = "08"
  9100. memo["hosp_appr_flag"] = "1"
  9101. memo["invoice_no"] = order.MdtrtId
  9102. memo["memo"] = "自费"
  9103. bytesData, _ := json.Marshal(memo)
  9104. fsiOPFLD.Memo = string(bytesData)
  9105. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9106. }
  9107. }
  9108. }
  9109. for _, items := range order_info_two {
  9110. memo := make(map[string]interface{})
  9111. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9112. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9113. fsiOPFLD.MedType = "14"
  9114. fsiOPFLD.BkkpSn = items.FeedetlSn
  9115. fsiOPFLD.FixmedinsCode = miConfig.Code
  9116. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9117. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9118. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9119. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9120. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9121. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9122. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9123. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9124. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9125. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9126. fsiOPFLD.BilgDeptName = department.Name
  9127. fsiOPFLD.BilgDeptCodg = department.Number
  9128. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9129. fsiOPFLD.BilgDrName = doctor.UserName
  9130. fsiOPFLD.MedChrgitmType = "09"
  9131. memo["hosp_appr_flag"] = "1"
  9132. memo["invoice_no"] = order.MdtrtId
  9133. memo["memo"] = "自费"
  9134. bytesData, _ := json.Marshal(memo)
  9135. fsiOPFLD.Memo = string(bytesData)
  9136. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9137. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9138. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9139. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9140. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9141. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9142. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9143. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9144. fsiOPFLD.BilgDeptName = department.Name
  9145. fsiOPFLD.BilgDeptCodg = department.Number
  9146. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9147. fsiOPFLD.BilgDrName = doctor.UserName
  9148. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9149. case 0:
  9150. break
  9151. case 1:
  9152. fsiOPFLD.MedChrgitmType = "14"
  9153. break
  9154. case 2:
  9155. fsiOPFLD.MedChrgitmType = "05"
  9156. break
  9157. case 3:
  9158. fsiOPFLD.MedChrgitmType = "03"
  9159. break
  9160. case 4:
  9161. fsiOPFLD.MedChrgitmType = "03"
  9162. break
  9163. case 5:
  9164. fsiOPFLD.MedChrgitmType = "08"
  9165. break
  9166. case 6:
  9167. fsiOPFLD.MedChrgitmType = "14"
  9168. break
  9169. case 7:
  9170. fsiOPFLD.MedChrgitmType = "14"
  9171. break
  9172. case 8:
  9173. fsiOPFLD.MedChrgitmType = "03"
  9174. break
  9175. case 9:
  9176. fsiOPFLD.MedChrgitmType = "14"
  9177. break
  9178. case 10:
  9179. fsiOPFLD.MedChrgitmType = "14"
  9180. break
  9181. case 11:
  9182. fsiOPFLD.MedChrgitmType = "06"
  9183. break
  9184. case 12:
  9185. fsiOPFLD.MedChrgitmType = "12"
  9186. break
  9187. case 13:
  9188. fsiOPFLD.MedChrgitmType = "01"
  9189. break
  9190. case 14:
  9191. fsiOPFLD.MedChrgitmType = "04"
  9192. break
  9193. case 15:
  9194. fsiOPFLD.MedChrgitmType = "14"
  9195. break
  9196. }
  9197. memo["hosp_appr_flag"] = "1"
  9198. memo["invoice_no"] = order.MdtrtId
  9199. memo["memo"] = "自费"
  9200. bytesData, _ := json.Marshal(memo)
  9201. fsiOPFLD.Memo = string(bytesData)
  9202. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9203. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9204. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9205. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9206. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9207. fsiOPFLD.BilgDeptName = department.Name
  9208. fsiOPFLD.BilgDeptCodg = department.Number
  9209. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9210. fsiOPFLD.BilgDrName = doctor.UserName
  9211. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9212. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9213. fsiOPFLD.MedChrgitmType = "08"
  9214. memo["hosp_appr_flag"] = "1"
  9215. memo["invoice_no"] = order.MdtrtId
  9216. memo["memo"] = "自费"
  9217. bytesData, _ := json.Marshal(memo)
  9218. fsiOPFLD.Memo = string(bytesData)
  9219. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9220. }
  9221. }
  9222. }
  9223. fmt.Println(fsiOPFLDs)
  9224. struct4201A.Fopfd = fsiOPFLDs
  9225. fmt.Println(struct4201A.Fopfd)
  9226. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9227. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9228. var res2 ResultSix
  9229. var respJSON2 map[string]interface{}
  9230. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9233. return
  9234. }
  9235. userJSONBytes2, _ := json.Marshal(respJSON2)
  9236. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9237. utils.ErrorLog("解析失败:%v", err)
  9238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9239. return
  9240. }
  9241. if res2.Infcode != 0 {
  9242. c.ServeSuccessJSON(map[string]interface{}{
  9243. "failed_code": -10,
  9244. "msg": res2.ErrMsg,
  9245. })
  9246. return
  9247. } else {
  9248. order.IsUploadOrderInfo = 1
  9249. service.UpdateOrder(order)
  9250. c.ServeSuccessJSON(map[string]interface{}{
  9251. "msg": "上传成功",
  9252. })
  9253. }
  9254. }
  9255. func (c *HisApiController) Get3103() {
  9256. admin_user_id, _ := c.GetInt64("admin_user_id")
  9257. warm_type, _ := c.GetInt64("warm_type")
  9258. fk_state, _ := c.GetInt64("fk_state")
  9259. warm_ids := c.GetString("warm_ids")
  9260. desc := c.GetString("desc")
  9261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9262. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9263. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9264. saveLog(result, requestLog, "3103", "反馈")
  9265. var res2 ResultSix3103
  9266. var respJSON2 map[string]interface{}
  9267. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9270. return
  9271. }
  9272. userJSONBytes2, _ := json.Marshal(respJSON2)
  9273. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9274. utils.ErrorLog("解析失败:%v", err)
  9275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9276. return
  9277. }
  9278. if res2.Infcode != 0 {
  9279. c.ServeSuccessJSON(map[string]interface{}{
  9280. "failed_code": -10,
  9281. "msg": res2.ErrMsg,
  9282. })
  9283. return
  9284. } else {
  9285. c.ServeSuccessJSON(map[string]interface{}{
  9286. "msg": "反馈成功",
  9287. })
  9288. return
  9289. }
  9290. }
  9291. func (c *HisApiController) Get4201A() {
  9292. order_id, _ := c.GetInt64("order_id")
  9293. admin_user_id, _ := c.GetInt64("admin_user_id")
  9294. order, _ := service.GetHisOrderByIDTwo(order_id)
  9295. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9296. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9297. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9298. //order_info = append(order_info, order_info_two...)
  9299. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9301. department, _ := service.GetDepartMentDetail(his.Departments)
  9302. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9303. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9304. if order.ID == 0 {
  9305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9306. return
  9307. }
  9308. var struct4201A models.Struct4201A
  9309. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9310. for _, items := range order_info {
  9311. memo := make(map[string]interface{})
  9312. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9313. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9314. fsiOPFLD.MedType = "14"
  9315. fsiOPFLD.BkkpSn = items.FeedetlSn
  9316. fsiOPFLD.FixmedinsCode = miConfig.Code
  9317. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9318. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9319. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9320. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9321. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9322. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9323. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9324. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9325. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9326. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9327. fsiOPFLD.BilgDeptName = department.Name
  9328. fsiOPFLD.BilgDeptCodg = department.Number
  9329. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9330. fsiOPFLD.BilgDrName = doctor.UserName
  9331. fsiOPFLD.MedChrgitmType = "09"
  9332. memo["hosp_appr_flag"] = "1"
  9333. memo["invoice_no"] = order.MdtrtId
  9334. memo["memo"] = "自费"
  9335. bytesData, _ := json.Marshal(memo)
  9336. fsiOPFLD.Memo = string(bytesData)
  9337. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9338. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9339. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9340. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9341. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9342. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9343. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9344. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9345. fsiOPFLD.BilgDeptName = department.Name
  9346. fsiOPFLD.BilgDeptCodg = department.Number
  9347. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9348. fsiOPFLD.BilgDrName = doctor.UserName
  9349. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9350. case 0:
  9351. break
  9352. case 1:
  9353. fsiOPFLD.MedChrgitmType = "14"
  9354. break
  9355. case 2:
  9356. fsiOPFLD.MedChrgitmType = "05"
  9357. break
  9358. case 3:
  9359. fsiOPFLD.MedChrgitmType = "03"
  9360. break
  9361. case 4:
  9362. fsiOPFLD.MedChrgitmType = "03"
  9363. break
  9364. case 5:
  9365. fsiOPFLD.MedChrgitmType = "08"
  9366. break
  9367. case 6:
  9368. fsiOPFLD.MedChrgitmType = "14"
  9369. break
  9370. case 7:
  9371. fsiOPFLD.MedChrgitmType = "14"
  9372. break
  9373. case 8:
  9374. fsiOPFLD.MedChrgitmType = "03"
  9375. break
  9376. case 9:
  9377. fsiOPFLD.MedChrgitmType = "14"
  9378. break
  9379. case 10:
  9380. fsiOPFLD.MedChrgitmType = "14"
  9381. break
  9382. case 11:
  9383. fsiOPFLD.MedChrgitmType = "06"
  9384. break
  9385. case 12:
  9386. fsiOPFLD.MedChrgitmType = "12"
  9387. break
  9388. case 13:
  9389. fsiOPFLD.MedChrgitmType = "01"
  9390. break
  9391. case 14:
  9392. fsiOPFLD.MedChrgitmType = "04"
  9393. break
  9394. case 15:
  9395. fsiOPFLD.MedChrgitmType = "14"
  9396. break
  9397. }
  9398. memo["hosp_appr_flag"] = "1"
  9399. memo["invoice_no"] = order.MdtrtId
  9400. memo["memo"] = "自费"
  9401. bytesData, _ := json.Marshal(memo)
  9402. fsiOPFLD.Memo = string(bytesData)
  9403. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9404. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9405. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9406. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9407. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9408. fsiOPFLD.BilgDeptName = department.Name
  9409. fsiOPFLD.BilgDeptCodg = department.Number
  9410. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9411. fsiOPFLD.BilgDrName = doctor.UserName
  9412. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9413. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9414. fsiOPFLD.MedChrgitmType = "08"
  9415. memo["hosp_appr_flag"] = "1"
  9416. memo["invoice_no"] = order.MdtrtId
  9417. memo["memo"] = "自费"
  9418. bytesData, _ := json.Marshal(memo)
  9419. fsiOPFLD.Memo = string(bytesData)
  9420. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9421. }
  9422. }
  9423. }
  9424. for _, items := range order_info_two {
  9425. memo := make(map[string]interface{})
  9426. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9427. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9428. fsiOPFLD.MedType = "14"
  9429. fsiOPFLD.BkkpSn = items.FeedetlSn
  9430. fsiOPFLD.FixmedinsCode = miConfig.Code
  9431. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9432. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9433. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9434. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9435. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9436. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9437. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9438. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9439. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9440. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9441. fsiOPFLD.BilgDeptName = department.Name
  9442. fsiOPFLD.BilgDeptCodg = department.Number
  9443. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9444. fsiOPFLD.BilgDrName = doctor.UserName
  9445. fsiOPFLD.MedChrgitmType = "09"
  9446. memo["hosp_appr_flag"] = "1"
  9447. memo["invoice_no"] = order.MdtrtId
  9448. memo["memo"] = "自费"
  9449. bytesData, _ := json.Marshal(memo)
  9450. fsiOPFLD.Memo = string(bytesData)
  9451. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9452. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9453. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9454. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9455. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9456. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9457. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9458. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9459. fsiOPFLD.BilgDeptName = department.Name
  9460. fsiOPFLD.BilgDeptCodg = department.Number
  9461. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9462. fsiOPFLD.BilgDrName = doctor.UserName
  9463. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9464. case 0:
  9465. break
  9466. case 1:
  9467. fsiOPFLD.MedChrgitmType = "14"
  9468. break
  9469. case 2:
  9470. fsiOPFLD.MedChrgitmType = "05"
  9471. break
  9472. case 3:
  9473. fsiOPFLD.MedChrgitmType = "03"
  9474. break
  9475. case 4:
  9476. fsiOPFLD.MedChrgitmType = "03"
  9477. break
  9478. case 5:
  9479. fsiOPFLD.MedChrgitmType = "08"
  9480. break
  9481. case 6:
  9482. fsiOPFLD.MedChrgitmType = "14"
  9483. break
  9484. case 7:
  9485. fsiOPFLD.MedChrgitmType = "14"
  9486. break
  9487. case 8:
  9488. fsiOPFLD.MedChrgitmType = "03"
  9489. break
  9490. case 9:
  9491. fsiOPFLD.MedChrgitmType = "14"
  9492. break
  9493. case 10:
  9494. fsiOPFLD.MedChrgitmType = "14"
  9495. break
  9496. case 11:
  9497. fsiOPFLD.MedChrgitmType = "06"
  9498. break
  9499. case 12:
  9500. fsiOPFLD.MedChrgitmType = "12"
  9501. break
  9502. case 13:
  9503. fsiOPFLD.MedChrgitmType = "01"
  9504. break
  9505. case 14:
  9506. fsiOPFLD.MedChrgitmType = "04"
  9507. break
  9508. case 15:
  9509. fsiOPFLD.MedChrgitmType = "14"
  9510. break
  9511. }
  9512. memo["hosp_appr_flag"] = "1"
  9513. memo["invoice_no"] = order.MdtrtId
  9514. memo["memo"] = "自费"
  9515. bytesData, _ := json.Marshal(memo)
  9516. fsiOPFLD.Memo = string(bytesData)
  9517. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9518. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9519. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9520. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9521. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9522. fsiOPFLD.BilgDeptName = department.Name
  9523. fsiOPFLD.BilgDeptCodg = department.Number
  9524. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9525. fsiOPFLD.BilgDrName = doctor.UserName
  9526. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9527. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9528. fsiOPFLD.MedChrgitmType = "08"
  9529. memo["hosp_appr_flag"] = "1"
  9530. memo["invoice_no"] = order.MdtrtId
  9531. memo["memo"] = "自费"
  9532. bytesData, _ := json.Marshal(memo)
  9533. fsiOPFLD.Memo = string(bytesData)
  9534. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9535. }
  9536. }
  9537. }
  9538. fmt.Println(fsiOPFLDs)
  9539. struct4201A.Fopfd = fsiOPFLDs
  9540. fmt.Println(struct4201A.Fopfd)
  9541. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9542. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9543. var res2 ResultSix
  9544. var respJSON2 map[string]interface{}
  9545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. userJSONBytes2, _ := json.Marshal(respJSON2)
  9551. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9552. utils.ErrorLog("解析失败:%v", err)
  9553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9554. return
  9555. }
  9556. if res2.Infcode != 0 {
  9557. c.ServeSuccessJSON(map[string]interface{}{
  9558. "failed_code": -10,
  9559. "msg": res2.ErrMsg,
  9560. })
  9561. return
  9562. } else {
  9563. order.IsUploadOrderInfo = 1
  9564. service.UpdateOrder(order)
  9565. c.ServeSuccessJSON(map[string]interface{}{
  9566. "msg": "上传成功",
  9567. })
  9568. }
  9569. }
  9570. func (c *HisApiController) Get4202() {
  9571. order_id, _ := c.GetInt64("order_id")
  9572. admin_user_id, _ := c.GetInt64("admin_user_id")
  9573. order, _ := service.GetHisOrderByIDTwo(order_id)
  9574. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9575. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9577. if order.ID == 0 {
  9578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9579. return
  9580. }
  9581. var struct4202 models.Struct4202
  9582. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9583. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9584. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9585. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9586. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9587. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9588. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9589. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9590. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9591. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9592. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9593. var config []*models.HisXtDiagnoseConfig
  9594. for _, item := range diagnosis_ids {
  9595. id, _ := strconv.ParseInt(item, 10, 64)
  9596. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9597. config = append(config, &diagnosisConfig)
  9598. }
  9599. var tempDiaginfos []models.OwnPayPatnDiagListD
  9600. for index, item := range config {
  9601. if index == 0 {
  9602. var tempDiaginfo models.OwnPayPatnDiagListD
  9603. tempDiaginfo.InoutDiagType = "1"
  9604. tempDiaginfo.DiagCode = item.CountryCode
  9605. tempDiaginfo.DiagName = item.CountryContentName
  9606. tempDiaginfo.DiagType = "1"
  9607. tempDiaginfo.DiagSrtNo = "1"
  9608. tempDiaginfo.MaindiagFlag = "1"
  9609. tempDiaginfo.ValiFlag = "1"
  9610. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9611. } else {
  9612. var tempDiaginfo models.OwnPayPatnDiagListD
  9613. tempDiaginfo.DiagCode = item.CountryCode
  9614. tempDiaginfo.DiagName = item.CountryContentName
  9615. tempDiaginfo.DiagType = "2"
  9616. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9617. tempDiaginfo.MaindiagFlag = "0"
  9618. tempDiaginfo.ValiFlag = "1"
  9619. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9620. }
  9621. }
  9622. struct4202.ODiagListD = tempDiaginfos
  9623. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9624. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9625. var res2 ResultSix
  9626. var respJSON2 map[string]interface{}
  9627. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9630. return
  9631. }
  9632. userJSONBytes2, _ := json.Marshal(respJSON2)
  9633. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9634. utils.ErrorLog("解析失败:%v", err)
  9635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9636. return
  9637. }
  9638. if res2.Infcode != 0 {
  9639. c.ServeSuccessJSON(map[string]interface{}{
  9640. "failed_code": -10,
  9641. "msg": res2.ErrMsg,
  9642. })
  9643. return
  9644. } else {
  9645. order.IsUploadDiagnose = 1
  9646. service.UpdateOrder(order)
  9647. c.ServeSuccessJSON(map[string]interface{}{
  9648. "msg": "上传成功",
  9649. })
  9650. }
  9651. }
  9652. func (c *HisApiController) Get4203() {
  9653. admin_user_id, _ := c.GetInt64("admin_user_id")
  9654. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9655. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9656. order_id, _ := c.GetInt64("order_id")
  9657. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9658. number := ""
  9659. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9660. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9661. if his.ID == 0 {
  9662. number = hospital.Number
  9663. } else {
  9664. number = his.Number
  9665. }
  9666. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9667. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9668. var res2 ResultSix
  9669. var respJSON2 map[string]interface{}
  9670. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9673. return
  9674. }
  9675. userJSONBytes2, _ := json.Marshal(respJSON2)
  9676. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9677. utils.ErrorLog("解析失败:%v", err)
  9678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9679. return
  9680. }
  9681. if res2.Infcode != 0 {
  9682. c.ServeSuccessJSON(map[string]interface{}{
  9683. "failed_code": -10,
  9684. "msg": res2.ErrMsg,
  9685. })
  9686. return
  9687. } else {
  9688. order.IsUploadSuccess = 1
  9689. service.UpdateOrderTwo(order)
  9690. c.ServeSuccessJSON(map[string]interface{}{
  9691. "msg": "上传成功",
  9692. })
  9693. }
  9694. }
  9695. func (c *HisApiController) Get4205() {
  9696. order_id, _ := c.GetInt64("order_id")
  9697. admin_user_id, _ := c.GetInt64("admin_user_id")
  9698. fapiao_code := c.GetString("fapiao_code")
  9699. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9700. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9701. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9702. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9703. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9704. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9705. //order_info = append(order_info, order_info_two...)
  9706. department, _ := service.GetDepartMentDetail(his.Departments)
  9707. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9708. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9709. if order.ID == 0 {
  9710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9711. return
  9712. }
  9713. var struct4201A models.Struct4201A
  9714. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9715. for _, items := range order_info {
  9716. memo := make(map[string]interface{})
  9717. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9718. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9719. fsiOPFLD.MedType = pre.MedType
  9720. fsiOPFLD.FixmedinsCode = miConfig.Code
  9721. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9722. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9723. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9724. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt*items.Pric)
  9725. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9726. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9727. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9728. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9729. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9730. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9731. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9732. fsiOPFLD.BilgDeptName = department.Name
  9733. fsiOPFLD.BilgDeptCodg = department.Number
  9734. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9735. fsiOPFLD.BilgDrName = doctor.UserName
  9736. fsiOPFLD.MedChrgitmType = "09"
  9737. memo["hosp_appr_flag"] = "1"
  9738. memo["invoice_no"] = fapiao_code
  9739. memo["memo"] = "自费"
  9740. bytesData, _ := json.Marshal(memo)
  9741. fsiOPFLD.Memo = string(bytesData)
  9742. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9743. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9744. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9745. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9746. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9747. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9748. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9749. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9750. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9751. fsiOPFLD.BilgDeptName = department.Name
  9752. fsiOPFLD.BilgDeptCodg = department.Number
  9753. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9754. fsiOPFLD.BilgDrName = doctor.UserName
  9755. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9756. case 0:
  9757. break
  9758. case 1:
  9759. fsiOPFLD.MedChrgitmType = "14"
  9760. break
  9761. case 2:
  9762. fsiOPFLD.MedChrgitmType = "05"
  9763. break
  9764. case 3:
  9765. fsiOPFLD.MedChrgitmType = "03"
  9766. break
  9767. case 4:
  9768. fsiOPFLD.MedChrgitmType = "03"
  9769. break
  9770. case 5:
  9771. fsiOPFLD.MedChrgitmType = "08"
  9772. break
  9773. case 6:
  9774. fsiOPFLD.MedChrgitmType = "14"
  9775. break
  9776. case 7:
  9777. fsiOPFLD.MedChrgitmType = "14"
  9778. break
  9779. case 8:
  9780. fsiOPFLD.MedChrgitmType = "03"
  9781. break
  9782. case 9:
  9783. fsiOPFLD.MedChrgitmType = "14"
  9784. break
  9785. case 10:
  9786. fsiOPFLD.MedChrgitmType = "14"
  9787. break
  9788. case 11:
  9789. fsiOPFLD.MedChrgitmType = "06"
  9790. break
  9791. case 12:
  9792. fsiOPFLD.MedChrgitmType = "12"
  9793. break
  9794. case 13:
  9795. fsiOPFLD.MedChrgitmType = "01"
  9796. break
  9797. case 14:
  9798. fsiOPFLD.MedChrgitmType = "04"
  9799. break
  9800. case 15:
  9801. fsiOPFLD.MedChrgitmType = "14"
  9802. break
  9803. }
  9804. memo["hosp_appr_flag"] = "1"
  9805. memo["invoice_no"] = fapiao_code
  9806. memo["memo"] = "自费"
  9807. bytesData, _ := json.Marshal(memo)
  9808. fsiOPFLD.Memo = string(bytesData)
  9809. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9810. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9811. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9812. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9813. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9814. fsiOPFLD.BilgDeptName = department.Name
  9815. fsiOPFLD.BilgDeptCodg = department.Number
  9816. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9817. fsiOPFLD.BilgDrName = doctor.UserName
  9818. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9819. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9820. fsiOPFLD.MedChrgitmType = "08"
  9821. memo["hosp_appr_flag"] = "1"
  9822. memo["invoice_no"] = fapiao_code
  9823. memo["memo"] = "自费"
  9824. bytesData, _ := json.Marshal(memo)
  9825. fsiOPFLD.Memo = string(bytesData)
  9826. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9827. }
  9828. }
  9829. }
  9830. for _, items := range order_info_two {
  9831. memo := make(map[string]interface{})
  9832. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9833. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9834. fsiOPFLD.MedType = pre.MedType
  9835. fsiOPFLD.BkkpSn = items.FeedetlSn
  9836. fsiOPFLD.FixmedinsCode = miConfig.Code
  9837. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9838. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9839. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9840. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt*items.Pric)
  9841. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9842. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9843. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9844. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9845. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9846. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9847. fsiOPFLD.BilgDeptName = department.Name
  9848. fsiOPFLD.BilgDeptCodg = department.Number
  9849. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9850. fsiOPFLD.BilgDrName = doctor.UserName
  9851. fsiOPFLD.MedChrgitmType = "09"
  9852. memo["hosp_appr_flag"] = "1"
  9853. memo["invoice_no"] = fapiao_code
  9854. memo["memo"] = "自费"
  9855. bytesData, _ := json.Marshal(memo)
  9856. fsiOPFLD.Memo = string(bytesData)
  9857. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9858. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9859. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9860. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9861. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9862. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9863. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9864. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9865. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9866. fsiOPFLD.BilgDeptName = department.Name
  9867. fsiOPFLD.BilgDeptCodg = department.Number
  9868. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9869. fsiOPFLD.BilgDrName = doctor.UserName
  9870. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9871. case 0:
  9872. break
  9873. case 1:
  9874. fsiOPFLD.MedChrgitmType = "14"
  9875. break
  9876. case 2:
  9877. fsiOPFLD.MedChrgitmType = "05"
  9878. break
  9879. case 3:
  9880. fsiOPFLD.MedChrgitmType = "03"
  9881. break
  9882. case 4:
  9883. fsiOPFLD.MedChrgitmType = "03"
  9884. break
  9885. case 5:
  9886. fsiOPFLD.MedChrgitmType = "08"
  9887. break
  9888. case 6:
  9889. fsiOPFLD.MedChrgitmType = "14"
  9890. break
  9891. case 7:
  9892. fsiOPFLD.MedChrgitmType = "14"
  9893. break
  9894. case 8:
  9895. fsiOPFLD.MedChrgitmType = "03"
  9896. break
  9897. case 9:
  9898. fsiOPFLD.MedChrgitmType = "14"
  9899. break
  9900. case 10:
  9901. fsiOPFLD.MedChrgitmType = "14"
  9902. break
  9903. case 11:
  9904. fsiOPFLD.MedChrgitmType = "06"
  9905. break
  9906. case 12:
  9907. fsiOPFLD.MedChrgitmType = "12"
  9908. break
  9909. case 13:
  9910. fsiOPFLD.MedChrgitmType = "01"
  9911. break
  9912. case 14:
  9913. fsiOPFLD.MedChrgitmType = "04"
  9914. break
  9915. case 15:
  9916. fsiOPFLD.MedChrgitmType = "14"
  9917. break
  9918. }
  9919. memo["hosp_appr_flag"] = "1"
  9920. memo["invoice_no"] = fapiao_code
  9921. memo["memo"] = "自费"
  9922. bytesData, _ := json.Marshal(memo)
  9923. fsiOPFLD.Memo = string(bytesData)
  9924. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9925. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9926. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9927. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9928. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9929. fsiOPFLD.BilgDeptName = department.Name
  9930. fsiOPFLD.BilgDeptCodg = department.Number
  9931. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9932. fsiOPFLD.BilgDrName = doctor.UserName
  9933. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9934. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9935. fsiOPFLD.MedChrgitmType = "08"
  9936. memo["hosp_appr_flag"] = "1"
  9937. memo["invoice_no"] = fapiao_code
  9938. memo["memo"] = "自费"
  9939. bytesData, _ := json.Marshal(memo)
  9940. fsiOPFLD.Memo = string(bytesData)
  9941. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9942. }
  9943. }
  9944. }
  9945. fmt.Println(fsiOPFLDs)
  9946. struct4201A.Fopfd = fsiOPFLDs
  9947. fmt.Println(struct4201A.Fopfd)
  9948. var struct4202 models.Struct4202
  9949. timeLayout := "2006-01-02 15:04:05"
  9950. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9951. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9952. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9953. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9954. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9955. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9956. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9957. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9958. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9959. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9960. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9961. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9962. var config []*models.HisXtDiagnoseConfig
  9963. for _, item := range diagnosis_ids {
  9964. id, _ := strconv.ParseInt(item, 10, 64)
  9965. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9966. config = append(config, &diagnosisConfig)
  9967. }
  9968. var tempDiaginfos []models.OwnPayPatnDiagListD
  9969. for index, item := range config {
  9970. if index == 0 {
  9971. var tempDiaginfo models.OwnPayPatnDiagListD
  9972. tempDiaginfo.InoutDiagType = "1"
  9973. tempDiaginfo.DiagCode = item.CountryCode
  9974. tempDiaginfo.DiagName = item.CountryContentName
  9975. tempDiaginfo.DiagType = "1"
  9976. tempDiaginfo.DiagSrtNo = "1"
  9977. tempDiaginfo.MaindiagFlag = "1"
  9978. tempDiaginfo.ValiFlag = "1"
  9979. tempDiaginfo.DiagDrName = doctor.UserName
  9980. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9981. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9982. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9983. } else {
  9984. var tempDiaginfo models.OwnPayPatnDiagListD
  9985. tempDiaginfo.DiagCode = item.CountryCode
  9986. tempDiaginfo.DiagName = item.CountryContentName
  9987. tempDiaginfo.DiagType = "2"
  9988. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9989. tempDiaginfo.MaindiagFlag = "0"
  9990. tempDiaginfo.ValiFlag = "1"
  9991. tempDiaginfo.DiagDrName = doctor.UserName
  9992. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9993. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9994. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9995. }
  9996. }
  9997. struct4202.ODiagListD = tempDiaginfos
  9998. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9999. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  10000. var res2 ResultSix
  10001. var respJSON2 map[string]interface{}
  10002. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. userJSONBytes2, _ := json.Marshal(respJSON2)
  10008. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10009. utils.ErrorLog("解析失败:%v", err)
  10010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10011. return
  10012. }
  10013. if res2.Infcode != 0 {
  10014. c.ServeSuccessJSON(map[string]interface{}{
  10015. "failed_code": -10,
  10016. "msg": res2.ErrMsg,
  10017. })
  10018. return
  10019. } else {
  10020. order.IsUploadDiagnose = 1
  10021. order.IsUploadOrderInfo = 1
  10022. service.UpdateOrderTwo(order)
  10023. c.ServeSuccessJSON(map[string]interface{}{
  10024. "msg": "上传成功",
  10025. })
  10026. }
  10027. }
  10028. func (c *HisApiController) Get4207() {
  10029. admin_user_id, _ := c.GetInt64("admin_user_id")
  10030. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10031. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10032. order_id, _ := c.GetInt64("order_id")
  10033. order, _ := service.GetHisOrderByIDTwo(order_id)
  10034. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10035. var struct4207 models.Struct4207
  10036. struct4207.PageNum = "1"
  10037. struct4207.PageSize = "1000"
  10038. struct4207.FixmedinsCode = miConfig.Code
  10039. struct4207.FixmedinsMdtrtID = order.Number
  10040. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  10041. saveLog(result, requestLog, "4207", "查询")
  10042. var res2 ResultSix
  10043. var respJSON2 map[string]interface{}
  10044. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10047. return
  10048. }
  10049. userJSONBytes2, _ := json.Marshal(respJSON2)
  10050. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10051. utils.ErrorLog("解析失败:%v", err)
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10053. return
  10054. }
  10055. if res2.Infcode != 0 {
  10056. c.ServeSuccessJSON(map[string]interface{}{
  10057. "failed_code": -10,
  10058. "msg": res2.ErrMsg,
  10059. })
  10060. return
  10061. } else {
  10062. c.ServeSuccessJSON(map[string]interface{}{
  10063. "msg": "查询成功",
  10064. })
  10065. }
  10066. }
  10067. func (c *HisApiController) Get4208() {
  10068. admin_user_id, _ := c.GetInt64("admin_user_id")
  10069. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10070. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10071. order_id, _ := c.GetInt64("order_id")
  10072. order, _ := service.GetHisOrderByIDTwo(order_id)
  10073. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10074. var struct4208 models.Struct4208
  10075. struct4208.PageNum = "1"
  10076. struct4208.PageSize = "1000"
  10077. struct4208.PsnCertType = "01"
  10078. struct4208.Certno = his.Certno
  10079. struct4208.MedType = order.MedType
  10080. struct4208.PsnName = his.Name
  10081. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  10082. saveLog(result, requestLog, "4208", "查询")
  10083. var res2 ResultSix
  10084. var respJSON2 map[string]interface{}
  10085. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10088. return
  10089. }
  10090. userJSONBytes2, _ := json.Marshal(respJSON2)
  10091. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10092. utils.ErrorLog("解析失败:%v", err)
  10093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10094. return
  10095. }
  10096. if res2.Infcode != 0 {
  10097. c.ServeSuccessJSON(map[string]interface{}{
  10098. "failed_code": -10,
  10099. "msg": res2.ErrMsg,
  10100. })
  10101. return
  10102. } else {
  10103. c.ServeSuccessJSON(map[string]interface{}{
  10104. "msg": "查询成功",
  10105. })
  10106. }
  10107. }
  10108. func (c *HisApiController) Get4209() {
  10109. admin_user_id, _ := c.GetInt64("admin_user_id")
  10110. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10112. order_id, _ := c.GetInt64("order_id")
  10113. order, _ := service.GetHisOrderByIDTwo(order_id)
  10114. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10115. var struct4209 models.Struct4209
  10116. struct4209.FixmedinsMdtrtID = order.Number
  10117. struct4209.FixmedinsCode = miConfig.Code
  10118. struct4209.PageSize = "1000"
  10119. struct4209.PageNum = "1"
  10120. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10121. saveLog(result, requestLog, "4209", "查询")
  10122. var res2 ResultSix
  10123. var respJSON2 map[string]interface{}
  10124. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10127. return
  10128. }
  10129. userJSONBytes2, _ := json.Marshal(respJSON2)
  10130. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10131. utils.ErrorLog("解析失败:%v", err)
  10132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. return
  10134. }
  10135. if res2.Infcode != 0 {
  10136. c.ServeSuccessJSON(map[string]interface{}{
  10137. "failed_code": -10,
  10138. "msg": res2.ErrMsg,
  10139. })
  10140. return
  10141. } else {
  10142. c.ServeSuccessJSON(map[string]interface{}{
  10143. "msg": "查询成功",
  10144. })
  10145. }
  10146. }
  10147. type Result3101 struct {
  10148. Infcode string `json:"infcode"`
  10149. InfRefmsgid string `json:"inf_refmsgid"`
  10150. RefmsgTime string `json:"refmsg_time"`
  10151. RespondTime string `json:"respond_time"`
  10152. Enctype string `json:"enctype"`
  10153. Signtype string `json:"signtype"`
  10154. ErrMsg string `json:"err_msg"`
  10155. Output struct {
  10156. Result []struct {
  10157. JudgeResultDetailDtos []struct {
  10158. VolaItemType string `json:"vola_item_type"`
  10159. MdtrtID string `json:"mdtrt_id"`
  10160. JrdID string `json:"jrd_id"`
  10161. PatnID string `json:"patn_id"`
  10162. RxID string `json:"rx_id"`
  10163. VolaAmt interface{} `json:"vola_amt"`
  10164. } `json:"judge_result_detail_dtos"`
  10165. RuleID string `json:"rule_id"`
  10166. VolaEvid string `json:"vola_evid"`
  10167. MdtrtID string `json:"mdtrt_id"`
  10168. RuleName string `json:"rule_name"`
  10169. VolaAmtStas string `json:"vola_amt_stas"`
  10170. JrID string `json:"jr_id"`
  10171. PatnID string `json:"patn_id"`
  10172. SevDeg string `json:"sev_deg"`
  10173. VolaAmt float64 `json:"vola_amt"`
  10174. VolaBhvrType string `json:"vola_bhvr_type"`
  10175. VolaCont string `json:"vola_cont"`
  10176. } `json:"result"`
  10177. } `json:"output"`
  10178. }
  10179. type Resultgd3101 struct {
  10180. Infcode int64 `json:"infcode"`
  10181. InfRefmsgid string `json:"inf_refmsgid"`
  10182. RefmsgTime string `json:"refmsg_time"`
  10183. RespondTime string `json:"respond_time"`
  10184. Enctype string `json:"enctype"`
  10185. Signtype string `json:"signtype"`
  10186. ErrMsg string `json:"err_msg"`
  10187. Output struct {
  10188. Result []struct {
  10189. JudgeResultDetailDtos []struct {
  10190. VolaItemType string `json:"vola_item_type"`
  10191. MdtrtID string `json:"mdtrt_id"`
  10192. JrdID string `json:"jrd_id"`
  10193. PatnID string `json:"patn_id"`
  10194. RxID string `json:"rx_id"`
  10195. VolaAmt interface{} `json:"vola_amt"`
  10196. } `json:"judge_result_detail_dtos"`
  10197. RuleID string `json:"rule_id"`
  10198. VolaEvid string `json:"vola_evid"`
  10199. MdtrtID string `json:"mdtrt_id"`
  10200. RuleName string `json:"rule_name"`
  10201. VolaAmtStas string `json:"vola_amt_stas"`
  10202. JrID string `json:"jr_id"`
  10203. PatnID string `json:"patn_id"`
  10204. SevDeg string `json:"sev_deg"`
  10205. VolaAmt float64 `json:"vola_amt"`
  10206. VolaBhvrType string `json:"vola_bhvr_type"`
  10207. VolaCont string `json:"vola_cont"`
  10208. } `json:"result"`
  10209. } `json:"output"`
  10210. }
  10211. func (c *HisApiController) ReadEleToken() {
  10212. admin_user_id, _ := c.GetInt64("admin_user_id")
  10213. his_patient_id, _ := c.GetInt64("his_patient_id")
  10214. adminUser := c.GetAdminUserInfo()
  10215. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10216. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10217. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10218. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10219. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10220. if len(tokens) > 0 {
  10221. c.ServeSuccessJSON(map[string]interface{}{
  10222. "msg": "读取成功",
  10223. })
  10224. } else {
  10225. c.ServeSuccessJSON(map[string]interface{}{
  10226. "failed_code": -10,
  10227. "msg": "读取失败",
  10228. })
  10229. }
  10230. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10231. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10232. if len(tokens) > 0 {
  10233. c.ServeSuccessJSON(map[string]interface{}{
  10234. "msg": "读取成功",
  10235. })
  10236. } else {
  10237. c.ServeSuccessJSON(map[string]interface{}{
  10238. "failed_code": -10,
  10239. "msg": "读取失败",
  10240. })
  10241. }
  10242. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10243. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10244. if len(tokens) > 0 {
  10245. c.ServeSuccessJSON(map[string]interface{}{
  10246. "msg": "读取成功",
  10247. })
  10248. } else {
  10249. c.ServeSuccessJSON(map[string]interface{}{
  10250. "failed_code": -10,
  10251. "msg": "读取失败",
  10252. })
  10253. }
  10254. } else if miConfig.MdtrtareaAdmvs == "150404" {
  10255. var api string
  10256. 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 +
  10257. "&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"
  10258. resp, requestErr := http.Get(api)
  10259. if requestErr != nil {
  10260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10261. }
  10262. body, ioErr := ioutil.ReadAll(resp.Body)
  10263. if ioErr != nil {
  10264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10266. }
  10267. var respJSON map[string]interface{}
  10268. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. var status string
  10274. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10275. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10276. var token string
  10277. var res ResultTwo //1101结果
  10278. var res10265 ResultTwo10265 //1101结果
  10279. if status == "0" { //读卡成功
  10280. var card_info string //卡信息
  10281. var busi_card_info string
  10282. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10283. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10284. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10285. fmt.Println(card_info)
  10286. fmt.Println(busi_card_info)
  10287. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10288. result, _ := json.Marshal(respJSON)
  10289. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10290. utils.ErrorLog("解析失败:%v", err)
  10291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10292. return
  10293. }
  10294. res.ErrMsg = res10265.ErrMsg
  10295. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10296. res.Infcode = infocode
  10297. res.Output = res10265.Output
  10298. res.InfRefmsgid = res10265.InfRefmsgid
  10299. if res.Infcode == 0 {
  10300. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10301. if err == gorm.ErrRecordNotFound {
  10302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10303. return
  10304. } else if err != nil {
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10306. return
  10307. } else {
  10308. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10309. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10310. infoStr := string(Iinfos)
  10311. idetinfoStr := string(Idetinfos)
  10312. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10313. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10314. psn := &models.HisPsn{
  10315. PsnNo: res.Output.Baseinfo.PsnNo,
  10316. PatientId: patient.ID,
  10317. Certno: res.Output.Baseinfo.Certno,
  10318. Gend: res.Output.Baseinfo.Gend,
  10319. Naty: res.Output.Baseinfo.Naty,
  10320. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10321. PsnName: res.Output.Baseinfo.PsnName,
  10322. Age: float64(age),
  10323. Brdy: b,
  10324. Idetinfo: idetinfoStr,
  10325. Insuinfo: infoStr,
  10326. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10327. CardInfo: card_info,
  10328. VerifyNumber: token,
  10329. IdCardType: 4,
  10330. }
  10331. var rf []*ResultFive
  10332. json.Unmarshal([]byte(infoStr), &rf)
  10333. var insutypes []*ResultFive
  10334. var insutype string
  10335. var is390 int = 0
  10336. var is310 int = 0
  10337. for _, item := range rf {
  10338. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10339. insutypes = append(insutypes, item)
  10340. }
  10341. }
  10342. if len(insutypes) == 1 {
  10343. insutype = insutypes[0].Insutype
  10344. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10345. } else {
  10346. for _, i := range insutypes {
  10347. if i.Insutype == "390" {
  10348. is390 = 1
  10349. }
  10350. if i.Insutype == "310" {
  10351. is310 = 1
  10352. }
  10353. }
  10354. }
  10355. if is390 == 1 {
  10356. insutype = "390"
  10357. }
  10358. if is310 == 1 {
  10359. insutype = "310"
  10360. }
  10361. if len(insutypes) == 0 {
  10362. insutype = "310"
  10363. }
  10364. service.CreateHisPsn(psn)
  10365. c.ServeSuccessJSON(map[string]interface{}{
  10366. "patient": patient,
  10367. "number": token,
  10368. "insutype": insutype,
  10369. })
  10370. }
  10371. } else {
  10372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10373. return
  10374. }
  10375. } else { //读卡失败
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10377. return
  10378. }
  10379. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10380. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10381. if len(errMsg) == 0 {
  10382. type ELeData struct {
  10383. Data struct {
  10384. IdNo string `json:"idNo"`
  10385. IdType string `json:"idType"`
  10386. UserName string `json:"userName"`
  10387. EcToken string `json:"ecToken"`
  10388. InsuOrg string `json:"insuOrg"`
  10389. Gender string `json:"gender"`
  10390. Birthday string `json:"birthday"`
  10391. Nationality string `json:"nationality"`
  10392. Email string `json:"email"`
  10393. Extra string `json:"extra"`
  10394. } `json:"data"`
  10395. Code int `json:"code"`
  10396. Message string `json:"message"`
  10397. }
  10398. var ele ELeData
  10399. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10400. if err != nil {
  10401. utils.ErrorLog("解析失败:%v", err)
  10402. }
  10403. token := ele.Data.EcToken
  10404. if len(token) > 0 {
  10405. psn := &models.HisPsn{
  10406. PsnNo: his.PsnNo,
  10407. Age: 0,
  10408. PatientId: his.PatientId,
  10409. Certno: his.Certno,
  10410. Brdy: his.Brdy,
  10411. Gend: his.Gend,
  10412. Naty: his.Naty,
  10413. PsnCertType: his.PsnCertType,
  10414. PsnName: his.PsnName,
  10415. Idetinfo: his.Idetinfo,
  10416. Insuinfo: his.Iinfo,
  10417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10418. CardInfo: outPutInfo,
  10419. VerifyNumber: token,
  10420. }
  10421. service.CreateHisPsn(psn)
  10422. }
  10423. if len(token) > 0 {
  10424. c.ServeSuccessJSON(map[string]interface{}{
  10425. "msg": "读取成功",
  10426. })
  10427. } else {
  10428. c.ServeSuccessJSON(map[string]interface{}{
  10429. "failed_code": -10,
  10430. "msg": "读取失败",
  10431. })
  10432. }
  10433. }
  10434. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10435. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10436. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10437. type ELeData struct {
  10438. Data struct {
  10439. IdNo string `json:"idNo"`
  10440. IdType string `json:"idType"`
  10441. UserName string `json:"userName"`
  10442. EcToken string `json:"ecToken"`
  10443. InsuOrg string `json:"insuOrg"`
  10444. Gender string `json:"gender"`
  10445. Birthday string `json:"birthday"`
  10446. Nationality string `json:"nationality"`
  10447. Email string `json:"email"`
  10448. Extra string `json:"extra"`
  10449. } `json:"data"`
  10450. Code int `json:"code"`
  10451. Message string `json:"message"`
  10452. }
  10453. var ele ELeData
  10454. err := json.Unmarshal([]byte(result), &ele)
  10455. if err != nil {
  10456. utils.ErrorLog("解析失败:%v", err)
  10457. }
  10458. token := ele.Data.EcToken
  10459. token = Remove0000(token)
  10460. fmt.Println(ele.Data.UserName)
  10461. 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)
  10462. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10463. var res ResultTwo
  10464. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10465. utils.ErrorLog("解析失败:%v", err)
  10466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10467. return
  10468. }
  10469. if res.Infcode == 0 {
  10470. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10471. if err == gorm.ErrRecordNotFound {
  10472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10473. return
  10474. } else if err != nil {
  10475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10476. return
  10477. } else {
  10478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10480. infoStr := string(Iinfos)
  10481. idetinfoStr := string(Idetinfos)
  10482. psn := &models.HisPsn{
  10483. PsnNo: res.Output.Baseinfo.PsnNo,
  10484. PatientId: patient.ID,
  10485. Certno: res.Output.Baseinfo.Certno,
  10486. Gend: res.Output.Baseinfo.Gend,
  10487. Naty: res.Output.Baseinfo.Naty,
  10488. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10489. PsnName: res.Output.Baseinfo.PsnName,
  10490. Idetinfo: idetinfoStr,
  10491. Insuinfo: infoStr,
  10492. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10493. CardInfo: "",
  10494. VerifyNumber: token,
  10495. }
  10496. service.CreateHisPsn(psn)
  10497. c.ServeSuccessJSON(map[string]interface{}{
  10498. "patient": patient,
  10499. "number": token,
  10500. })
  10501. }
  10502. } else {
  10503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10504. return
  10505. }
  10506. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10507. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10508. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10509. type ELeData struct {
  10510. Data struct {
  10511. IdNo string `json:"idNo"`
  10512. IdType string `json:"idType"`
  10513. UserName string `json:"userName"`
  10514. EcToken string `json:"ecToken"`
  10515. InsuOrg string `json:"insuOrg"`
  10516. Gender string `json:"gender"`
  10517. Birthday string `json:"birthday"`
  10518. Nationality string `json:"nationality"`
  10519. Email string `json:"email"`
  10520. Extra string `json:"extra"`
  10521. } `json:"data"`
  10522. Code int `json:"code"`
  10523. Message string `json:"message"`
  10524. }
  10525. var ele ELeData
  10526. err := json.Unmarshal([]byte(result), &ele)
  10527. if err != nil {
  10528. utils.ErrorLog("解析失败:%v", err)
  10529. }
  10530. token := ele.Data.EcToken
  10531. token = Remove0000(token)
  10532. fmt.Println(ele.Data.UserName)
  10533. 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)
  10534. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10535. var res ResultTwo
  10536. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10537. utils.ErrorLog("解析失败:%v", err)
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10539. return
  10540. }
  10541. if res.Infcode == 0 {
  10542. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10543. if err == gorm.ErrRecordNotFound {
  10544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10545. return
  10546. } else if err != nil {
  10547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10548. return
  10549. } else {
  10550. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10551. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10552. infoStr := string(Iinfos)
  10553. idetinfoStr := string(Idetinfos)
  10554. psn := &models.HisPsn{
  10555. PsnNo: res.Output.Baseinfo.PsnNo,
  10556. PatientId: patient.ID,
  10557. Certno: res.Output.Baseinfo.Certno,
  10558. Gend: res.Output.Baseinfo.Gend,
  10559. Naty: res.Output.Baseinfo.Naty,
  10560. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10561. PsnName: res.Output.Baseinfo.PsnName,
  10562. Idetinfo: idetinfoStr,
  10563. Insuinfo: infoStr,
  10564. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10565. CardInfo: "",
  10566. VerifyNumber: token,
  10567. }
  10568. service.CreateHisPsn(psn)
  10569. c.ServeSuccessJSON(map[string]interface{}{
  10570. "patient": patient,
  10571. "number": token,
  10572. })
  10573. }
  10574. } else {
  10575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10576. return
  10577. }
  10578. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10579. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10580. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10581. type ELeData struct {
  10582. Data struct {
  10583. IdNo string `json:"idNo"`
  10584. IdType string `json:"idType"`
  10585. UserName string `json:"userName"`
  10586. EcToken string `json:"ecToken"`
  10587. InsuOrg string `json:"insuOrg"`
  10588. Gender string `json:"gender"`
  10589. Birthday string `json:"birthday"`
  10590. Nationality string `json:"nationality"`
  10591. Email string `json:"email"`
  10592. Extra string `json:"extra"`
  10593. } `json:"data"`
  10594. Code int `json:"code"`
  10595. Message string `json:"message"`
  10596. }
  10597. var ele ELeData
  10598. err := json.Unmarshal([]byte(result), &ele)
  10599. if err != nil {
  10600. utils.ErrorLog("解析失败:%v", err)
  10601. }
  10602. token := ele.Data.EcToken
  10603. token = Remove0000(token)
  10604. fmt.Println(ele.Data.UserName)
  10605. 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)
  10606. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10607. var res ResultTwo
  10608. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10609. utils.ErrorLog("解析失败:%v", err)
  10610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10611. return
  10612. }
  10613. if res.Infcode == 0 {
  10614. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10615. if err == gorm.ErrRecordNotFound {
  10616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10617. return
  10618. } else if err != nil {
  10619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10620. return
  10621. } else {
  10622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10624. infoStr := string(Iinfos)
  10625. idetinfoStr := string(Idetinfos)
  10626. psn := &models.HisPsn{
  10627. PsnNo: res.Output.Baseinfo.PsnNo,
  10628. PatientId: patient.ID,
  10629. Certno: res.Output.Baseinfo.Certno,
  10630. Gend: res.Output.Baseinfo.Gend,
  10631. Naty: res.Output.Baseinfo.Naty,
  10632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10633. PsnName: res.Output.Baseinfo.PsnName,
  10634. Idetinfo: idetinfoStr,
  10635. Insuinfo: infoStr,
  10636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10637. CardInfo: "",
  10638. VerifyNumber: token,
  10639. }
  10640. service.CreateHisPsn(psn)
  10641. c.ServeSuccessJSON(map[string]interface{}{
  10642. "patient": patient,
  10643. "number": token,
  10644. })
  10645. }
  10646. } else {
  10647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10648. return
  10649. }
  10650. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10651. //if initFlag == 0 {
  10652. //c.TestGetJiangXiBasBaseInit()
  10653. //}
  10654. //if initEleFlag == 0 {
  10655. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10656. //}
  10657. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10658. utils.ErrorLog("解析失败:%v", json_result)
  10659. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10660. type ELeData struct {
  10661. Data struct {
  10662. IdNo string `json:"idNo"`
  10663. IdType string `json:"idType"`
  10664. UserName string `json:"userName"`
  10665. EcToken string `json:"ecToken"`
  10666. InsuOrg string `json:"insuOrg"`
  10667. Gender string `json:"gender"`
  10668. Birthday string `json:"birthday"`
  10669. Nationality string `json:"nationality"`
  10670. Email string `json:"email"`
  10671. Extra string `json:"extra"`
  10672. } `json:"data"`
  10673. Code int `json:"code"`
  10674. Message string `json:"message"`
  10675. }
  10676. var ele ELeData
  10677. err := json.Unmarshal([]byte(json_result), &ele)
  10678. if err != nil {
  10679. utils.ErrorLog("解析失败:%v", err)
  10680. }
  10681. token := ele.Data.EcToken
  10682. token = Remove0000(token)
  10683. //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)
  10684. 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)
  10685. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10686. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10687. var res ResultTwo
  10688. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10689. utils.ErrorLog("解析失败:%v", err)
  10690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10691. return
  10692. }
  10693. if res.Infcode == 0 {
  10694. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10695. if err == gorm.ErrRecordNotFound {
  10696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10697. return
  10698. } else if err != nil {
  10699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10700. return
  10701. } else {
  10702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10704. infoStr := string(Iinfos)
  10705. idetinfoStr := string(Idetinfos)
  10706. psn := &models.HisPsn{
  10707. PsnNo: res.Output.Baseinfo.PsnNo,
  10708. PatientId: patient.ID,
  10709. Certno: res.Output.Baseinfo.Certno,
  10710. Gend: res.Output.Baseinfo.Gend,
  10711. Naty: res.Output.Baseinfo.Naty,
  10712. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10713. PsnName: res.Output.Baseinfo.PsnName,
  10714. Idetinfo: idetinfoStr,
  10715. Insuinfo: infoStr,
  10716. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10717. CardInfo: "",
  10718. VerifyNumber: token,
  10719. InsuplcAdmdvs: ele.Data.InsuOrg,
  10720. }
  10721. service.CreateHisPsn(psn)
  10722. c.ServeSuccessJSON(map[string]interface{}{
  10723. "patient": patient,
  10724. "number": token,
  10725. })
  10726. }
  10727. } else {
  10728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10729. return
  10730. }
  10731. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10732. res := c.GetoleInfo()
  10733. if res.Infcode == 0 {
  10734. var result string
  10735. if res.Output.MdtrtCertType == "01" {
  10736. 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)
  10737. } else if res.Output.MdtrtCertType == "02" {
  10738. 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)
  10739. } else if res.Output.MdtrtCertType == "03" {
  10740. 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)
  10741. }
  10742. var dat map[string]interface{}
  10743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10744. fmt.Println(dat)
  10745. } else {
  10746. fmt.Println(err)
  10747. }
  10748. userJSONBytes, _ := json.Marshal(dat)
  10749. var res2 ResultTwo
  10750. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10751. utils.ErrorLog("解析失败:%v", err)
  10752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10753. return
  10754. }
  10755. if res2.Infcode == 0 {
  10756. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10757. if err == gorm.ErrRecordNotFound {
  10758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10759. return
  10760. } else if err != nil {
  10761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10762. return
  10763. } else {
  10764. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10765. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10766. infoStr := string(Iinfos)
  10767. idetinfoStr := string(Idetinfos)
  10768. var rf []*ResultFive
  10769. json.Unmarshal([]byte(infoStr), &rf)
  10770. var insutypes []*ResultFive
  10771. var insutype string
  10772. var is390 int = 0
  10773. var is310 int = 0
  10774. //var insuplc_admdvs string
  10775. for _, item := range rf {
  10776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10777. insutypes = append(insutypes, item)
  10778. }
  10779. }
  10780. if len(insutypes) == 1 {
  10781. insutype = insutypes[0].Insutype
  10782. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10783. } else {
  10784. for _, i := range insutypes {
  10785. if i.Insutype == "390" {
  10786. is390 = 1
  10787. }
  10788. if i.Insutype == "310" {
  10789. is310 = 1
  10790. }
  10791. }
  10792. }
  10793. if is390 == 1 {
  10794. insutype = "390"
  10795. }
  10796. if is310 == 1 {
  10797. insutype = "310"
  10798. }
  10799. if len(insutypes) == 0 {
  10800. insutype = "310"
  10801. }
  10802. psn := &models.HisPsn{
  10803. PsnNo: res2.Output.Baseinfo.PsnNo,
  10804. PatientId: patient.ID,
  10805. Certno: res2.Output.Baseinfo.Certno,
  10806. Gend: res2.Output.Baseinfo.Gend,
  10807. Naty: res2.Output.Baseinfo.Naty,
  10808. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10809. PsnName: res2.Output.Baseinfo.PsnName,
  10810. Idetinfo: idetinfoStr,
  10811. Insuinfo: infoStr,
  10812. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10813. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10814. VerifyNumber: res.Output.EcToken,
  10815. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10816. }
  10817. service.CreateHisPsn(psn)
  10818. c.ServeSuccessJSON(map[string]interface{}{
  10819. "patient": patient,
  10820. "number": res.Output.CardNo,
  10821. "insutype": insutype,
  10822. })
  10823. }
  10824. } else {
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10826. return
  10827. }
  10828. } else {
  10829. c.ServeSuccessJSON(map[string]interface{}{
  10830. "failed_code": -10,
  10831. "msg": res.ErrMsg,
  10832. })
  10833. }
  10834. } else {
  10835. //if initFlag == 0 {
  10836. // c.TestGetBasBaseInit()
  10837. //}
  10838. //token := c.GetEleBaseInfo()
  10839. //token = Remove0000(token)
  10840. type ELeData struct {
  10841. Code string `json:"code"`
  10842. Data struct {
  10843. Aac002 string `json:"aac002"`
  10844. Aaz500 string `json:"aaz500"`
  10845. ActCardNo string `json:"actCardNo"`
  10846. Bab520 string `json:"bab520"`
  10847. Bkz543 string `json:"bkz543"`
  10848. BusinessType string `json:"businessType"`
  10849. CertfCodg string `json:"certfCodg"`
  10850. EcIndexNo string `json:"ecIndexNo"`
  10851. EcToken string `json:"ecToken"`
  10852. ID0000 string `json:"id0000"`
  10853. IDNo string `json:"idNo"`
  10854. IDType string `json:"idType"`
  10855. Idcode string `json:"idcode"`
  10856. IdentityToken string `json:"identity_token"`
  10857. InsuOrg string `json:"insuOrg"`
  10858. OfficeID string `json:"officeId"`
  10859. OfficeName string `json:"officeName"`
  10860. OperatorID string `json:"operatorId"`
  10861. OperatorName string `json:"operatorName"`
  10862. OrgID string `json:"orgId"`
  10863. UserName string `json:"userName"`
  10864. } `json:"data"`
  10865. Infno interface{} `json:"infno"`
  10866. Message string `json:"message"`
  10867. OrgID string `json:"orgId"`
  10868. TransType string `json:"transType"`
  10869. }
  10870. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10871. fmt.Println(result)
  10872. outPutInfo := Remove0000(result)
  10873. fmt.Println(outPutInfo)
  10874. var ele ELeData
  10875. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10876. if err != nil {
  10877. utils.ErrorLog("解析失败:%v", err)
  10878. }
  10879. token := ele.Data.EcToken
  10880. var result2 string
  10881. var requestLog2 string
  10882. if len(token) > 0 {
  10883. if strings.Contains(ele.Data.IDNo, "HKG") {
  10884. 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)
  10885. } else {
  10886. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10887. }
  10888. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10889. var res ResultTwo
  10890. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10891. utils.ErrorLog("解析失败:%v", err)
  10892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10893. return
  10894. }
  10895. if res.Infcode == 0 {
  10896. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10897. if err == gorm.ErrRecordNotFound {
  10898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10899. return
  10900. } else if err != nil {
  10901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10902. return
  10903. } else {
  10904. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10905. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10906. infoStr := string(Iinfos)
  10907. idetinfoStr := string(Idetinfos)
  10908. psn := &models.HisPsn{
  10909. PsnNo: res.Output.Baseinfo.PsnNo,
  10910. PatientId: patient.ID,
  10911. Certno: res.Output.Baseinfo.Certno,
  10912. Gend: res.Output.Baseinfo.Gend,
  10913. Naty: res.Output.Baseinfo.Naty,
  10914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10915. PsnName: res.Output.Baseinfo.PsnName,
  10916. Idetinfo: idetinfoStr,
  10917. Insuinfo: infoStr,
  10918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10919. CardInfo: "",
  10920. VerifyNumber: token,
  10921. }
  10922. service.CreateHisPsn(psn)
  10923. c.ServeSuccessJSON(map[string]interface{}{
  10924. "msg": "读取成功",
  10925. })
  10926. }
  10927. } else {
  10928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10929. return
  10930. }
  10931. } else {
  10932. c.ServeSuccessJSON(map[string]interface{}{
  10933. "failed_code": -10,
  10934. "msg": "读取失败",
  10935. })
  10936. }
  10937. }
  10938. }
  10939. func (c *HisApiController) ReadEleFace() {
  10940. admin_user_id, _ := c.GetInt64("admin_user_id")
  10941. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10942. adminUser := c.GetAdminUserInfo()
  10943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10944. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10945. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10946. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10947. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10948. if len(tokens) > 0 {
  10949. c.ServeSuccessJSON(map[string]interface{}{
  10950. "msg": "读取成功",
  10951. })
  10952. } else {
  10953. c.ServeSuccessJSON(map[string]interface{}{
  10954. "failed_code": -10,
  10955. "msg": "读取失败",
  10956. })
  10957. }
  10958. }
  10959. }
  10960. func timestampToBirthdayString(timestamp int64) string {
  10961. // 将时间戳转换为 time.Time
  10962. t := time.Unix(timestamp, 0)
  10963. // 格式化时间为生日字符串,例如 "2006-01-02"
  10964. birthday := t.Format("2006-01-02")
  10965. return birthday
  10966. }
  10967. func (c *HisApiController) Get9001() {
  10968. adminUser := c.GetAdminUserInfo()
  10969. admin_user_id, _ := c.GetInt64("admin_user_id")
  10970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10972. if miConfig.MdtrtareaAdmvs == "350500" {
  10973. service.GetFjAuthorizationInfo(miConfig.Code)
  10974. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10975. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10976. var dat map[string]interface{}
  10977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10978. fmt.Println(dat)
  10979. } else {
  10980. fmt.Println(err)
  10981. }
  10982. userJSONBytes, _ := json.Marshal(dat)
  10983. var res models.Result9001
  10984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10985. utils.ErrorLog("解析失败:%v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10990. fmt.Println(miConfig.SecretKey)
  10991. var res models.Result9001Two
  10992. 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 +
  10993. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10994. resp, requestErr := http.Get(api)
  10995. if requestErr != nil {
  10996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10997. return
  10998. }
  10999. body, ioErr := ioutil.ReadAll(resp.Body)
  11000. if ioErr != nil {
  11001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11003. return
  11004. }
  11005. var respJSON map[string]interface{}
  11006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11009. return
  11010. }
  11011. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11012. if status == "0" {
  11013. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11014. c.ServeSuccessJSON(map[string]interface{}{
  11015. "failed_code": -10,
  11016. "msg": err_msg,
  11017. })
  11018. return
  11019. }
  11020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11021. result, _ := json.Marshal(respJSON)
  11022. fmt.Println("log")
  11023. fmt.Println(string(result))
  11024. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11025. utils.ErrorLog("解析失败:%v", err)
  11026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11027. return
  11028. }
  11029. if res.Infcode == 0 {
  11030. sign := models.HisSignIn{
  11031. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11032. SignNo: res.Output.Signinoutb.SignNo,
  11033. SignTime: "",
  11034. Ctime: time.Now().Unix(),
  11035. Mtime: time.Now().Unix(),
  11036. Status: 1,
  11037. InputLog: "",
  11038. OutputLog: "",
  11039. FixmedinsCode: miConfig.Code,
  11040. }
  11041. err := service.CreateSignIn(&sign)
  11042. if err == nil {
  11043. c.ServeSuccessJSON(map[string]interface{}{
  11044. "msg": "签到成功",
  11045. })
  11046. }
  11047. } else {
  11048. c.ServeSuccessJSON(map[string]interface{}{
  11049. "failed_code": -10,
  11050. "msg": res.ErrMsg,
  11051. })
  11052. return
  11053. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11054. //return
  11055. }
  11056. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11057. fmt.Println(miConfig.SecretKey)
  11058. var res models.Result9001Two
  11059. 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 +
  11060. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  11061. resp, requestErr := http.Get(api)
  11062. if requestErr != nil {
  11063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11064. return
  11065. }
  11066. body, ioErr := ioutil.ReadAll(resp.Body)
  11067. if ioErr != nil {
  11068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11070. return
  11071. }
  11072. var respJSON map[string]interface{}
  11073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11076. return
  11077. }
  11078. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11079. if status == "0" {
  11080. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11081. c.ServeSuccessJSON(map[string]interface{}{
  11082. "failed_code": -10,
  11083. "msg": err_msg,
  11084. })
  11085. return
  11086. }
  11087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11088. result, _ := json.Marshal(respJSON)
  11089. fmt.Println("log")
  11090. fmt.Println(string(result))
  11091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11092. utils.ErrorLog("解析失败:%v", err)
  11093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11094. return
  11095. }
  11096. if res.Infcode == 0 {
  11097. sign := models.HisSignIn{
  11098. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11099. SignNo: res.Output.Signinoutb.SignNo,
  11100. SignTime: "",
  11101. Ctime: time.Now().Unix(),
  11102. Mtime: time.Now().Unix(),
  11103. Status: 1,
  11104. InputLog: "",
  11105. OutputLog: "",
  11106. FixmedinsCode: miConfig.Code,
  11107. }
  11108. err := service.CreateSignIn(&sign)
  11109. if err == nil {
  11110. c.ServeSuccessJSON(map[string]interface{}{
  11111. "msg": "签到成功",
  11112. })
  11113. }
  11114. } else {
  11115. c.ServeSuccessJSON(map[string]interface{}{
  11116. "failed_code": -10,
  11117. "msg": res.ErrMsg,
  11118. })
  11119. return
  11120. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11121. //return
  11122. }
  11123. } else {
  11124. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11125. var dat map[string]interface{}
  11126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11127. fmt.Println(dat)
  11128. } else {
  11129. fmt.Println(err)
  11130. }
  11131. userJSONBytes, _ := json.Marshal(dat)
  11132. var res models.Result9001
  11133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11134. utils.ErrorLog("解析失败:%v", err)
  11135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11136. return
  11137. }
  11138. if res.Infcode == 0 {
  11139. sign := models.HisSignIn{
  11140. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11141. SignNo: res.Output.Signinoutb.SignNo,
  11142. SignTime: res.Output.Signinoutb.SignTime,
  11143. Ctime: time.Now().Unix(),
  11144. Mtime: time.Now().Unix(),
  11145. Status: 1,
  11146. InputLog: "",
  11147. OutputLog: "",
  11148. FixmedinsCode: miConfig.Code,
  11149. }
  11150. err := service.CreateSignIn(&sign)
  11151. if err == nil {
  11152. c.ServeSuccessJSON(map[string]interface{}{
  11153. "msg": "签到成功",
  11154. })
  11155. }
  11156. }
  11157. }
  11158. }
  11159. 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) {
  11160. var res Result3101
  11161. adminUser := c.GetAdminUserInfo()
  11162. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11163. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11165. //record_time := c.GetString("record_time")
  11166. //trig_scen := c.GetString("trig_scen")
  11167. timeLayout := "2006-01-02"
  11168. loc, _ := time.LoadLocation("Local")
  11169. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11170. if err != nil {
  11171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11172. return res
  11173. }
  11174. recordDateTime := theTime.Unix()
  11175. var patientPrescription models.HisPrescriptionInfo
  11176. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11177. //if patientPrescription.ID == 0 {
  11178. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11179. //}
  11180. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11181. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11182. //
  11183. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11184. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11185. var pp models.PublicParams
  11186. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11187. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11188. pp.FixmedinsName = miConfig.OrgName
  11189. pp.FixmedinsCode = miConfig.Code
  11190. pp.RequestUrl = miConfig.Url
  11191. pp.Cainfo = miConfig.Cainfo
  11192. pp.SecretKey = miConfig.SecretKey
  11193. pp.AccessKey = miConfig.AccessKey
  11194. pp.OpterName = roles.UserName
  11195. var config []*models.HisXtDiagnoseConfig
  11196. for _, item := range diagnosis_ids {
  11197. id, _ := strconv.ParseInt(item, 10, 64)
  11198. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11199. config = append(config, &diagnosisConfig)
  11200. }
  11201. var pd models.PatientDtos
  11202. pd.PatnID = his.PsnNo
  11203. pd.PatnName = his.Name
  11204. pd.Gend = his.Gend
  11205. pd.Brdy = his.Brdy
  11206. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11207. pd.CurrMdtrtID = his.Number
  11208. var fed models.FsiEncounterDtos
  11209. fed.MdtrtID = his.Number
  11210. fed.MedinsID = miConfig.Code
  11211. fed.MedinsName = miConfig.OrgName
  11212. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11213. fed.MedMdtrtType = "1"
  11214. fed.MedinsType = "1"
  11215. fed.MedinsLv = "11"
  11216. tm := time.Unix(his.RecordDate, 0)
  11217. s_tm := tm.Format("2006-01-02 15:04:05")
  11218. fed.AdmDate = s_tm
  11219. fed.DscgDate = s_tm
  11220. fed.DscgMainDiseCodg = config[0].CountryCode
  11221. fed.DscgMainDiseName = config[0].CountryContentName
  11222. //诊断信息
  11223. var fdds []*models.FsiDiagnoseDtos
  11224. for index, item := range config {
  11225. if index == 0 {
  11226. var fdd models.FsiDiagnoseDtos
  11227. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11228. fdd.InoutDiseType = "1"
  11229. fdd.MaindiseFlag = "1"
  11230. fdd.DiseDate = s_tm
  11231. fdd.DiasSrtNo = "1"
  11232. fdd.DiseName = item.CountryContentName
  11233. fdd.DiseCodg = item.CountryCode
  11234. fdds = append(fdds, &fdd)
  11235. } else {
  11236. var fdd models.FsiDiagnoseDtos
  11237. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11238. fdd.InoutDiseType = "1"
  11239. fdd.MaindiseFlag = "1"
  11240. fdd.DiseDate = s_tm
  11241. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11242. fdd.DiseName = item.CountryContentName
  11243. fdd.DiseCodg = item.CountryCode
  11244. fdds = append(fdds, &fdd)
  11245. }
  11246. }
  11247. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11248. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11249. fed.AdmDeptName = de.Name
  11250. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11251. fed.DscgDeptName = de.Name
  11252. fed.MedMdtrtType = "1"
  11253. fed.MedType = "11"
  11254. //if his.Insutype == "390" {
  11255. // fed.MedType = "1402"
  11256. //} else {
  11257. // fed.MedType = "9933"
  11258. //}
  11259. var orders []*models.FsiOrderDtos
  11260. if trig_scen == "2" {
  11261. //处方医嘱信息
  11262. for _, item := range prescriptions {
  11263. for _, subItem := range item.HisDoctorAdviceInfo {
  11264. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11265. var order models.FsiOrderDtos
  11266. order.RxID = strconv.FormatInt(item.ID, 10)
  11267. order.Rxno = strconv.FormatInt(item.ID, 10)
  11268. order.LongDrordFlag = "0"
  11269. order.HilistType = "1"
  11270. order.ChrgType = "1"
  11271. order.DrordBhvr = "-"
  11272. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11273. order.HosplistName = subItem.BaseDrugLib.DrugName
  11274. order.HilistLv = "1"
  11275. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11276. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11277. order.HosplistName = subItem.BaseDrugLib.DrugName
  11278. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11279. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11280. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11281. order.OwnpayAmt = ""
  11282. order.SelfpayAmt = ""
  11283. order.Spec = ""
  11284. order.SpecUnt = ""
  11285. order.DrordBegnDate = s_tm
  11286. order.DrordStopDate = ""
  11287. order.DrordDrCodg = doctor_info.DoctorNumber
  11288. order.DrordDeptName = department.Name
  11289. order.DrordDeptCodg = department.Number
  11290. order.DrordDrName = doctor_info.UserName
  11291. order.DrordDrProfttl = "234"
  11292. order.CurrDrordFlag = "1"
  11293. orders = append(orders, &order)
  11294. }
  11295. }
  11296. for _, subItem := range item.HisPrescriptionProject {
  11297. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11298. var order models.FsiOrderDtos
  11299. order.RxID = strconv.FormatInt(item.ID, 10)
  11300. order.Rxno = strconv.FormatInt(item.ID, 10)
  11301. order.LongDrordFlag = "0"
  11302. order.HilistType = "1"
  11303. order.ChrgType = "1"
  11304. order.DrordBhvr = "-"
  11305. order.HilistCode = subItem.HisProject.MedicalCode
  11306. order.HosplistName = subItem.HisProject.ProjectName
  11307. order.HilistLv = "1"
  11308. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11309. order.HosplistCode = subItem.HisProject.MedicalCode
  11310. order.HosplistName = subItem.HisProject.ProjectName
  11311. order.Cnt = subItem.Count
  11312. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11313. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11314. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11315. order.OwnpayAmt = ""
  11316. order.SelfpayAmt = ""
  11317. order.Spec = ""
  11318. order.SpecUnt = ""
  11319. order.DrordBegnDate = s_tm
  11320. order.DrordStopDate = ""
  11321. order.DrordDrCodg = doctor_info.DoctorNumber
  11322. order.DrordDeptName = department.Name
  11323. order.DrordDeptCodg = department.Number
  11324. order.DrordDrName = doctor_info.UserName
  11325. order.DrordDrProfttl = "234"
  11326. order.CurrDrordFlag = "1"
  11327. orders = append(orders, &order)
  11328. }
  11329. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11330. var order models.FsiOrderDtos
  11331. order.RxID = strconv.FormatInt(item.ID, 10)
  11332. order.Rxno = strconv.FormatInt(item.ID, 10)
  11333. order.LongDrordFlag = "0"
  11334. order.HilistType = "1"
  11335. order.ChrgType = "1"
  11336. order.DrordBhvr = "-"
  11337. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11338. order.HosplistName = subItem.GoodInfo.GoodName
  11339. order.HilistLv = "1"
  11340. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11341. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11342. order.HosplistName = subItem.GoodInfo.GoodName
  11343. order.Cnt = subItem.Count
  11344. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11345. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11346. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11347. order.OwnpayAmt = ""
  11348. order.SelfpayAmt = ""
  11349. order.Spec = ""
  11350. order.SpecUnt = ""
  11351. order.DrordBegnDate = s_tm
  11352. order.DrordStopDate = ""
  11353. order.DrordDrCodg = doctor_info.DoctorNumber
  11354. order.DrordDeptName = department.Name
  11355. order.DrordDeptCodg = department.Number
  11356. order.DrordDrName = doctor_info.UserName
  11357. order.DrordDrProfttl = "234"
  11358. order.CurrDrordFlag = "1"
  11359. orders = append(orders, &order)
  11360. }
  11361. }
  11362. }
  11363. //处方医嘱信息
  11364. }
  11365. fed.MatnStas = "0"
  11366. fed.MedfeeSumamt = "0"
  11367. fed.OwnpayAmt = "0"
  11368. fed.SelfpayAmt = "0"
  11369. fed.AcctPayamt = "0"
  11370. fed.MaAmt = "0"
  11371. fed.HifpPayamt = "0"
  11372. fed.SetlTotlnum = "1"
  11373. fed.Insutype = his.Insutype
  11374. fed.ReimFlag = "0"
  11375. fed.OutSetlFlag = "0"
  11376. var fopd []*models.FsiOperationDtosData
  11377. data := make(map[string]interface{})
  11378. data["fed"] = fed
  11379. data["fdd"] = fdds
  11380. data["fod"] = orders
  11381. data["pd"] = pd
  11382. data["pp"] = pp
  11383. data["fopd"] = fopd
  11384. data["trig_scen"] = trig_scen
  11385. fmt.Println(data)
  11386. fmt.Println(fed)
  11387. fmt.Println(fdds)
  11388. fmt.Println(orders)
  11389. fmt.Println(pd)
  11390. fmt.Println(pp)
  11391. fmt.Println(fopd)
  11392. client := &http.Client{}
  11393. bytesData, _ := json.Marshal(data)
  11394. var req *http.Request
  11395. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11396. if miConfig.MdtrtareaAdmvs == "320830" {
  11397. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11398. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11400. } else {
  11401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11402. }
  11403. resp, _ := client.Do(req)
  11404. defer resp.Body.Close()
  11405. body, ioErr := ioutil.ReadAll(resp.Body)
  11406. if ioErr != nil {
  11407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11409. return res
  11410. }
  11411. var respJSON map[string]interface{}
  11412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11415. return res
  11416. }
  11417. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11418. fmt.Println(respJSON)
  11419. result, _ := json.Marshal(respJSON)
  11420. fmt.Println(result)
  11421. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11422. utils.ErrorLog("解析失败:%v", err)
  11423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. return res
  11425. }
  11426. return res
  11427. } else {
  11428. //if miConfig.MdtrtareaAdmvs == "441202" {
  11429. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11430. saveLog(output, input, "3101", "事前")
  11431. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11432. utils.ErrorLog("解析失败:%v", err)
  11433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11434. return
  11435. }
  11436. return res
  11437. //}
  11438. }
  11439. }
  11440. 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) {
  11441. adminUser := c.GetAdminUserInfo()
  11442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11443. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11445. //record_time := c.GetString("record_time")
  11446. //trig_scen := c.GetString("trig_scen")
  11447. timeLayout := "2006-01-02"
  11448. loc, _ := time.LoadLocation("Local")
  11449. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11450. if err != nil {
  11451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11452. return res
  11453. }
  11454. recordDateTime := theTime.Unix()
  11455. var patientPrescription models.HisPrescriptionInfo
  11456. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11457. if patientPrescription.ID == 0 {
  11458. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11459. }
  11460. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11461. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11462. //
  11463. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11464. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11465. var pp models.PublicParams
  11466. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11467. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11468. pp.FixmedinsName = miConfig.OrgName
  11469. pp.FixmedinsCode = miConfig.Code
  11470. pp.RequestUrl = miConfig.Url
  11471. pp.Cainfo = miConfig.Cainfo
  11472. pp.SecretKey = miConfig.SecretKey
  11473. pp.AccessKey = miConfig.AccessKey
  11474. pp.OpterName = roles.UserName
  11475. var config []*models.HisXtDiagnoseConfig
  11476. for _, item := range diagnosis_ids {
  11477. id, _ := strconv.ParseInt(item, 10, 64)
  11478. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11479. config = append(config, &diagnosisConfig)
  11480. }
  11481. var pd models.PatientDtos
  11482. pd.PatnID = his.PsnNo
  11483. pd.PatnName = his.Name
  11484. pd.Gend = his.Gend
  11485. pd.Brdy = his.Brdy
  11486. pd.Poolarea = his.InsuplcAdmdvs
  11487. pd.CurrMdtrtID = his.Number
  11488. var fed models.FsiEncounterDtos
  11489. fed.MdtrtID = his.Number
  11490. fed.MedinsID = miConfig.Code
  11491. fed.MedinsName = miConfig.OrgName
  11492. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11493. fed.MedMdtrtType = "1"
  11494. fed.MedinsType = "1"
  11495. fed.MedinsLv = "11"
  11496. tm := time.Unix(his.RecordDate, 0)
  11497. s_tm := tm.Format("2006-01-02 15:04:05")
  11498. fed.AdmDate = s_tm
  11499. fed.DscgDate = s_tm
  11500. fed.DscgMainDiseCodg = config[0].CountryCode
  11501. fed.DscgMainDiseName = config[0].CountryContentName
  11502. //诊断信息
  11503. var fdds []*models.FsiDiagnoseDtos
  11504. for index, item := range config {
  11505. if index == 0 {
  11506. var fdd models.FsiDiagnoseDtos
  11507. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11508. fdd.InoutDiseType = "1"
  11509. fdd.MaindiseFlag = "1"
  11510. fdd.DiseDate = s_tm
  11511. fdd.DiasSrtNo = "1"
  11512. fdd.DiseName = item.CountryContentName
  11513. fdd.DiseCodg = item.CountryCode
  11514. fdds = append(fdds, &fdd)
  11515. } else {
  11516. var fdd models.FsiDiagnoseDtos
  11517. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11518. fdd.InoutDiseType = "1"
  11519. fdd.MaindiseFlag = "1"
  11520. fdd.DiseDate = s_tm
  11521. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11522. fdd.DiseName = item.CountryContentName
  11523. fdd.DiseCodg = item.CountryCode
  11524. fdds = append(fdds, &fdd)
  11525. }
  11526. }
  11527. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11528. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11529. fed.AdmDeptName = department.Name
  11530. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11531. fed.DscgDeptName = department.Name
  11532. fed.MedMdtrtType = "1"
  11533. fed.MedType = "11"
  11534. //if his.Insutype == "390" {
  11535. // fed.MedType = "1402"
  11536. //} else {
  11537. // fed.MedType = "9933"
  11538. //}
  11539. var orders []*models.FsiOrderDtos
  11540. if trig_scen == "2" {
  11541. //处方医嘱信息
  11542. for _, item := range prescriptions {
  11543. for _, subItem := range item.HisDoctorAdviceInfo {
  11544. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11545. var order models.FsiOrderDtos
  11546. order.RxID = strconv.FormatInt(item.ID, 10)
  11547. order.Rxno = strconv.FormatInt(item.ID, 10)
  11548. order.LongDrordFlag = "0"
  11549. order.HilistType = "1"
  11550. order.ChrgType = "1"
  11551. order.DrordBhvr = "-"
  11552. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11553. order.HosplistName = subItem.BaseDrugLib.DrugName
  11554. order.HilistLv = "1"
  11555. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11556. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11557. order.HosplistName = subItem.BaseDrugLib.DrugName
  11558. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11559. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11560. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11561. order.OwnpayAmt = ""
  11562. order.SelfpayAmt = ""
  11563. order.Spec = ""
  11564. order.SpecUnt = ""
  11565. order.DrordBegnDate = s_tm
  11566. order.DrordStopDate = ""
  11567. order.DrordDrCodg = doctor_info.DoctorNumber
  11568. order.DrordDeptName = department.Name
  11569. order.DrordDeptCodg = department.Number
  11570. order.DrordDrName = doctor_info.UserName
  11571. order.DrordDrProfttl = "234"
  11572. order.CurrDrordFlag = "1"
  11573. orders = append(orders, &order)
  11574. }
  11575. }
  11576. for _, subItem := range item.HisPrescriptionProject {
  11577. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11578. var order models.FsiOrderDtos
  11579. order.RxID = strconv.FormatInt(item.ID, 10)
  11580. order.Rxno = strconv.FormatInt(item.ID, 10)
  11581. order.LongDrordFlag = "0"
  11582. order.HilistType = "1"
  11583. order.ChrgType = "1"
  11584. order.DrordBhvr = "-"
  11585. order.HilistCode = subItem.HisProject.MedicalCode
  11586. order.HosplistName = subItem.HisProject.ProjectName
  11587. order.HilistLv = "1"
  11588. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11589. order.HosplistCode = subItem.HisProject.MedicalCode
  11590. order.HosplistName = subItem.HisProject.ProjectName
  11591. order.Cnt = subItem.Count
  11592. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11593. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11594. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11595. order.OwnpayAmt = ""
  11596. order.SelfpayAmt = ""
  11597. order.Spec = ""
  11598. order.SpecUnt = ""
  11599. order.DrordBegnDate = s_tm
  11600. order.DrordStopDate = ""
  11601. order.DrordDrCodg = doctor_info.DoctorNumber
  11602. order.DrordDeptName = department.Name
  11603. order.DrordDeptCodg = department.Number
  11604. order.DrordDrName = doctor_info.UserName
  11605. order.DrordDrProfttl = "234"
  11606. order.CurrDrordFlag = "1"
  11607. orders = append(orders, &order)
  11608. }
  11609. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11610. var order models.FsiOrderDtos
  11611. order.RxID = strconv.FormatInt(item.ID, 10)
  11612. order.Rxno = strconv.FormatInt(item.ID, 10)
  11613. order.LongDrordFlag = "0"
  11614. order.HilistType = "1"
  11615. order.ChrgType = "1"
  11616. order.DrordBhvr = "-"
  11617. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11618. order.HosplistName = subItem.GoodInfo.GoodName
  11619. order.HilistLv = "1"
  11620. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11621. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11622. order.HosplistName = subItem.GoodInfo.GoodName
  11623. order.Cnt = subItem.Count
  11624. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11626. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11627. order.OwnpayAmt = ""
  11628. order.SelfpayAmt = ""
  11629. order.Spec = ""
  11630. order.SpecUnt = ""
  11631. order.DrordBegnDate = s_tm
  11632. order.DrordStopDate = ""
  11633. order.DrordDrCodg = doctor_info.DoctorNumber
  11634. order.DrordDeptName = department.Name
  11635. order.DrordDeptCodg = department.Number
  11636. order.DrordDrName = doctor_info.UserName
  11637. order.DrordDrProfttl = "234"
  11638. order.CurrDrordFlag = "1"
  11639. orders = append(orders, &order)
  11640. }
  11641. }
  11642. }
  11643. //处方医嘱信息
  11644. }
  11645. fed.MatnStas = "0"
  11646. fed.MedfeeSumamt = "0"
  11647. fed.OwnpayAmt = "0"
  11648. fed.SelfpayAmt = "0"
  11649. fed.AcctPayamt = "0"
  11650. fed.MaAmt = "0"
  11651. fed.HifpPayamt = "0"
  11652. fed.SetlTotlnum = "1"
  11653. fed.Insutype = his.Insutype
  11654. fed.ReimFlag = "0"
  11655. fed.OutSetlFlag = "0"
  11656. var fopd []*models.FsiOperationDtosData
  11657. data := make(map[string]interface{})
  11658. data["fed"] = fed
  11659. data["fdd"] = fdds
  11660. data["fod"] = orders
  11661. data["pd"] = pd
  11662. data["pp"] = pp
  11663. data["fopd"] = fopd
  11664. data["trig_scen"] = trig_scen
  11665. fmt.Println(data)
  11666. fmt.Println(fed)
  11667. fmt.Println(fdds)
  11668. fmt.Println(orders)
  11669. fmt.Println(pd)
  11670. fmt.Println(pp)
  11671. fmt.Println(fopd)
  11672. client := &http.Client{}
  11673. bytesData, _ := json.Marshal(data)
  11674. var req *http.Request
  11675. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11676. if miConfig.MdtrtareaAdmvs == "320830" {
  11677. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11678. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11679. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11680. } else {
  11681. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11682. }
  11683. resp, _ := client.Do(req)
  11684. defer resp.Body.Close()
  11685. body, ioErr := ioutil.ReadAll(resp.Body)
  11686. if ioErr != nil {
  11687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11689. return res
  11690. }
  11691. var respJSON map[string]interface{}
  11692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11695. return res
  11696. }
  11697. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11698. fmt.Println(respJSON)
  11699. result, _ := json.Marshal(respJSON)
  11700. fmt.Println(result)
  11701. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11702. utils.ErrorLog("解析失败:%v", err)
  11703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11704. return res
  11705. }
  11706. return res
  11707. } else {
  11708. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11709. saveLog(output, input, "3101", "事前")
  11710. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11711. utils.ErrorLog("解析失败:%v", err)
  11712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11713. return
  11714. }
  11715. return res
  11716. }
  11717. return res
  11718. }
  11719. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11720. ////patient_id, _ := c.GetInt64("patient_id")
  11721. //order_id, _ := c.GetInt64("order_id")
  11722. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11723. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11724. //trig_scen := c.GetString("trig_scen")
  11725. adminUser := c.GetAdminUserInfo()
  11726. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11727. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11728. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11729. record_time := c.GetString("record_time")
  11730. order, _ := service.GetHisOrderByID(order_id)
  11731. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11732. timeLayout := "2006-01-02"
  11733. loc, _ := time.LoadLocation("Local")
  11734. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11735. if err != nil {
  11736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11737. return
  11738. }
  11739. recordDateTime := theTime.Unix()
  11740. var patientPrescription models.HisPrescriptionInfo
  11741. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11742. if patientPrescription.ID == 0 {
  11743. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11744. }
  11745. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11746. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11747. //
  11748. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11749. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11750. var pp models.PublicParams
  11751. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11752. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11753. pp.FixmedinsName = miConfig.OrgName
  11754. pp.FixmedinsCode = miConfig.Code
  11755. pp.RequestUrl = miConfig.Url
  11756. pp.Cainfo = miConfig.Cainfo
  11757. pp.SecretKey = miConfig.SecretKey
  11758. pp.AccessKey = miConfig.AccessKey
  11759. pp.OpterName = roles.UserName
  11760. var config []*models.HisXtDiagnoseConfig
  11761. for _, item := range diagnosis_ids {
  11762. id, _ := strconv.ParseInt(item, 10, 64)
  11763. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11764. config = append(config, &diagnosisConfig)
  11765. }
  11766. var pd models.PatientDtos
  11767. pd.PatnID = his.PsnNo
  11768. pd.PatnName = his.Name
  11769. pd.Gend = his.Gend
  11770. pd.Brdy = psn_info.Brdy
  11771. pd.Poolarea = his.InsuplcAdmdvs
  11772. pd.CurrMdtrtID = his.Number
  11773. var fed models.FsiEncounterDtos
  11774. fed.MdtrtID = his.Number
  11775. fed.MedinsID = miConfig.Code
  11776. fed.MedinsName = miConfig.OrgName
  11777. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11778. fed.MedMdtrtType = "1"
  11779. fed.MedinsType = "1"
  11780. fed.MedinsLv = "11"
  11781. tm := time.Unix(his.RecordDate, 0)
  11782. s_tm := tm.Format("2006-01-02 15:04:05")
  11783. fed.AdmDate = s_tm
  11784. fed.DscgDate = s_tm
  11785. fed.DscgMainDiseCodg = config[0].CountryCode
  11786. fed.DscgMainDiseName = config[0].CountryContentName
  11787. //诊断信息
  11788. var fdds []*models.FsiDiagnoseDtos
  11789. for index, item := range config {
  11790. if index == 0 {
  11791. var fdd models.FsiDiagnoseDtos
  11792. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11793. fdd.InoutDiseType = "1"
  11794. fdd.MaindiseFlag = "1"
  11795. fdd.DiseDate = s_tm
  11796. fdd.DiasSrtNo = "1"
  11797. fdd.DiseName = item.CountryContentName
  11798. fdd.DiseCodg = item.CountryCode
  11799. fdds = append(fdds, &fdd)
  11800. } else {
  11801. var fdd models.FsiDiagnoseDtos
  11802. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11803. fdd.InoutDiseType = "1"
  11804. fdd.MaindiseFlag = "1"
  11805. fdd.DiseDate = s_tm
  11806. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11807. fdd.DiseName = item.CountryContentName
  11808. fdd.DiseCodg = item.CountryCode
  11809. fdds = append(fdds, &fdd)
  11810. }
  11811. }
  11812. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11813. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11814. fed.AdmDeptName = department.Name
  11815. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11816. fed.DscgDeptName = department.Name
  11817. fed.MedType = order.MedType
  11818. //处方医嘱信息
  11819. var orders []*models.FsiOrderDtos
  11820. //for _, item := range prescriptions {
  11821. // for _, subItem := range item.HisDoctorAdviceInfo {
  11822. // var order models.FsiOrderDtos
  11823. // order.RxID = strconv.FormatInt(item.ID, 10)
  11824. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11825. // order.LongDrordFlag = "0"
  11826. // order.HilistType = "1"
  11827. // order.ChrgType = "1"
  11828. // order.DrordBhvr = "-"
  11829. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11830. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11831. // order.HilistLv = "1"
  11832. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11833. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11834. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11835. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11836. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11837. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11838. // order.OwnpayAmt = ""
  11839. // order.SelfpayAmt = ""
  11840. // order.Spec = ""
  11841. // order.SpecUnt = ""
  11842. // order.DrordBegnDate = s_tm
  11843. // order.DrordStopDate = ""
  11844. // order.DrordDrCodg = "1"
  11845. // order.DrordDeptName = department.Name
  11846. // order.DrordDrCodg = "1"
  11847. // order.DrordDrName = doctor_info.UserName
  11848. // order.DrordDrProfttl = ""
  11849. // order.CurrDrordFlag = "1"
  11850. // orders = append(orders, &order)
  11851. // }
  11852. // for _, subItem := range item.HisPrescriptionProject {
  11853. // if subItem.Type == 2 {
  11854. // var order models.FsiOrderDtos
  11855. // order.RxID = strconv.FormatInt(item.ID, 10)
  11856. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11857. // order.LongDrordFlag = "0"
  11858. // order.HilistType = "1"
  11859. // order.ChrgType = "1"
  11860. // order.DrordBhvr = "-"
  11861. // order.HilistCode = subItem.HisProject.MedicalCode
  11862. // order.HosplistName = subItem.HisProject.ProjectName
  11863. // order.HilistLv = "1"
  11864. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11865. // order.HosplistCode = subItem.HisProject.MedicalCode
  11866. // order.HosplistName = subItem.HisProject.ProjectName
  11867. // order.Cnt = subItem.Count
  11868. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11869. //
  11870. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11871. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11872. // order.OwnpayAmt = ""
  11873. // order.SelfpayAmt = ""
  11874. // order.Spec = ""
  11875. // order.SpecUnt = ""
  11876. // order.DrordBegnDate = s_tm
  11877. // order.DrordStopDate = ""
  11878. // order.DrordDrCodg = "1"
  11879. // order.DrordDeptName = department.Name
  11880. // order.DrordDrCodg = "1"
  11881. // order.DrordDrName = doctor_info.UserName
  11882. // order.DrordDrProfttl = ""
  11883. // order.CurrDrordFlag = "1"
  11884. // orders = append(orders, &order)
  11885. //
  11886. // }
  11887. // if subItem.Type == 3 {
  11888. //
  11889. // var order models.FsiOrderDtos
  11890. // order.RxID = strconv.FormatInt(item.ID, 10)
  11891. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11892. // order.LongDrordFlag = "0"
  11893. // order.HilistType = "1"
  11894. // order.ChrgType = "1"
  11895. // order.DrordBhvr = "-"
  11896. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11897. // order.HosplistName = subItem.GoodInfo.GoodName
  11898. // order.HilistLv = "1"
  11899. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11900. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11901. // order.HosplistName = subItem.GoodInfo.GoodName
  11902. // order.Cnt = subItem.Count
  11903. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11904. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11905. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11906. // order.OwnpayAmt = ""
  11907. // order.SelfpayAmt = ""
  11908. // order.Spec = ""
  11909. // order.SpecUnt = ""
  11910. // order.DrordBegnDate = s_tm
  11911. // order.DrordStopDate = ""
  11912. // order.DrordDrCodg = "1"
  11913. // order.DrordDeptName = department.Name
  11914. // order.DrordDrCodg = "1"
  11915. // order.DrordDrName = doctor_info.UserName
  11916. // order.DrordDrProfttl = ""
  11917. // order.CurrDrordFlag = "1"
  11918. // orders = append(orders, &order)
  11919. //
  11920. // }
  11921. // }
  11922. //}
  11923. for _, item := range prescriptions {
  11924. for _, subItem := range item.HisDoctorAdviceInfo {
  11925. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11926. var order models.FsiOrderDtos
  11927. order.RxID = strconv.FormatInt(item.ID, 10)
  11928. order.Rxno = strconv.FormatInt(item.ID, 10)
  11929. order.LongDrordFlag = "0"
  11930. order.HilistType = "101"
  11931. order.ChrgType = "1"
  11932. order.DrordBhvr = "-"
  11933. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11934. order.HosplistName = subItem.BaseDrugLib.DrugName
  11935. order.HilistLv = "1"
  11936. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11937. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11938. order.HosplistName = subItem.BaseDrugLib.DrugName
  11939. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11940. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11941. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11942. order.OwnpayAmt = ""
  11943. order.SelfpayAmt = ""
  11944. order.Spec = ""
  11945. order.SpecUnt = ""
  11946. order.DrordBegnDate = s_tm
  11947. order.DrordStopDate = ""
  11948. order.DrordDrCodg = doctor_info.DoctorNumber
  11949. order.DrordDeptName = department.Name
  11950. order.DrordDeptCodg = department.Number
  11951. order.DrordDrName = doctor_info.UserName
  11952. order.DrordDrProfttl = "234"
  11953. order.CurrDrordFlag = "1"
  11954. orders = append(orders, &order)
  11955. }
  11956. }
  11957. for _, subItem := range item.HisPrescriptionProject {
  11958. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11959. var order models.FsiOrderDtos
  11960. order.RxID = strconv.FormatInt(item.ID, 10)
  11961. order.Rxno = strconv.FormatInt(item.ID, 10)
  11962. order.LongDrordFlag = "0"
  11963. order.HilistType = "201"
  11964. order.ChrgType = "1"
  11965. order.DrordBhvr = "-"
  11966. order.HilistCode = subItem.HisProject.MedicalCode
  11967. order.HosplistName = subItem.HisProject.ProjectName
  11968. order.HilistLv = "1"
  11969. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11970. order.HosplistCode = subItem.HisProject.MedicalCode
  11971. order.HosplistName = subItem.HisProject.ProjectName
  11972. order.Cnt = subItem.Count
  11973. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11974. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11975. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11976. order.OwnpayAmt = ""
  11977. order.SelfpayAmt = ""
  11978. order.Spec = ""
  11979. order.SpecUnt = ""
  11980. order.DrordBegnDate = s_tm
  11981. order.DrordStopDate = ""
  11982. order.DrordDrCodg = doctor_info.DoctorNumber
  11983. order.DrordDeptName = department.Name
  11984. order.DrordDeptCodg = department.Number
  11985. order.DrordDrName = doctor_info.UserName
  11986. order.DrordDrProfttl = "234"
  11987. order.CurrDrordFlag = "1"
  11988. orders = append(orders, &order)
  11989. }
  11990. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11991. var order models.FsiOrderDtos
  11992. order.RxID = strconv.FormatInt(item.ID, 10)
  11993. order.Rxno = strconv.FormatInt(item.ID, 10)
  11994. order.LongDrordFlag = "0"
  11995. order.HilistType = "301"
  11996. order.ChrgType = "1"
  11997. order.DrordBhvr = "0"
  11998. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11999. order.HosplistName = subItem.GoodInfo.GoodName
  12000. order.HilistLv = "1"
  12001. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12002. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12003. order.HosplistName = subItem.GoodInfo.GoodName
  12004. order.Cnt = subItem.Count
  12005. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12006. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12007. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12008. order.OwnpayAmt = ""
  12009. order.SelfpayAmt = ""
  12010. order.Spec = ""
  12011. order.SpecUnt = ""
  12012. order.DrordBegnDate = s_tm
  12013. order.DrordStopDate = ""
  12014. order.DrordDrCodg = doctor_info.DoctorNumber
  12015. order.DrordDeptName = department.Name
  12016. order.DrordDeptCodg = department.Number
  12017. order.DrordDrName = doctor_info.UserName
  12018. order.DrordDrProfttl = "234"
  12019. order.CurrDrordFlag = "1"
  12020. orders = append(orders, &order)
  12021. }
  12022. }
  12023. }
  12024. //处方医嘱信息
  12025. fed.MatnStas = "0"
  12026. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12027. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12028. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12029. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12030. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12031. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12032. fed.SetlTotlnum = "1"
  12033. fed.Insutype = his.Insutype
  12034. fed.ReimFlag = "0"
  12035. fed.OutSetlFlag = "0"
  12036. var fopd []*models.FsiOperationDtosData
  12037. data := make(map[string]interface{})
  12038. data["fed"] = fed
  12039. data["fdd"] = fdds
  12040. data["fod"] = orders
  12041. data["pd"] = pd
  12042. data["pp"] = pp
  12043. data["fopd"] = fopd
  12044. data["trig_scen"] = trig_scen
  12045. client := &http.Client{}
  12046. bytesData, _ := json.Marshal(data)
  12047. var req *http.Request
  12048. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12049. if miConfig.MdtrtareaAdmvs == "320830" {
  12050. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12051. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12052. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12053. } else {
  12054. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12055. }
  12056. resp, _ := client.Do(req)
  12057. defer resp.Body.Close()
  12058. body, ioErr := ioutil.ReadAll(resp.Body)
  12059. if ioErr != nil {
  12060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return res
  12063. }
  12064. var respJSON map[string]interface{}
  12065. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return res
  12069. }
  12070. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12071. result, _ := json.Marshal(respJSON)
  12072. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12073. utils.ErrorLog("解析失败:%v", err)
  12074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12075. return res
  12076. }
  12077. return res
  12078. } else {
  12079. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12080. saveLog(output, input, "3102", "事中")
  12081. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12082. utils.ErrorLog("解析失败:%v", err)
  12083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12084. return
  12085. }
  12086. return res
  12087. }
  12088. return res
  12089. }
  12090. 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) {
  12091. var res Resultgd3101
  12092. adminUser := c.GetAdminUserInfo()
  12093. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12094. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12095. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12096. //record_time := c.GetString("record_time")
  12097. //trig_scen := c.GetString("trig_scen")
  12098. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12099. //psn_info, _ := service.GetPatientId(patient_id)
  12100. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12101. timeLayout := "2006-01-02"
  12102. loc, _ := time.LoadLocation("Local")
  12103. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12104. if err != nil {
  12105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12106. return res
  12107. }
  12108. recordDateTime := theTime.Unix()
  12109. var patientPrescription models.HisPrescriptionInfo
  12110. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12111. //if patientPrescription.ID == 0 {
  12112. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12113. //}
  12114. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12115. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12116. //
  12117. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12118. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12119. var str string
  12120. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12121. str = timestampToBirthdayString(patient.Birthday)
  12122. } else {
  12123. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12124. }
  12125. var pp models.PublicParams
  12126. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12127. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12128. pp.FixmedinsName = miConfig.OrgName
  12129. pp.FixmedinsCode = miConfig.Code
  12130. pp.RequestUrl = miConfig.Url
  12131. pp.Cainfo = miConfig.Cainfo
  12132. pp.SecretKey = miConfig.SecretKey
  12133. pp.AccessKey = miConfig.AccessKey
  12134. pp.OpterName = roles.UserName
  12135. var config []*models.HisXtDiagnoseConfig
  12136. for _, item := range diagnosis_ids {
  12137. id, _ := strconv.ParseInt(item, 10, 64)
  12138. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12139. config = append(config, &diagnosisConfig)
  12140. }
  12141. if len(config) == 0 {
  12142. var config1 models.HisXtDiagnoseConfig
  12143. config1.CountryCode = "N18.500"
  12144. config1.CountryContentName = "慢性肾脏病5期"
  12145. config = append(config, &config1)
  12146. }
  12147. var pd models.PatientDtos
  12148. pd.PatnID = his.PsnNo
  12149. pd.PatnName = his.Name
  12150. pd.Gend = his.Gend
  12151. pd.Brdy = str
  12152. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12153. pd.CurrMdtrtID = his.Number
  12154. var fed models.FsiEncounterDtos
  12155. fed.MdtrtID = his.Number
  12156. fed.MedinsID = miConfig.Code
  12157. fed.MedinsName = miConfig.OrgName
  12158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12159. fed.MedMdtrtType = "1"
  12160. fed.MedinsType = "1"
  12161. fed.MedinsLv = "11"
  12162. tm := time.Unix(his.RecordDate, 0)
  12163. s_tm := tm.Format("2006-01-02 15:04:05")
  12164. fed.AdmDate = s_tm
  12165. fed.DscgDate = s_tm
  12166. fed.DscgMainDiseCodg = config[0].CountryCode
  12167. fed.DscgMainDiseName = config[0].CountryContentName
  12168. //诊断信息
  12169. var fdds []*models.FsiDiagnoseDtos
  12170. for index, item := range config {
  12171. if index == 0 {
  12172. var fdd models.FsiDiagnoseDtos
  12173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12174. fdd.InoutDiseType = "1"
  12175. fdd.MaindiseFlag = "1"
  12176. fdd.DiseDate = s_tm
  12177. fdd.DiasSrtNo = "1"
  12178. fdd.DiseName = item.CountryContentName
  12179. fdd.DiseCodg = item.CountryCode
  12180. fdds = append(fdds, &fdd)
  12181. } else {
  12182. var fdd models.FsiDiagnoseDtos
  12183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12184. fdd.InoutDiseType = "1"
  12185. fdd.MaindiseFlag = "1"
  12186. fdd.DiseDate = s_tm
  12187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12188. fdd.DiseName = item.CountryContentName
  12189. fdd.DiseCodg = item.CountryCode
  12190. fdds = append(fdds, &fdd)
  12191. }
  12192. }
  12193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12194. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12195. fed.AdmDeptName = de.Name
  12196. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12197. fed.DscgDeptName = de.Name
  12198. fed.MedMdtrtType = "1"
  12199. fed.MedType = "11"
  12200. //if his.Insutype == "390" {
  12201. // fed.MedType = "1402"
  12202. //} else {
  12203. // fed.MedType = "9933"
  12204. //}
  12205. var orders []*models.FsiOrderDtos
  12206. if trig_scen == "2" {
  12207. //处方医嘱信息
  12208. for _, item := range prescriptions {
  12209. for _, subItem := range item.HisDoctorAdviceInfo {
  12210. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12211. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12212. var order models.FsiOrderDtos
  12213. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12214. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12215. order.LongDrordFlag = "0"
  12216. order.HilistType = "101"
  12217. order.ChrgType = "1"
  12218. order.DrordBhvr = "0"
  12219. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12220. order.HosplistName = subItem.BaseDrugLib.DrugName
  12221. order.HilistLv = "1"
  12222. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12223. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12224. order.HosplistName = subItem.BaseDrugLib.DrugName
  12225. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12226. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12227. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12228. order.OwnpayAmt = ""
  12229. order.SelfpayAmt = ""
  12230. order.Spec = spec
  12231. order.SpecUnt = subItem.PrescribingNumberUnit
  12232. order.DrordBegnDate = s_tm
  12233. order.DrordStopDate = ""
  12234. order.DrordDrCodg = doctor_info.DoctorNumber
  12235. order.DrordDeptName = department.Name
  12236. order.DrordDeptCodg = department.Number
  12237. order.DrordDrName = doctor_info.UserName
  12238. order.DrordDrProfttl = "234"
  12239. order.CurrDrordFlag = "1"
  12240. orders = append(orders, &order)
  12241. }
  12242. }
  12243. for _, subItem := range item.HisPrescriptionProject {
  12244. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12245. var order models.FsiOrderDtos
  12246. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12247. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12248. order.LongDrordFlag = "0"
  12249. order.HilistType = "201"
  12250. order.ChrgType = "1"
  12251. order.DrordBhvr = "0"
  12252. order.HilistCode = subItem.HisProject.MedicalCode
  12253. order.HosplistName = subItem.HisProject.ProjectName
  12254. order.HilistLv = "1"
  12255. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12256. order.HosplistCode = subItem.HisProject.MedicalCode
  12257. order.HosplistName = subItem.HisProject.ProjectName
  12258. order.Cnt = subItem.Count
  12259. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12260. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12261. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12262. order.OwnpayAmt = ""
  12263. order.SelfpayAmt = ""
  12264. if subItem.Unit == "" {
  12265. order.Spec = "次"
  12266. order.SpecUnt = "次"
  12267. } else {
  12268. order.Spec = subItem.Unit
  12269. order.SpecUnt = subItem.Unit
  12270. }
  12271. order.DrordBegnDate = s_tm
  12272. order.DrordStopDate = ""
  12273. order.DrordDrCodg = doctor_info.DoctorNumber
  12274. order.DrordDeptName = department.Name
  12275. order.DrordDeptCodg = department.Number
  12276. order.DrordDrName = doctor_info.UserName
  12277. order.DrordDrProfttl = "234"
  12278. order.CurrDrordFlag = "1"
  12279. orders = append(orders, &order)
  12280. }
  12281. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12282. var order models.FsiOrderDtos
  12283. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12284. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12285. order.LongDrordFlag = "0"
  12286. order.HilistType = "301"
  12287. order.ChrgType = "1"
  12288. order.DrordBhvr = "0"
  12289. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12290. order.HosplistName = subItem.GoodInfo.GoodName
  12291. order.HilistLv = "1"
  12292. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12293. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12294. order.HosplistName = subItem.GoodInfo.GoodName
  12295. order.Cnt = subItem.Count
  12296. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12297. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12298. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12299. order.OwnpayAmt = ""
  12300. order.SelfpayAmt = ""
  12301. order.Spec = subItem.GoodInfo.SpecificationName
  12302. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12303. order.DrordBegnDate = s_tm
  12304. order.DrordStopDate = ""
  12305. order.DrordDrCodg = doctor_info.DoctorNumber
  12306. order.DrordDeptName = department.Name
  12307. order.DrordDeptCodg = department.Number
  12308. order.DrordDrName = doctor_info.UserName
  12309. order.DrordDrProfttl = "234"
  12310. order.CurrDrordFlag = "1"
  12311. orders = append(orders, &order)
  12312. }
  12313. }
  12314. }
  12315. //处方医嘱信息
  12316. }
  12317. fed.MatnStas = "0"
  12318. fed.MedfeeSumamt = "0"
  12319. fed.OwnpayAmt = "0"
  12320. fed.SelfpayAmt = "0"
  12321. fed.AcctPayamt = "0"
  12322. fed.MaAmt = "0"
  12323. fed.HifpPayamt = "0"
  12324. fed.SetlTotlnum = "1"
  12325. fed.Insutype = his.Insutype
  12326. fed.ReimFlag = "0"
  12327. fed.OutSetlFlag = "0"
  12328. var fopd []*models.FsiOperationDtosData
  12329. data := make(map[string]interface{})
  12330. data["fed"] = fed
  12331. data["fdd"] = fdds
  12332. data["fod"] = orders
  12333. data["pd"] = pd
  12334. data["pp"] = pp
  12335. data["fopd"] = fopd
  12336. data["trig_scen"] = trig_scen
  12337. fmt.Println(data)
  12338. fmt.Println(fed)
  12339. fmt.Println(fdds)
  12340. fmt.Println(orders)
  12341. fmt.Println(pd)
  12342. fmt.Println(pp)
  12343. fmt.Println(fopd)
  12344. client := &http.Client{}
  12345. bytesData, _ := json.Marshal(data)
  12346. var req *http.Request
  12347. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12348. if miConfig.MdtrtareaAdmvs == "320830" {
  12349. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12350. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12351. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12352. } else {
  12353. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12354. }
  12355. resp, _ := client.Do(req)
  12356. defer resp.Body.Close()
  12357. body, ioErr := ioutil.ReadAll(resp.Body)
  12358. if ioErr != nil {
  12359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12361. return res
  12362. }
  12363. var respJSON map[string]interface{}
  12364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12367. return res
  12368. }
  12369. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12370. fmt.Println(respJSON)
  12371. result, _ := json.Marshal(respJSON)
  12372. fmt.Println(result)
  12373. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12374. utils.ErrorLog("解析失败:%v", err)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return res
  12377. }
  12378. return res
  12379. } else {
  12380. //if miConfig.MdtrtareaAdmvs == "441202" {
  12381. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12382. saveLog(output, input, "3101", "事前")
  12383. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12384. utils.ErrorLog("解析失败:%v", err)
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. return
  12387. }
  12388. return res
  12389. //}
  12390. }
  12391. }
  12392. 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) {
  12393. adminUser := c.GetAdminUserInfo()
  12394. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12395. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12396. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12397. //record_time := c.GetString("record_time")
  12398. //trig_scen := c.GetString("trig_scen")
  12399. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12400. timeLayout := "2006-01-02"
  12401. loc, _ := time.LoadLocation("Local")
  12402. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12403. if err != nil {
  12404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12405. return res
  12406. }
  12407. recordDateTime := theTime.Unix()
  12408. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12409. var patientPrescription models.HisPrescriptionInfo
  12410. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12411. if patientPrescription.ID == 0 {
  12412. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12413. }
  12414. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12415. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12416. //
  12417. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12418. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12419. var pp models.PublicParams
  12420. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12421. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12422. pp.FixmedinsName = miConfig.OrgName
  12423. pp.FixmedinsCode = miConfig.Code
  12424. pp.RequestUrl = miConfig.Url
  12425. pp.Cainfo = miConfig.Cainfo
  12426. pp.SecretKey = miConfig.SecretKey
  12427. pp.AccessKey = miConfig.AccessKey
  12428. pp.OpterName = roles.UserName
  12429. var config []*models.HisXtDiagnoseConfig
  12430. for _, item := range diagnosis_ids {
  12431. id, _ := strconv.ParseInt(item, 10, 64)
  12432. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12433. config = append(config, &diagnosisConfig)
  12434. }
  12435. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12436. var str string
  12437. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12438. str = timestampToBirthdayString(patient.Birthday)
  12439. } else {
  12440. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12441. }
  12442. var pd models.PatientDtos
  12443. pd.PatnID = his.PsnNo
  12444. pd.PatnName = his.Name
  12445. pd.Gend = his.Gend
  12446. pd.Brdy = str
  12447. pd.Poolarea = his.InsuplcAdmdvs
  12448. pd.CurrMdtrtID = his.Number
  12449. var fed models.FsiEncounterDtos
  12450. fed.MdtrtID = his.Number
  12451. fed.MedinsID = miConfig.Code
  12452. fed.MedinsName = miConfig.OrgName
  12453. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12454. fed.MedMdtrtType = "1"
  12455. fed.MedinsType = "1"
  12456. fed.MedinsLv = "11"
  12457. tm := time.Unix(his.RecordDate, 0)
  12458. s_tm := tm.Format("2006-01-02 15:04:05")
  12459. fed.AdmDate = s_tm
  12460. fed.DscgDate = s_tm
  12461. fed.DscgMainDiseCodg = config[0].CountryCode
  12462. fed.DscgMainDiseName = config[0].CountryContentName
  12463. //诊断信息
  12464. var fdds []*models.FsiDiagnoseDtos
  12465. for index, item := range config {
  12466. if index == 0 {
  12467. var fdd models.FsiDiagnoseDtos
  12468. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12469. fdd.InoutDiseType = "1"
  12470. fdd.MaindiseFlag = "1"
  12471. fdd.DiseDate = s_tm
  12472. fdd.DiasSrtNo = "1"
  12473. fdd.DiseName = item.CountryContentName
  12474. fdd.DiseCodg = item.CountryCode
  12475. fdds = append(fdds, &fdd)
  12476. } else {
  12477. var fdd models.FsiDiagnoseDtos
  12478. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12479. fdd.InoutDiseType = "1"
  12480. fdd.MaindiseFlag = "1"
  12481. fdd.DiseDate = s_tm
  12482. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12483. fdd.DiseName = item.CountryContentName
  12484. fdd.DiseCodg = item.CountryCode
  12485. fdds = append(fdds, &fdd)
  12486. }
  12487. }
  12488. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12489. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12490. fed.AdmDeptName = department.Name
  12491. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12492. fed.DscgDeptName = department.Name
  12493. fed.MedMdtrtType = "1"
  12494. fed.MedType = "11"
  12495. //if his.Insutype == "390" {
  12496. // fed.MedType = "1402"
  12497. //} else {
  12498. // fed.MedType = "9933"
  12499. //}
  12500. var orders []*models.FsiOrderDtos
  12501. if trig_scen == "2" {
  12502. //处方医嘱信息
  12503. for _, item := range prescriptions {
  12504. for _, subItem := range item.HisDoctorAdviceInfo {
  12505. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12506. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "/" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit
  12507. var order models.FsiOrderDtos
  12508. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12509. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12510. order.LongDrordFlag = "0"
  12511. order.HilistType = "101"
  12512. order.ChrgType = "1"
  12513. order.DrordBhvr = "0"
  12514. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12515. order.HosplistName = subItem.BaseDrugLib.DrugName
  12516. order.HilistLv = "1"
  12517. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12518. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12519. order.HosplistName = subItem.BaseDrugLib.DrugName
  12520. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12521. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12522. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12523. order.OwnpayAmt = ""
  12524. order.SelfpayAmt = ""
  12525. order.Spec = spec
  12526. order.SpecUnt = subItem.PrescribingNumberUnit
  12527. order.DrordBegnDate = s_tm
  12528. order.DrordStopDate = ""
  12529. order.DrordDrCodg = doctor_info.DoctorNumber
  12530. order.DrordDeptName = department.Name
  12531. order.DrordDeptCodg = department.Number
  12532. order.DrordDrName = doctor_info.UserName
  12533. order.DrordDrProfttl = "234"
  12534. order.CurrDrordFlag = "1"
  12535. orders = append(orders, &order)
  12536. }
  12537. }
  12538. for _, subItem := range item.HisPrescriptionProject {
  12539. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12540. var order models.FsiOrderDtos
  12541. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12542. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12543. order.LongDrordFlag = "0"
  12544. order.HilistType = "201"
  12545. order.ChrgType = "1"
  12546. order.DrordBhvr = "0"
  12547. order.HilistCode = subItem.HisProject.MedicalCode
  12548. order.HosplistName = subItem.HisProject.ProjectName
  12549. order.HilistLv = "1"
  12550. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12551. order.HosplistCode = subItem.HisProject.MedicalCode
  12552. order.HosplistName = subItem.HisProject.ProjectName
  12553. order.Cnt = subItem.Count
  12554. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12555. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12556. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12557. order.OwnpayAmt = ""
  12558. order.SelfpayAmt = ""
  12559. if subItem.Unit == "" {
  12560. order.Spec = "次"
  12561. order.SpecUnt = "次"
  12562. } else {
  12563. order.Spec = subItem.Unit
  12564. order.SpecUnt = subItem.Unit
  12565. }
  12566. order.DrordBegnDate = s_tm
  12567. order.DrordStopDate = ""
  12568. order.DrordDrCodg = doctor_info.DoctorNumber
  12569. order.DrordDeptName = department.Name
  12570. order.DrordDeptCodg = department.Number
  12571. order.DrordDrName = doctor_info.UserName
  12572. order.DrordDrProfttl = "234"
  12573. order.CurrDrordFlag = "1"
  12574. orders = append(orders, &order)
  12575. }
  12576. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12577. var order models.FsiOrderDtos
  12578. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12579. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12580. order.LongDrordFlag = "0"
  12581. order.HilistType = "301"
  12582. order.ChrgType = "1"
  12583. order.DrordBhvr = "0"
  12584. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12585. order.HosplistName = subItem.GoodInfo.GoodName
  12586. order.HilistLv = "1"
  12587. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12588. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12589. order.HosplistName = subItem.GoodInfo.GoodName
  12590. order.Cnt = subItem.Count
  12591. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12592. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12593. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12594. order.OwnpayAmt = ""
  12595. order.SelfpayAmt = ""
  12596. order.Spec = subItem.GoodInfo.SpecificationName
  12597. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12598. order.DrordBegnDate = s_tm
  12599. order.DrordStopDate = ""
  12600. order.DrordDrCodg = doctor_info.DoctorNumber
  12601. order.DrordDeptName = department.Name
  12602. order.DrordDeptCodg = department.Number
  12603. order.DrordDrName = doctor_info.UserName
  12604. order.DrordDrProfttl = "234"
  12605. order.CurrDrordFlag = "1"
  12606. orders = append(orders, &order)
  12607. }
  12608. }
  12609. }
  12610. //处方医嘱信息
  12611. }
  12612. fed.MatnStas = "0"
  12613. fed.MedfeeSumamt = "0"
  12614. fed.OwnpayAmt = "0"
  12615. fed.SelfpayAmt = "0"
  12616. fed.AcctPayamt = "0"
  12617. fed.MaAmt = "0"
  12618. fed.HifpPayamt = "0"
  12619. fed.SetlTotlnum = "1"
  12620. fed.Insutype = his.Insutype
  12621. fed.ReimFlag = "0"
  12622. fed.OutSetlFlag = "0"
  12623. var fopd []*models.FsiOperationDtosData
  12624. data := make(map[string]interface{})
  12625. data["fed"] = fed
  12626. data["fdd"] = fdds
  12627. data["fod"] = orders
  12628. data["pd"] = pd
  12629. data["pp"] = pp
  12630. data["fopd"] = fopd
  12631. data["trig_scen"] = trig_scen
  12632. fmt.Println(data)
  12633. fmt.Println(fed)
  12634. fmt.Println(fdds)
  12635. fmt.Println(orders)
  12636. fmt.Println(pd)
  12637. fmt.Println(pp)
  12638. fmt.Println(fopd)
  12639. client := &http.Client{}
  12640. bytesData, _ := json.Marshal(data)
  12641. var req *http.Request
  12642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12643. if miConfig.MdtrtareaAdmvs == "320830" {
  12644. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12645. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12646. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12647. } else {
  12648. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12649. }
  12650. resp, _ := client.Do(req)
  12651. defer resp.Body.Close()
  12652. body, ioErr := ioutil.ReadAll(resp.Body)
  12653. if ioErr != nil {
  12654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12656. return res
  12657. }
  12658. var respJSON map[string]interface{}
  12659. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12662. return res
  12663. }
  12664. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12665. fmt.Println(respJSON)
  12666. result, _ := json.Marshal(respJSON)
  12667. fmt.Println(result)
  12668. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12669. utils.ErrorLog("解析失败:%v", err)
  12670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12671. return res
  12672. }
  12673. return res
  12674. } else {
  12675. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12676. saveLog(output, input, "3101", "事前")
  12677. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12678. utils.ErrorLog("解析失败:%v", err)
  12679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12680. return
  12681. }
  12682. return res
  12683. }
  12684. return res
  12685. }
  12686. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12687. adminUser := c.GetAdminUserInfo()
  12688. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12689. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12691. record_time := c.GetString("record_time")
  12692. order, _ := service.GetHisOrderByID(order_id)
  12693. timeLayout := "2006-01-02"
  12694. loc, _ := time.LoadLocation("Local")
  12695. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12696. if err != nil {
  12697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12698. return
  12699. }
  12700. recordDateTime := theTime.Unix()
  12701. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12702. var patientPrescription models.HisPrescriptionInfo
  12703. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12704. if patientPrescription.ID == 0 {
  12705. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12706. }
  12707. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12708. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12709. //
  12710. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12711. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12712. var pp models.PublicParams
  12713. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12714. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12715. pp.FixmedinsName = miConfig.OrgName
  12716. pp.FixmedinsCode = miConfig.Code
  12717. pp.RequestUrl = miConfig.Url
  12718. pp.Cainfo = miConfig.Cainfo
  12719. pp.SecretKey = miConfig.SecretKey
  12720. pp.AccessKey = miConfig.AccessKey
  12721. pp.OpterName = roles.UserName
  12722. var config []*models.HisXtDiagnoseConfig
  12723. for _, item := range diagnosis_ids {
  12724. id, _ := strconv.ParseInt(item, 10, 64)
  12725. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12726. config = append(config, &diagnosisConfig)
  12727. }
  12728. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12729. var str string
  12730. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12731. str = timestampToBirthdayString(patient.Birthday)
  12732. } else {
  12733. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12734. }
  12735. var pd models.PatientDtos
  12736. pd.PatnID = his.PsnNo
  12737. pd.PatnName = his.Name
  12738. pd.Gend = his.Gend
  12739. pd.Brdy = str
  12740. pd.Poolarea = his.InsuplcAdmdvs
  12741. pd.CurrMdtrtID = his.Number
  12742. var fed models.FsiEncounterDtos
  12743. fed.MdtrtID = his.Number
  12744. fed.MedinsID = miConfig.Code
  12745. fed.MedinsName = miConfig.OrgName
  12746. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12747. fed.MedMdtrtType = "1"
  12748. fed.MedinsType = "1"
  12749. fed.MedinsLv = "11"
  12750. tm := time.Unix(his.RecordDate, 0)
  12751. s_tm := tm.Format("2006-01-02 15:04:05")
  12752. fed.AdmDate = s_tm
  12753. fed.DscgDate = s_tm
  12754. fed.DscgMainDiseCodg = config[0].CountryCode
  12755. fed.DscgMainDiseName = config[0].CountryContentName
  12756. //诊断信息
  12757. var fdds []*models.FsiDiagnoseDtos
  12758. for index, item := range config {
  12759. if index == 0 {
  12760. var fdd models.FsiDiagnoseDtos
  12761. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12762. fdd.InoutDiseType = "1"
  12763. fdd.MaindiseFlag = "1"
  12764. fdd.DiseDate = s_tm
  12765. fdd.DiasSrtNo = "1"
  12766. fdd.DiseName = item.CountryContentName
  12767. fdd.DiseCodg = item.CountryCode
  12768. fdds = append(fdds, &fdd)
  12769. } else {
  12770. var fdd models.FsiDiagnoseDtos
  12771. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12772. fdd.InoutDiseType = "1"
  12773. fdd.MaindiseFlag = "1"
  12774. fdd.DiseDate = s_tm
  12775. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12776. fdd.DiseName = item.CountryContentName
  12777. fdd.DiseCodg = item.CountryCode
  12778. fdds = append(fdds, &fdd)
  12779. }
  12780. }
  12781. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12782. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12783. fed.AdmDeptName = department.Name
  12784. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12785. fed.DscgDeptName = department.Name
  12786. fed.MedType = order.MedType
  12787. //处方医嘱信息
  12788. var orders []*models.FsiOrderDtos
  12789. //for _, item := range prescriptions {
  12790. // for _, subItem := range item.HisDoctorAdviceInfo {
  12791. // var order models.FsiOrderDtos
  12792. // order.RxID = strconv.FormatInt(item.ID, 10)
  12793. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12794. // order.LongDrordFlag = "0"
  12795. // order.HilistType = "1"
  12796. // order.ChrgType = "1"
  12797. // order.DrordBhvr = "-"
  12798. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12799. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12800. // order.HilistLv = "1"
  12801. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12802. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12803. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12804. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12805. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12806. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12807. // order.OwnpayAmt = ""
  12808. // order.SelfpayAmt = ""
  12809. // order.Spec = ""
  12810. // order.SpecUnt = ""
  12811. // order.DrordBegnDate = s_tm
  12812. // order.DrordStopDate = ""
  12813. // order.DrordDrCodg = "1"
  12814. // order.DrordDeptName = department.Name
  12815. // order.DrordDrCodg = "1"
  12816. // order.DrordDrName = doctor_info.UserName
  12817. // order.DrordDrProfttl = ""
  12818. // order.CurrDrordFlag = "1"
  12819. // orders = append(orders, &order)
  12820. // }
  12821. // for _, subItem := range item.HisPrescriptionProject {
  12822. // if subItem.Type == 2 {
  12823. // var order models.FsiOrderDtos
  12824. // order.RxID = strconv.FormatInt(item.ID, 10)
  12825. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12826. // order.LongDrordFlag = "0"
  12827. // order.HilistType = "1"
  12828. // order.ChrgType = "1"
  12829. // order.DrordBhvr = "-"
  12830. // order.HilistCode = subItem.HisProject.MedicalCode
  12831. // order.HosplistName = subItem.HisProject.ProjectName
  12832. // order.HilistLv = "1"
  12833. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12834. // order.HosplistCode = subItem.HisProject.MedicalCode
  12835. // order.HosplistName = subItem.HisProject.ProjectName
  12836. // order.Cnt = subItem.Count
  12837. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12838. //
  12839. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12840. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12841. // order.OwnpayAmt = ""
  12842. // order.SelfpayAmt = ""
  12843. // order.Spec = ""
  12844. // order.SpecUnt = ""
  12845. // order.DrordBegnDate = s_tm
  12846. // order.DrordStopDate = ""
  12847. // order.DrordDrCodg = "1"
  12848. // order.DrordDeptName = department.Name
  12849. // order.DrordDrCodg = "1"
  12850. // order.DrordDrName = doctor_info.UserName
  12851. // order.DrordDrProfttl = ""
  12852. // order.CurrDrordFlag = "1"
  12853. // orders = append(orders, &order)
  12854. //
  12855. // }
  12856. // if subItem.Type == 3 {
  12857. //
  12858. // var order models.FsiOrderDtos
  12859. // order.RxID = strconv.FormatInt(item.ID, 10)
  12860. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12861. // order.LongDrordFlag = "0"
  12862. // order.HilistType = "1"
  12863. // order.ChrgType = "1"
  12864. // order.DrordBhvr = "-"
  12865. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12866. // order.HosplistName = subItem.GoodInfo.GoodName
  12867. // order.HilistLv = "1"
  12868. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12869. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12870. // order.HosplistName = subItem.GoodInfo.GoodName
  12871. // order.Cnt = subItem.Count
  12872. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12873. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12874. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12875. // order.OwnpayAmt = ""
  12876. // order.SelfpayAmt = ""
  12877. // order.Spec = ""
  12878. // order.SpecUnt = ""
  12879. // order.DrordBegnDate = s_tm
  12880. // order.DrordStopDate = ""
  12881. // order.DrordDrCodg = "1"
  12882. // order.DrordDeptName = department.Name
  12883. // order.DrordDrCodg = "1"
  12884. // order.DrordDrName = doctor_info.UserName
  12885. // order.DrordDrProfttl = ""
  12886. // order.CurrDrordFlag = "1"
  12887. // orders = append(orders, &order)
  12888. //
  12889. // }
  12890. // }
  12891. //}
  12892. for _, item := range prescriptions {
  12893. for _, subItem := range item.HisDoctorAdviceInfo {
  12894. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12895. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12896. var order models.FsiOrderDtos
  12897. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12898. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12899. order.LongDrordFlag = "0"
  12900. order.HilistType = "101"
  12901. order.ChrgType = "01"
  12902. order.DrordBhvr = "0"
  12903. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12904. order.HosplistName = subItem.BaseDrugLib.DrugName
  12905. order.HilistLv = "1"
  12906. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12907. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12908. order.HosplistName = subItem.BaseDrugLib.DrugName
  12909. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12910. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12911. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12912. order.OwnpayAmt = ""
  12913. order.SelfpayAmt = ""
  12914. order.Spec = spec
  12915. order.SpecUnt = subItem.PrescribingNumberUnit
  12916. order.DrordBegnDate = s_tm
  12917. order.DrordStopDate = ""
  12918. order.DrordDrCodg = doctor_info.DoctorNumber
  12919. order.DrordDeptName = department.Name
  12920. order.DrordDeptCodg = department.Number
  12921. order.DrordDrName = doctor_info.UserName
  12922. order.DrordDrProfttl = "234"
  12923. order.CurrDrordFlag = "1"
  12924. orders = append(orders, &order)
  12925. }
  12926. }
  12927. for _, subItem := range item.HisPrescriptionProject {
  12928. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12929. var order models.FsiOrderDtos
  12930. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12931. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12932. order.LongDrordFlag = "0"
  12933. order.HilistType = "201"
  12934. order.ChrgType = "05"
  12935. order.DrordBhvr = "0"
  12936. order.HilistCode = subItem.HisProject.MedicalCode
  12937. order.HosplistName = subItem.HisProject.ProjectName
  12938. order.HilistLv = "1"
  12939. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12940. order.HosplistCode = subItem.HisProject.MedicalCode
  12941. order.HosplistName = subItem.HisProject.ProjectName
  12942. order.Cnt = subItem.Count
  12943. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12944. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12945. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12946. order.OwnpayAmt = ""
  12947. order.SelfpayAmt = ""
  12948. if subItem.Unit == "" {
  12949. order.Spec = "次"
  12950. order.SpecUnt = "次"
  12951. } else {
  12952. order.Spec = subItem.Unit
  12953. order.SpecUnt = subItem.Unit
  12954. }
  12955. order.DrordBegnDate = s_tm
  12956. order.DrordStopDate = ""
  12957. order.DrordDrCodg = doctor_info.DoctorNumber
  12958. order.DrordDeptName = department.Name
  12959. order.DrordDeptCodg = department.Number
  12960. order.DrordDrName = doctor_info.UserName
  12961. order.DrordDrProfttl = "234"
  12962. order.CurrDrordFlag = "1"
  12963. orders = append(orders, &order)
  12964. }
  12965. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12966. var order models.FsiOrderDtos
  12967. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12968. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12969. order.LongDrordFlag = "0"
  12970. order.HilistType = "301"
  12971. order.ChrgType = "08"
  12972. order.DrordBhvr = "0"
  12973. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12974. order.HosplistName = subItem.GoodInfo.GoodName
  12975. order.HilistLv = "1"
  12976. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12977. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12978. order.HosplistName = subItem.GoodInfo.GoodName
  12979. order.Cnt = subItem.Count
  12980. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12981. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12982. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12983. order.OwnpayAmt = ""
  12984. order.SelfpayAmt = ""
  12985. order.Spec = subItem.GoodInfo.SpecificationName
  12986. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12987. order.DrordBegnDate = s_tm
  12988. order.DrordStopDate = ""
  12989. order.DrordDrCodg = doctor_info.DoctorNumber
  12990. order.DrordDeptName = department.Name
  12991. order.DrordDeptCodg = department.Number
  12992. order.DrordDrName = doctor_info.UserName
  12993. order.DrordDrProfttl = "234"
  12994. order.CurrDrordFlag = "1"
  12995. orders = append(orders, &order)
  12996. }
  12997. }
  12998. }
  12999. //处方医嘱信息
  13000. fed.MatnStas = "0"
  13001. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  13002. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  13003. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  13004. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  13005. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  13006. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  13007. fed.SetlTotlnum = "1"
  13008. fed.Insutype = his.Insutype
  13009. fed.ReimFlag = "0"
  13010. fed.OutSetlFlag = "0"
  13011. var fopd []*models.FsiOperationDtosData
  13012. data := make(map[string]interface{})
  13013. data["fed"] = fed
  13014. data["fdd"] = fdds
  13015. data["fod"] = orders
  13016. data["pd"] = pd
  13017. data["pp"] = pp
  13018. data["fopd"] = fopd
  13019. data["trig_scen"] = trig_scen
  13020. client := &http.Client{}
  13021. bytesData, _ := json.Marshal(data)
  13022. var req *http.Request
  13023. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13024. if miConfig.MdtrtareaAdmvs == "320830" {
  13025. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  13026. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13027. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13028. } else {
  13029. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13030. }
  13031. resp, _ := client.Do(req)
  13032. defer resp.Body.Close()
  13033. body, ioErr := ioutil.ReadAll(resp.Body)
  13034. if ioErr != nil {
  13035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13037. return res
  13038. }
  13039. var respJSON map[string]interface{}
  13040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13043. return res
  13044. }
  13045. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13046. result, _ := json.Marshal(respJSON)
  13047. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13048. utils.ErrorLog("解析失败:%v", err)
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return res
  13051. }
  13052. return res
  13053. } else {
  13054. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  13055. saveLog(output, input, "3102", "事中")
  13056. if err := json.Unmarshal([]byte(output), &res); err != nil {
  13057. utils.ErrorLog("解析失败:%v", err)
  13058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13059. return
  13060. }
  13061. return res
  13062. }
  13063. return res
  13064. }
  13065. func (c *HisApiController) Check() {
  13066. psn_no := c.GetString("psn_no")
  13067. in := c.GetString("in")
  13068. mt := c.GetString("mt")
  13069. baseParams := models.BaseParams{
  13070. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  13071. FixmedinsCode: "H15049901371",
  13072. InsuplcAdmdvs: "150404",
  13073. MdtrtareaAdmvs: "150404",
  13074. OrgName: "赤峰费森血液透析中心",
  13075. Doctor: "1111",
  13076. }
  13077. service.Gdyb2001(baseParams, psn_no, in, mt)
  13078. }
  13079. func (c *HisApiController) GetPsnNcdsInfo() {
  13080. admin_user_id, _ := c.GetInt64("admin_user_id")
  13081. patient_id, _ := c.GetInt64("patient_id")
  13082. //id, _ := c.GetInt64("id")
  13083. adminUser := c.GetAdminUserInfo()
  13084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13085. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13086. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13087. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13088. //psn_record, _ := service.GetP(id)
  13089. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13090. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  13091. //
  13092. //if psn_record.ID == 0 {
  13093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13094. // return
  13095. //}
  13096. var res Result5301
  13097. var res10265 Result5301For10265
  13098. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13099. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13100. var api string
  13101. if miConfig.MdtrtareaAdmvs == "320830" {
  13102. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13103. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13104. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13105. 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 +
  13106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13107. } else {
  13108. 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 +
  13109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13110. }
  13111. resp, requestErr := http.Get(api)
  13112. if requestErr != nil {
  13113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13114. return
  13115. }
  13116. body, ioErr := ioutil.ReadAll(resp.Body)
  13117. if ioErr != nil {
  13118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13120. return
  13121. }
  13122. var respJSON map[string]interface{}
  13123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13126. return
  13127. }
  13128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13129. result, _ := json.Marshal(respJSON)
  13130. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13131. utils.ErrorLog("解析失败:%v", err)
  13132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13133. return
  13134. }
  13135. res.ErrMsg = res10265.ErrMsg
  13136. res.Output = res10265.Output
  13137. res.InfRefmsgid = res10265.InfRefmsgid
  13138. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13139. res.Infcode = infocode
  13140. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13141. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13142. var api string
  13143. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13144. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13145. resp, requestErr := http.Get(api)
  13146. if requestErr != nil {
  13147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13148. return
  13149. }
  13150. body, ioErr := ioutil.ReadAll(resp.Body)
  13151. if ioErr != nil {
  13152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13154. return
  13155. }
  13156. var respJSON map[string]interface{}
  13157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13160. return
  13161. }
  13162. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13163. if status == "0" {
  13164. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13165. c.ServeSuccessJSON(map[string]interface{}{
  13166. "failed_code": -10,
  13167. "msg": err_msg,
  13168. })
  13169. return
  13170. }
  13171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13172. result, _ := json.Marshal(respJSON)
  13173. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13174. utils.ErrorLog("解析失败:%v", err)
  13175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13176. return
  13177. }
  13178. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13179. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13180. var api string
  13181. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13182. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13183. resp, requestErr := http.Get(api)
  13184. if requestErr != nil {
  13185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13186. return
  13187. }
  13188. body, ioErr := ioutil.ReadAll(resp.Body)
  13189. if ioErr != nil {
  13190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13192. return
  13193. }
  13194. var respJSON map[string]interface{}
  13195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13198. return
  13199. }
  13200. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13201. if status == "0" {
  13202. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13203. c.ServeSuccessJSON(map[string]interface{}{
  13204. "failed_code": -10,
  13205. "msg": err_msg,
  13206. })
  13207. return
  13208. }
  13209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13210. result, _ := json.Marshal(respJSON)
  13211. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13212. utils.ErrorLog("解析失败:%v", err)
  13213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13214. return
  13215. }
  13216. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13217. p, _ := service.GetHisPatientById(patient_id)
  13218. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13219. var dat map[string]interface{}
  13220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13221. fmt.Println(dat)
  13222. } else {
  13223. fmt.Println(err)
  13224. }
  13225. userJSONBytes, _ := json.Marshal(dat)
  13226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13227. utils.ErrorLog("解析失败:%v", err)
  13228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13229. return
  13230. }
  13231. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13232. p, _ := service.GetHisPatientById(patient_id)
  13233. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13234. var dat map[string]interface{}
  13235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13236. fmt.Println(dat)
  13237. } else {
  13238. fmt.Println(err)
  13239. }
  13240. userJSONBytes, _ := json.Marshal(dat)
  13241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13242. utils.ErrorLog("解析失败:%v", err)
  13243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13244. return
  13245. }
  13246. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13247. p, _ := service.GetHisPatientById(patient_id)
  13248. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13249. var dat map[string]interface{}
  13250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13251. fmt.Println(dat)
  13252. } else {
  13253. fmt.Println(err)
  13254. }
  13255. userJSONBytes, _ := json.Marshal(dat)
  13256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13257. utils.ErrorLog("解析失败:%v", err)
  13258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13259. return
  13260. }
  13261. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13262. p, _ := service.GetHisPatientById(patient_id)
  13263. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13264. var dat map[string]interface{}
  13265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13266. fmt.Println(dat)
  13267. } else {
  13268. fmt.Println(err)
  13269. }
  13270. userJSONBytes, _ := json.Marshal(dat)
  13271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13272. utils.ErrorLog("解析失败:%v", err)
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13274. return
  13275. }
  13276. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13277. p, _ := service.GetHisPatientById(patient_id)
  13278. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13279. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13280. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13281. resp, requestErr := http.Get(api)
  13282. if requestErr != nil {
  13283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13284. return
  13285. }
  13286. body, ioErr := ioutil.ReadAll(resp.Body)
  13287. if ioErr != nil {
  13288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13290. return
  13291. }
  13292. var respJSON map[string]interface{}
  13293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13296. return
  13297. }
  13298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13299. result, _ := json.Marshal(respJSON)
  13300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13301. utils.ErrorLog("解析失败:%v", err)
  13302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13303. return
  13304. }
  13305. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13306. p, _ := service.GetHisPatientById(patient_id)
  13307. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13308. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13309. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13310. resp, requestErr := http.Get(api)
  13311. if requestErr != nil {
  13312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13313. return
  13314. }
  13315. body, ioErr := ioutil.ReadAll(resp.Body)
  13316. if ioErr != nil {
  13317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13319. return
  13320. }
  13321. var respJSON map[string]interface{}
  13322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13325. return
  13326. }
  13327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13328. result, _ := json.Marshal(respJSON)
  13329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13330. utils.ErrorLog("解析失败:%v", err)
  13331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13332. return
  13333. }
  13334. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13335. p, _ := service.GetHisPatientById(patient_id)
  13336. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13337. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13338. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13339. resp, requestErr := http.Get(api)
  13340. if requestErr != nil {
  13341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13342. return
  13343. }
  13344. body, ioErr := ioutil.ReadAll(resp.Body)
  13345. if ioErr != nil {
  13346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13348. return
  13349. }
  13350. var respJSON map[string]interface{}
  13351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13354. return
  13355. }
  13356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13357. result, _ := json.Marshal(respJSON)
  13358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13359. utils.ErrorLog("解析失败:%v", err)
  13360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13361. return
  13362. }
  13363. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13364. p, _ := service.GetHisPatientById(patient_id)
  13365. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13366. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13367. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13368. resp, requestErr := http.Get(api)
  13369. if requestErr != nil {
  13370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13371. return
  13372. }
  13373. body, ioErr := ioutil.ReadAll(resp.Body)
  13374. if ioErr != nil {
  13375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13377. return
  13378. }
  13379. var respJSON map[string]interface{}
  13380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13383. return
  13384. }
  13385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13386. result, _ := json.Marshal(respJSON)
  13387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13388. utils.ErrorLog("解析失败:%v", err)
  13389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13390. return
  13391. }
  13392. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13393. p, _ := service.GetHisPatientById(patient_id)
  13394. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13395. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13396. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13397. resp, requestErr := http.Get(api)
  13398. if requestErr != nil {
  13399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13400. return
  13401. }
  13402. body, ioErr := ioutil.ReadAll(resp.Body)
  13403. if ioErr != nil {
  13404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. var respJSON map[string]interface{}
  13409. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13412. return
  13413. }
  13414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13415. result, _ := json.Marshal(respJSON)
  13416. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13417. utils.ErrorLog("解析失败:%v", err)
  13418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13419. return
  13420. }
  13421. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13422. p, _ := service.GetHisPatientById(patient_id)
  13423. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13424. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13425. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13426. resp, requestErr := http.Get(api)
  13427. if requestErr != nil {
  13428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13429. return
  13430. }
  13431. body, ioErr := ioutil.ReadAll(resp.Body)
  13432. if ioErr != nil {
  13433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13435. return
  13436. }
  13437. var respJSON map[string]interface{}
  13438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13441. return
  13442. }
  13443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13444. result, _ := json.Marshal(respJSON)
  13445. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13446. utils.ErrorLog("解析失败:%v", err)
  13447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13448. return
  13449. }
  13450. } else {
  13451. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13452. var dat map[string]interface{}
  13453. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13454. fmt.Println(dat)
  13455. } else {
  13456. fmt.Println(err)
  13457. }
  13458. userJSONBytes, _ := json.Marshal(dat)
  13459. if miConfig.Code == "H15049901371" {
  13460. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13461. utils.ErrorLog("解析失败:%v", err)
  13462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13463. return
  13464. }
  13465. res.InfRefmsgid = res10265.InfRefmsgid
  13466. res.Output = res10265.Output
  13467. res.ErrMsg = res10265.ErrMsg
  13468. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13469. res.Infcode = infocode
  13470. } else {
  13471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13472. utils.ErrorLog("解析失败:%v", err)
  13473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13474. return
  13475. }
  13476. }
  13477. }
  13478. if res.Infcode == 0 {
  13479. c.ServeSuccessJSON(map[string]interface{}{
  13480. "result": res.Output.Result,
  13481. })
  13482. }
  13483. }
  13484. func (c *HisApiController) CheckInsutype() {
  13485. his_patient_id, _ := c.GetInt64("his_patient_id")
  13486. admin_user_id, _ := c.GetInt64("admin_user_id")
  13487. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13488. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13490. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13491. var dat map[string]interface{}
  13492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13493. fmt.Println(dat)
  13494. } else {
  13495. fmt.Println(err)
  13496. }
  13497. userJSONBytes, _ := json.Marshal(dat)
  13498. var res Result90100
  13499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13500. utils.ErrorLog("解析失败:%v", err)
  13501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13502. return
  13503. }
  13504. if res.Infcode != 0 {
  13505. c.ServeSuccessJSON(map[string]interface{}{
  13506. "failed_code": -10,
  13507. "msg": res.ErrMsg,
  13508. })
  13509. return
  13510. } else {
  13511. fmt.Println(res)
  13512. }
  13513. }
  13514. func (c *HisApiController) CheckCardPWD() {
  13515. card_pwd := c.GetString("card_pwd")
  13516. his_patient_id, _ := c.GetInt64("his_patient_id")
  13517. admin_user_id, _ := c.GetInt64("admin_user_id")
  13518. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13519. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13520. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13521. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13522. bas := strings.Split(psn.CardInfo, "|")
  13523. basNumber := bas[2]
  13524. if psn.InsuplcAdmdvs[:4] == "4403" {
  13525. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13526. var dat map[string]interface{}
  13527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13528. fmt.Println(dat)
  13529. } else {
  13530. fmt.Println(err)
  13531. }
  13532. userJSONBytes, _ := json.Marshal(dat)
  13533. var res Result90991
  13534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13535. utils.ErrorLog("解析失败:%v", err)
  13536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13537. return
  13538. }
  13539. if res.Infcode != 0 {
  13540. c.ServeSuccessJSON(map[string]interface{}{
  13541. "failed_code": -10,
  13542. "msg": res.ErrMsg,
  13543. })
  13544. return
  13545. } else {
  13546. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13547. var msg string
  13548. switch res.Output.Result.CardStat {
  13549. case "00":
  13550. msg = "未激活"
  13551. break
  13552. case "10":
  13553. msg = "激活"
  13554. break
  13555. case "20":
  13556. msg = "窗口挂失"
  13557. break
  13558. case "21":
  13559. msg = "电话挂失"
  13560. break
  13561. case "22":
  13562. msg = "单位网上申报挂失"
  13563. break
  13564. case "23":
  13565. msg = "保健办挂失"
  13566. break
  13567. case "24":
  13568. msg = "个人网上挂失"
  13569. break
  13570. case "25":
  13571. msg = "网上服务大厅挂失"
  13572. break
  13573. case "30":
  13574. msg = "注销"
  13575. break
  13576. case "40":
  13577. msg = "回收"
  13578. break
  13579. case "99":
  13580. msg = "制卡中(无效卡)"
  13581. break
  13582. }
  13583. c.ServeSuccessJSON(map[string]interface{}{
  13584. "failed_code": -10,
  13585. "msg": msg,
  13586. })
  13587. return
  13588. } else {
  13589. c.ServeSuccessJSON(map[string]interface{}{
  13590. "msg": "校验成功",
  13591. })
  13592. return
  13593. }
  13594. }
  13595. } else {
  13596. c.ServeSuccessJSON(map[string]interface{}{
  13597. "msg": "校验成功",
  13598. })
  13599. return
  13600. }
  13601. }
  13602. func (c *HisApiController) CheckCardPWDTwo() {
  13603. //card_pwd := c.GetString("card_pwd")
  13604. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13605. admin_user_id, _ := c.GetInt64("admin_user_id")
  13606. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13607. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13608. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13609. var dat map[string]interface{}
  13610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13611. fmt.Println(dat)
  13612. } else {
  13613. fmt.Println(err)
  13614. }
  13615. userJSONBytes, _ := json.Marshal(dat)
  13616. var res Result90991
  13617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13618. utils.ErrorLog("解析失败:%v", err)
  13619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13620. return
  13621. }
  13622. if res.Infcode != 0 {
  13623. c.ServeSuccessJSON(map[string]interface{}{
  13624. "failed_code": -10,
  13625. "msg": res.ErrMsg,
  13626. })
  13627. return
  13628. } else {
  13629. if res.Output.Result.SscnoCheckStat == "0" {
  13630. var msg string
  13631. switch res.Output.Result.CardStat {
  13632. case "00":
  13633. msg = "未激活"
  13634. break
  13635. case "10":
  13636. msg = "激活"
  13637. break
  13638. case "20":
  13639. msg = "窗口挂失"
  13640. break
  13641. case "21":
  13642. msg = "电话挂失"
  13643. break
  13644. case "22":
  13645. msg = "单位网上申报挂失"
  13646. break
  13647. case "23":
  13648. msg = "保健办挂失"
  13649. break
  13650. case "24":
  13651. msg = "个人网上挂失"
  13652. break
  13653. case "25":
  13654. msg = "网上服务大厅挂失"
  13655. break
  13656. case "30":
  13657. msg = "注销"
  13658. break
  13659. case "40":
  13660. msg = "回收"
  13661. break
  13662. case "99":
  13663. msg = "制卡中(无效卡)"
  13664. break
  13665. }
  13666. c.ServeSuccessJSON(map[string]interface{}{
  13667. "failed_code": -10,
  13668. "msg": msg,
  13669. })
  13670. return
  13671. } else {
  13672. c.ServeSuccessJSON(map[string]interface{}{
  13673. "msg": "校验成功",
  13674. })
  13675. return
  13676. }
  13677. }
  13678. }
  13679. type ELeCertData struct {
  13680. Data struct {
  13681. Extra string `json:"extra"`
  13682. IDNo string `json:"idNo"`
  13683. IDType string `json:"idType"`
  13684. EcToken string `json:"ecToken"`
  13685. InsuOrg string `json:"insuOrg"`
  13686. UserName string `json:"userName"`
  13687. EcIndexNo string `json:"ecIndexNo"`
  13688. Gender string `json:"gender"`
  13689. Birthday string `json:"birthday"`
  13690. Nationality string `json:"nationality"`
  13691. Email string `json:"email"`
  13692. } `json:"OutData"`
  13693. }
  13694. func (c *HisApiController) ReadCard() {
  13695. id_card_type, _ := c.GetInt64("id_card_type")
  13696. admin_user_id, _ := c.GetInt64("admin_user_id")
  13697. certificates, _ := c.GetInt64("certificates")
  13698. //
  13699. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13700. id_card_no := c.GetString("id_card_no")
  13701. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13702. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13703. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13704. switch id_card_type {
  13705. case 1:
  13706. if miConfig.MdtrtareaAdmvs == "421300" {
  13707. var res ResultTwo
  13708. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13709. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13710. "&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)
  13711. resp, requestErr := http.Get(api)
  13712. if requestErr != nil {
  13713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13714. return
  13715. }
  13716. body, ioErr := ioutil.ReadAll(resp.Body)
  13717. if ioErr != nil {
  13718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13720. return
  13721. }
  13722. var respJSON map[string]interface{}
  13723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13726. return
  13727. }
  13728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13729. result, _ := json.Marshal(respJSON)
  13730. fmt.Println("log")
  13731. fmt.Println(string(result))
  13732. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13733. utils.ErrorLog("解析失败:%v", err)
  13734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13735. return
  13736. }
  13737. if res.Infcode == 0 {
  13738. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13739. if err == gorm.ErrRecordNotFound {
  13740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13741. return
  13742. } else if err != nil {
  13743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13744. return
  13745. } else {
  13746. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13747. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13748. infoStr := string(Iinfos)
  13749. idetinfoStr := string(Idetinfos)
  13750. var rf []*ResultFive
  13751. json.Unmarshal([]byte(infoStr), &rf)
  13752. var insutypes []*ResultFive
  13753. var insutype string
  13754. var is390 int = 0
  13755. var is310 int = 0
  13756. for _, item := range rf {
  13757. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13758. insutypes = append(insutypes, item)
  13759. }
  13760. }
  13761. if len(insutypes) == 1 {
  13762. insutype = insutypes[0].Insutype
  13763. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13764. } else {
  13765. for _, i := range insutypes {
  13766. if i.Insutype == "390" {
  13767. is390 = 1
  13768. }
  13769. if i.Insutype == "310" {
  13770. is310 = 1
  13771. }
  13772. }
  13773. }
  13774. if is390 == 1 {
  13775. insutype = "390"
  13776. }
  13777. if is310 == 1 {
  13778. insutype = "310"
  13779. }
  13780. if len(insutypes) == 0 {
  13781. insutype = "390"
  13782. }
  13783. var insuplc_admdvs string
  13784. for _, item := range rf {
  13785. if item.Insutype == insutype {
  13786. insuplc_admdvs = item.InsuplcAdmdvs
  13787. }
  13788. }
  13789. if strings.Contains(insuplc_admdvs, "4213") {
  13790. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13791. }
  13792. psn := &models.HisPsn{
  13793. PsnNo: res.Output.Baseinfo.PsnNo,
  13794. PatientId: patient.ID,
  13795. Certno: res.Output.Baseinfo.Certno,
  13796. Gend: res.Output.Baseinfo.Gend,
  13797. Naty: res.Output.Baseinfo.Naty,
  13798. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13799. PsnName: res.Output.Baseinfo.PsnName,
  13800. Idetinfo: idetinfoStr,
  13801. Insuinfo: infoStr,
  13802. InsuplcAdmdvs: insuplc_admdvs,
  13803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13804. }
  13805. service.CreateHisPsn(psn)
  13806. c.ServeSuccessJSON(map[string]interface{}{
  13807. "patient": patient,
  13808. "number": res.Output.Baseinfo.Certno,
  13809. })
  13810. }
  13811. } else {
  13812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13813. return
  13814. }
  13815. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13816. var res ResultTwo
  13817. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13818. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13819. "&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)
  13820. resp, requestErr := http.Get(api)
  13821. if requestErr != nil {
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13823. return
  13824. }
  13825. body, ioErr := ioutil.ReadAll(resp.Body)
  13826. if ioErr != nil {
  13827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13829. return
  13830. }
  13831. var respJSON map[string]interface{}
  13832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13835. return
  13836. }
  13837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13838. result, _ := json.Marshal(respJSON)
  13839. fmt.Println("log")
  13840. fmt.Println(string(result))
  13841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13842. utils.ErrorLog("解析失败:%v", err)
  13843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13844. return
  13845. }
  13846. if res.Infcode == 0 {
  13847. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13848. if err == gorm.ErrRecordNotFound {
  13849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13850. return
  13851. } else if err != nil {
  13852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13853. return
  13854. } else {
  13855. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13856. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13857. infoStr := string(Iinfos)
  13858. idetinfoStr := string(Idetinfos)
  13859. psn := &models.HisPsn{
  13860. PsnNo: res.Output.Baseinfo.PsnNo,
  13861. PatientId: patient.ID,
  13862. Certno: res.Output.Baseinfo.Certno,
  13863. Gend: res.Output.Baseinfo.Gend,
  13864. Naty: res.Output.Baseinfo.Naty,
  13865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13866. PsnName: res.Output.Baseinfo.PsnName,
  13867. Idetinfo: idetinfoStr,
  13868. Insuinfo: infoStr,
  13869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13870. }
  13871. service.CreateHisPsn(psn)
  13872. var rf []*ResultFive
  13873. json.Unmarshal([]byte(infoStr), &rf)
  13874. var insutypes []*ResultFive
  13875. var insutype string
  13876. var is390 int = 0
  13877. var is310 int = 0
  13878. for _, item := range rf {
  13879. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13880. insutypes = append(insutypes, item)
  13881. }
  13882. }
  13883. if len(insutypes) == 1 {
  13884. insutype = insutypes[0].Insutype
  13885. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13886. } else {
  13887. for _, i := range insutypes {
  13888. if i.Insutype == "390" {
  13889. is390 = 1
  13890. }
  13891. if i.Insutype == "310" {
  13892. is310 = 1
  13893. }
  13894. }
  13895. }
  13896. if is390 == 1 {
  13897. insutype = "390"
  13898. }
  13899. if is310 == 1 {
  13900. insutype = "310"
  13901. }
  13902. if len(insutypes) == 0 {
  13903. insutype = "310"
  13904. }
  13905. c.ServeSuccessJSON(map[string]interface{}{
  13906. "patient": patient,
  13907. "number": res.Output.Baseinfo.Certno,
  13908. "insutype": insutype,
  13909. })
  13910. }
  13911. } else {
  13912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13913. return
  13914. }
  13915. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13916. var res ResultTwo
  13917. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13918. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13919. "&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)
  13920. resp, requestErr := http.Get(api)
  13921. if requestErr != nil {
  13922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13923. return
  13924. }
  13925. body, ioErr := ioutil.ReadAll(resp.Body)
  13926. if ioErr != nil {
  13927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13929. return
  13930. }
  13931. var respJSON map[string]interface{}
  13932. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13935. return
  13936. }
  13937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13938. result, _ := json.Marshal(respJSON)
  13939. fmt.Println("log")
  13940. fmt.Println(string(result))
  13941. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13942. utils.ErrorLog("解析失败:%v", err)
  13943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13944. return
  13945. }
  13946. if res.Infcode == 0 {
  13947. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13948. if err == gorm.ErrRecordNotFound {
  13949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13950. return
  13951. } else if err != nil {
  13952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13953. return
  13954. } else {
  13955. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13956. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13957. infoStr := string(Iinfos)
  13958. idetinfoStr := string(Idetinfos)
  13959. var rf []*ResultFive
  13960. json.Unmarshal([]byte(infoStr), &rf)
  13961. var insutypes []*ResultFive
  13962. var insutype string
  13963. var is390 int = 0
  13964. var is310 int = 0
  13965. for _, item := range rf {
  13966. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13967. insutypes = append(insutypes, item)
  13968. }
  13969. }
  13970. if len(insutypes) == 1 {
  13971. insutype = insutypes[0].Insutype
  13972. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13973. } else {
  13974. for _, i := range insutypes {
  13975. if i.Insutype == "390" {
  13976. is390 = 1
  13977. }
  13978. if i.Insutype == "310" {
  13979. is310 = 1
  13980. }
  13981. }
  13982. }
  13983. if is390 == 1 {
  13984. insutype = "390"
  13985. }
  13986. if is310 == 1 {
  13987. insutype = "310"
  13988. }
  13989. if len(insutypes) == 0 {
  13990. insutype = "390"
  13991. }
  13992. var insuplc_admdvs string
  13993. for _, item := range rf {
  13994. if item.Insutype == insutype {
  13995. insuplc_admdvs = item.InsuplcAdmdvs
  13996. }
  13997. }
  13998. psn := &models.HisPsn{
  13999. PsnNo: res.Output.Baseinfo.PsnNo,
  14000. PatientId: patient.ID,
  14001. Certno: res.Output.Baseinfo.Certno,
  14002. Gend: res.Output.Baseinfo.Gend,
  14003. Naty: res.Output.Baseinfo.Naty,
  14004. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14005. PsnName: res.Output.Baseinfo.PsnName,
  14006. Idetinfo: idetinfoStr,
  14007. Insuinfo: infoStr,
  14008. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14009. InsuplcAdmdvs: insuplc_admdvs,
  14010. }
  14011. service.CreateHisPsn(psn)
  14012. for _, item := range rf {
  14013. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14014. insutypes = append(insutypes, item)
  14015. }
  14016. }
  14017. if len(insutypes) == 1 {
  14018. insutype = insutypes[0].Insutype
  14019. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14020. } else {
  14021. for _, i := range insutypes {
  14022. if i.Insutype == "390" {
  14023. is390 = 1
  14024. }
  14025. if i.Insutype == "310" {
  14026. is310 = 1
  14027. }
  14028. }
  14029. }
  14030. if is390 == 1 {
  14031. insutype = "390"
  14032. }
  14033. if is310 == 1 {
  14034. insutype = "310"
  14035. }
  14036. if len(insutypes) == 0 {
  14037. insutype = "310"
  14038. }
  14039. c.ServeSuccessJSON(map[string]interface{}{
  14040. "patient": patient,
  14041. "number": res.Output.Baseinfo.Certno,
  14042. "insutype": insutype,
  14043. })
  14044. }
  14045. } else {
  14046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14047. return
  14048. }
  14049. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14050. var res ResultTwo
  14051. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  14052. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14053. "&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)
  14054. resp, requestErr := http.Get(api)
  14055. if requestErr != nil {
  14056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14057. return
  14058. }
  14059. body, ioErr := ioutil.ReadAll(resp.Body)
  14060. if ioErr != nil {
  14061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14063. return
  14064. }
  14065. var respJSON map[string]interface{}
  14066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14069. return
  14070. }
  14071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14072. result, _ := json.Marshal(respJSON)
  14073. fmt.Println("log")
  14074. fmt.Println(string(result))
  14075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14076. utils.ErrorLog("解析失败:%v", err)
  14077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14078. return
  14079. }
  14080. if res.Infcode == 0 {
  14081. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14082. if err == gorm.ErrRecordNotFound {
  14083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14084. return
  14085. } else if err != nil {
  14086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14087. return
  14088. } else {
  14089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14091. infoStr := string(Iinfos)
  14092. idetinfoStr := string(Idetinfos)
  14093. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14094. psn := &models.HisPsn{
  14095. PsnNo: res.Output.Baseinfo.PsnNo,
  14096. PatientId: patient.ID,
  14097. Certno: res.Output.Baseinfo.Certno,
  14098. Brdy: b,
  14099. Age: float64(age),
  14100. Gend: res.Output.Baseinfo.Gend,
  14101. Naty: res.Output.Baseinfo.Naty,
  14102. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14103. PsnName: res.Output.Baseinfo.PsnName,
  14104. Idetinfo: idetinfoStr,
  14105. Insuinfo: infoStr,
  14106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14107. }
  14108. service.CreateHisPsn(psn)
  14109. var rf []*ResultFive
  14110. json.Unmarshal([]byte(infoStr), &rf)
  14111. var insutypes []*ResultFive
  14112. var insutype string
  14113. var is390 int = 0
  14114. var is310 int = 0
  14115. for _, item := range rf {
  14116. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14117. insutypes = append(insutypes, item)
  14118. }
  14119. }
  14120. if len(insutypes) == 1 {
  14121. insutype = insutypes[0].Insutype
  14122. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14123. } else {
  14124. for _, i := range insutypes {
  14125. if i.Insutype == "390" {
  14126. is390 = 1
  14127. }
  14128. if i.Insutype == "310" {
  14129. is310 = 1
  14130. }
  14131. }
  14132. }
  14133. if is390 == 1 {
  14134. insutype = "390"
  14135. }
  14136. if is310 == 1 {
  14137. insutype = "310"
  14138. }
  14139. if len(insutypes) == 0 {
  14140. insutype = "310"
  14141. }
  14142. c.ServeSuccessJSON(map[string]interface{}{
  14143. "patient": patient,
  14144. "number": res.Output.Baseinfo.Certno,
  14145. "insutype": insutype,
  14146. })
  14147. }
  14148. } else {
  14149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14150. return
  14151. }
  14152. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14153. var api string
  14154. if miConfig.MdtrtareaAdmvs == "320830" {
  14155. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14156. "&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
  14157. fmt.Println(api)
  14158. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14159. 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 +
  14160. "&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
  14161. fmt.Println(api)
  14162. } else {
  14163. 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 +
  14164. "&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)
  14165. }
  14166. resp, requestErr := http.Get(api)
  14167. if requestErr != nil {
  14168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14169. return
  14170. }
  14171. body, ioErr := ioutil.ReadAll(resp.Body)
  14172. if ioErr != nil {
  14173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. return
  14176. }
  14177. var respJSON map[string]interface{}
  14178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14181. return
  14182. }
  14183. var status string
  14184. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14185. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14186. //console.log()
  14187. fmt.Println("type===")
  14188. fmt.Println(card_type)
  14189. var token string
  14190. var res ResultTwo //1101结果
  14191. var res10265 ResultTwo10265 //1101结果
  14192. var card_info string //卡信息
  14193. var busi_card_info string
  14194. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14195. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14196. if status == "0" { //读卡成功
  14197. if card_type == "1" {
  14198. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14199. result, _ := json.Marshal(respJSON)
  14200. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14201. utils.ErrorLog("解析失败:%v", err)
  14202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14203. return
  14204. }
  14205. res.ErrMsg = res10265.ErrMsg
  14206. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14207. res.Infcode = infocode
  14208. res.Output = res10265.Output
  14209. res.InfRefmsgid = res10265.InfRefmsgid
  14210. } else {
  14211. //var card_info string //卡信息
  14212. //var busi_card_info string
  14213. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14214. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14215. //fmt.Println(card_info)
  14216. //fmt.Println(busi_card_info)
  14217. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14218. result, _ := json.Marshal(respJSON)
  14219. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14220. utils.ErrorLog("解析失败:%v", err)
  14221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14222. return
  14223. }
  14224. res.ErrMsg = res10265.ErrMsg
  14225. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14226. res.Infcode = infocode
  14227. res.Output = res10265.Output
  14228. res.InfRefmsgid = res10265.InfRefmsgid
  14229. }
  14230. if res.Infcode == 0 {
  14231. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14232. if err == gorm.ErrRecordNotFound {
  14233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14234. return
  14235. } else if err != nil {
  14236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14237. return
  14238. } else {
  14239. if card_type == "1" {
  14240. bas := strings.Split(card_info, "|")
  14241. basNumber := bas[2]
  14242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14243. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14244. infoStr := string(Iinfos)
  14245. idetinfoStr := string(Idetinfos)
  14246. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14247. psn := &models.HisPsn{
  14248. PsnNo: res.Output.Baseinfo.PsnNo,
  14249. PatientId: patient.ID,
  14250. Certno: res.Output.Baseinfo.Certno,
  14251. Brdy: b,
  14252. Age: float64(age),
  14253. Gend: res.Output.Baseinfo.Gend,
  14254. Naty: res.Output.Baseinfo.Naty,
  14255. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14256. PsnName: res.Output.Baseinfo.PsnName,
  14257. Idetinfo: idetinfoStr,
  14258. Insuinfo: infoStr,
  14259. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14260. CardInfo: card_info,
  14261. VerifyNumber: busi_card_info,
  14262. }
  14263. service.CreateHisPsn(psn)
  14264. var rf []*ResultFive
  14265. json.Unmarshal([]byte(infoStr), &rf)
  14266. var insutypes []*ResultFive
  14267. var insutype string
  14268. var is390 int = 0
  14269. var is310 int = 0
  14270. for _, item := range rf {
  14271. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14272. insutypes = append(insutypes, item)
  14273. }
  14274. }
  14275. if len(insutypes) == 1 {
  14276. insutype = insutypes[0].Insutype
  14277. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14278. } else {
  14279. for _, i := range insutypes {
  14280. if i.Insutype == "390" {
  14281. is390 = 1
  14282. }
  14283. if i.Insutype == "310" {
  14284. is310 = 1
  14285. }
  14286. }
  14287. }
  14288. if is390 == 1 {
  14289. insutype = "390"
  14290. }
  14291. if is310 == 1 {
  14292. insutype = "310"
  14293. }
  14294. if len(insutypes) == 0 {
  14295. insutype = "310"
  14296. }
  14297. c.ServeSuccessJSON(map[string]interface{}{
  14298. "patient": patient,
  14299. "number": basNumber,
  14300. "insutype": insutype,
  14301. })
  14302. } else {
  14303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14305. infoStr := string(Iinfos)
  14306. idetinfoStr := string(Idetinfos)
  14307. psn := &models.HisPsn{
  14308. PsnNo: res.Output.Baseinfo.PsnNo,
  14309. PatientId: patient.ID,
  14310. Certno: res.Output.Baseinfo.Certno,
  14311. Gend: res.Output.Baseinfo.Gend,
  14312. Naty: res.Output.Baseinfo.Naty,
  14313. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14314. PsnName: res.Output.Baseinfo.PsnName,
  14315. Idetinfo: idetinfoStr,
  14316. Insuinfo: infoStr,
  14317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14318. CardInfo: card_info,
  14319. VerifyNumber: token,
  14320. }
  14321. service.CreateHisPsn(psn)
  14322. c.ServeSuccessJSON(map[string]interface{}{
  14323. "patient": patient,
  14324. "number": token,
  14325. })
  14326. }
  14327. }
  14328. } else {
  14329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14330. return
  14331. }
  14332. } else { //读卡失败
  14333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14334. return
  14335. }
  14336. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14337. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14338. cardnum = DeleteExtraSpaceTwo(cardnum)
  14339. cardCode = DeleteExtraSpaceTwo(cardCode)
  14340. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14341. name = DeleteExtraSpaceTwo(name)
  14342. errmsg = DeleteExtraSpaceTwo(errmsg)
  14343. cardnum = Remove0000(cardnum)
  14344. cardCode = Remove0000(cardCode)
  14345. id_card_no = Remove0000(id_card_no)
  14346. name = Remove0000(name)
  14347. errmsg = Remove0000(errmsg)
  14348. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14349. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14350. //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)
  14351. //fmt.Println(result2)
  14352. //fmt.Println(requestLog2)
  14353. //fmt.Println(errMsgLog2)
  14354. 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)
  14355. saveLog(result, requestLog, "1101", "获取人员信息")
  14356. fmt.Println(errMsgLog)
  14357. if len(errMsgLog) > 0 {
  14358. } else {
  14359. var dat map[string]interface{}
  14360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14361. fmt.Println(dat)
  14362. } else {
  14363. fmt.Println(err)
  14364. }
  14365. userJSONBytes, _ := json.Marshal(dat)
  14366. var res ResultTwo
  14367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14368. utils.ErrorLog("解析失败:%v", err)
  14369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14370. return
  14371. }
  14372. res.ErrMsg = errMsgLog
  14373. if res.Infcode == 0 {
  14374. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14375. if err == gorm.ErrRecordNotFound {
  14376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14377. return
  14378. } else if err != nil {
  14379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14380. return
  14381. } else {
  14382. fmt.Println(res)
  14383. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14384. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14385. infoStr := string(Iinfos)
  14386. idetinfoStr := string(Idetinfos)
  14387. var rf []*ResultFive
  14388. json.Unmarshal([]byte(infoStr), &rf)
  14389. var insutypes []*ResultFive
  14390. var insutype string
  14391. var is390 int = 0
  14392. var is310 int = 0
  14393. for _, item := range rf {
  14394. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14395. insutypes = append(insutypes, item)
  14396. }
  14397. }
  14398. if len(insutypes) == 1 {
  14399. insutype = insutypes[0].Insutype
  14400. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14401. } else {
  14402. for _, i := range insutypes {
  14403. if i.Insutype == "390" {
  14404. is390 = 1
  14405. }
  14406. if i.Insutype == "310" {
  14407. is310 = 1
  14408. }
  14409. }
  14410. }
  14411. if is390 == 1 {
  14412. insutype = "390"
  14413. }
  14414. if is310 == 1 {
  14415. insutype = "310"
  14416. }
  14417. if len(insutypes) == 0 {
  14418. insutype = "390"
  14419. }
  14420. var insuplc_admdvs string
  14421. for _, item := range rf {
  14422. if item.Insutype == insutype {
  14423. insuplc_admdvs = item.InsuplcAdmdvs
  14424. }
  14425. }
  14426. psn := &models.HisPsn{
  14427. PsnNo: res.Output.Baseinfo.PsnNo,
  14428. PatientId: patient.ID,
  14429. Certno: res.Output.Baseinfo.Certno,
  14430. Gend: res.Output.Baseinfo.Gend,
  14431. Naty: res.Output.Baseinfo.Naty,
  14432. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14433. PsnName: res.Output.Baseinfo.PsnName,
  14434. Idetinfo: idetinfoStr,
  14435. Insuinfo: infoStr,
  14436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14437. CardInfo: basStr,
  14438. VerifyNumber: "",
  14439. InsuplcAdmdvs: insuplc_admdvs,
  14440. }
  14441. service.CreateHisPsn(psn)
  14442. c.ServeSuccessJSON(map[string]interface{}{
  14443. "patient": patient,
  14444. "number": cardnum,
  14445. "insutype": insutype,
  14446. })
  14447. }
  14448. } else {
  14449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14450. return
  14451. }
  14452. }
  14453. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14454. fmt.Println(initFlag)
  14455. fmt.Println("initFlag")
  14456. if initFlag == 0 {
  14457. c.TestGetJiangXiBasBaseInit()
  14458. }
  14459. basStr := c.GetBasBaseInfo()
  14460. if len(basStr) == 0 {
  14461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14462. return
  14463. }
  14464. fmt.Println(basStr)
  14465. bas := strings.Split(basStr, "|")
  14466. basNumber := bas[1]
  14467. fmt.Println(basNumber)
  14468. card := bas[2]
  14469. card_sn := bas[3]
  14470. fmt.Println(card_sn)
  14471. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14472. result, _ := service.Jxyb11012(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, card)
  14473. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14474. var dat map[string]interface{}
  14475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14476. fmt.Println(dat)
  14477. } else {
  14478. fmt.Println(err)
  14479. }
  14480. userJSONBytes, _ := json.Marshal(dat)
  14481. var res ResultTwo
  14482. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14483. utils.ErrorLog("解析失败:%v", err)
  14484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14485. return
  14486. }
  14487. if res.Infcode == 0 {
  14488. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14489. if err == gorm.ErrRecordNotFound {
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14491. return
  14492. } else if err != nil {
  14493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14494. return
  14495. } else {
  14496. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14497. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14498. infoStr := string(Iinfos)
  14499. idetinfoStr := string(Idetinfos)
  14500. var rf []*ResultFive
  14501. json.Unmarshal([]byte(infoStr), &rf)
  14502. var insutypes []*ResultFive
  14503. var insutype string
  14504. var is390 int = 0
  14505. var is310 int = 0
  14506. var insuplc_admdvs string
  14507. for _, item := range rf {
  14508. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14509. insutypes = append(insutypes, item)
  14510. }
  14511. }
  14512. if len(insutypes) == 1 {
  14513. insutype = insutypes[0].Insutype
  14514. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14515. } else {
  14516. for _, i := range insutypes {
  14517. if i.Insutype == "390" {
  14518. is390 = 1
  14519. }
  14520. if i.Insutype == "310" {
  14521. is310 = 1
  14522. }
  14523. }
  14524. }
  14525. if is390 == 1 {
  14526. insutype = "390"
  14527. }
  14528. if is310 == 1 {
  14529. insutype = "310"
  14530. }
  14531. if len(insutypes) == 0 {
  14532. insutype = "310"
  14533. }
  14534. for _, item := range rf {
  14535. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14536. insuplc_admdvs = item.InsuplcAdmdvs
  14537. }
  14538. }
  14539. psn := &models.HisPsn{
  14540. PsnNo: res.Output.Baseinfo.PsnNo,
  14541. PatientId: patient.ID,
  14542. Certno: res.Output.Baseinfo.Certno,
  14543. Gend: res.Output.Baseinfo.Gend,
  14544. Naty: res.Output.Baseinfo.Naty,
  14545. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14546. PsnName: res.Output.Baseinfo.PsnName,
  14547. Idetinfo: idetinfoStr,
  14548. Insuinfo: infoStr,
  14549. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14550. CardInfo: basStr,
  14551. InsuplcAdmdvs: insuplc_admdvs,
  14552. VerifyNumber: "",
  14553. }
  14554. service.CreateHisPsn(psn)
  14555. c.ServeSuccessJSON(map[string]interface{}{
  14556. "patient": patient,
  14557. "number": basNumber,
  14558. "insutype": insutype,
  14559. })
  14560. }
  14561. } else {
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14563. return
  14564. }
  14565. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14566. basStr := c.GetBasBaseInfo22222()
  14567. fmt.Println(basStr)
  14568. if len(basStr) == 0 {
  14569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14570. return
  14571. }
  14572. fmt.Println(basStr)
  14573. bas := strings.Split(basStr, "|")
  14574. basNumber := bas[2] //卡号
  14575. card_sn := bas[3] //
  14576. id_card_No := bas[1] //卡号
  14577. fmt.Println(basNumber)
  14578. fmt.Println(card_sn)
  14579. fmt.Println(id_card_No)
  14580. var patient service.Patients
  14581. if len(id_card_No) == 0 {
  14582. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14583. } else {
  14584. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14585. }
  14586. 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)
  14587. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14588. var dat map[string]interface{}
  14589. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14590. fmt.Println(dat)
  14591. } else {
  14592. fmt.Println(err)
  14593. }
  14594. userJSONBytes, _ := json.Marshal(dat)
  14595. var res ResultTwo
  14596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14597. utils.ErrorLog("解析失败:%v", err)
  14598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14599. return
  14600. }
  14601. if res.Infcode == 0 {
  14602. var pateint2 service.Patients
  14603. var err error
  14604. if len(id_card_No) == 0 {
  14605. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14606. } else {
  14607. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14608. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14609. }
  14610. if err == gorm.ErrRecordNotFound {
  14611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14612. return
  14613. } else if err != nil {
  14614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14615. return
  14616. } else {
  14617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14618. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14619. infoStr := string(Iinfos)
  14620. idetinfoStr := string(Idetinfos)
  14621. var rf []*ResultFive
  14622. json.Unmarshal([]byte(infoStr), &rf)
  14623. var insutypes []*ResultFive
  14624. var insutype string
  14625. var is390 int = 0
  14626. var is310 int = 0
  14627. var insuplc_admdvs string
  14628. for _, item := range rf {
  14629. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14630. insutypes = append(insutypes, item)
  14631. }
  14632. }
  14633. if len(insutypes) == 1 {
  14634. insutype = insutypes[0].Insutype
  14635. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14636. } else {
  14637. for _, i := range insutypes {
  14638. if i.Insutype == "390" {
  14639. is390 = 1
  14640. }
  14641. if i.Insutype == "310" {
  14642. is310 = 1
  14643. }
  14644. }
  14645. }
  14646. if is390 == 1 {
  14647. insutype = "390"
  14648. }
  14649. if is310 == 1 {
  14650. insutype = "310"
  14651. }
  14652. if len(insutypes) == 0 {
  14653. insutype = "310"
  14654. }
  14655. for _, item := range rf {
  14656. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14657. insuplc_admdvs = item.InsuplcAdmdvs
  14658. }
  14659. }
  14660. psn := &models.HisPsn{
  14661. PsnNo: res.Output.Baseinfo.PsnNo,
  14662. PatientId: pateint2.ID,
  14663. Certno: res.Output.Baseinfo.Certno,
  14664. Gend: res.Output.Baseinfo.Gend,
  14665. Naty: res.Output.Baseinfo.Naty,
  14666. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14667. PsnName: res.Output.Baseinfo.PsnName,
  14668. Idetinfo: idetinfoStr,
  14669. Insuinfo: infoStr,
  14670. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14671. CardInfo: basStr,
  14672. InsuplcAdmdvs: insuplc_admdvs,
  14673. VerifyNumber: "",
  14674. }
  14675. service.CreateHisPsn(psn)
  14676. c.ServeSuccessJSON(map[string]interface{}{
  14677. "patient": patient,
  14678. "number": basNumber,
  14679. "insutype": insutype,
  14680. })
  14681. }
  14682. } else {
  14683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14684. return
  14685. }
  14686. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14687. fmt.Println(initFlag)
  14688. fmt.Println("initFlag")
  14689. if initFlag == 0 {
  14690. c.TestGetJiangXiBasBaseInittwo()
  14691. }
  14692. basStr := c.GetBasBaseInfo()
  14693. if len(basStr) == 0 {
  14694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14695. return
  14696. }
  14697. fmt.Println(basStr)
  14698. bas := strings.Split(basStr, "|")
  14699. basNumber := bas[1]
  14700. fmt.Println(basNumber)
  14701. card_sn := bas[3]
  14702. fmt.Println(card_sn)
  14703. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14704. 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)
  14705. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14706. var dat map[string]interface{}
  14707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14708. fmt.Println(dat)
  14709. } else {
  14710. fmt.Println(err)
  14711. }
  14712. userJSONBytes, _ := json.Marshal(dat)
  14713. var res ResultTwo
  14714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14715. utils.ErrorLog("解析失败:%v", err)
  14716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14717. return
  14718. }
  14719. if res.Infcode == 0 {
  14720. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14721. if err == gorm.ErrRecordNotFound {
  14722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14723. return
  14724. } else if err != nil {
  14725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14726. return
  14727. } else {
  14728. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14729. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14730. infoStr := string(Iinfos)
  14731. idetinfoStr := string(Idetinfos)
  14732. var rf []*ResultFive
  14733. json.Unmarshal([]byte(infoStr), &rf)
  14734. var insutypes []*ResultFive
  14735. var insutype string
  14736. var is390 int = 0
  14737. var is310 int = 0
  14738. var insuplc_admdvs string
  14739. for _, item := range rf {
  14740. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14741. insutypes = append(insutypes, item)
  14742. }
  14743. }
  14744. if len(insutypes) == 1 {
  14745. insutype = insutypes[0].Insutype
  14746. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14747. } else {
  14748. for _, i := range insutypes {
  14749. if i.Insutype == "390" {
  14750. is390 = 1
  14751. }
  14752. if i.Insutype == "310" {
  14753. is310 = 1
  14754. }
  14755. }
  14756. }
  14757. if is390 == 1 {
  14758. insutype = "390"
  14759. }
  14760. if is310 == 1 {
  14761. insutype = "310"
  14762. }
  14763. if len(insutypes) == 0 {
  14764. insutype = "310"
  14765. }
  14766. for _, item := range rf {
  14767. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14768. insuplc_admdvs = item.InsuplcAdmdvs
  14769. }
  14770. }
  14771. psn := &models.HisPsn{
  14772. PsnNo: res.Output.Baseinfo.PsnNo,
  14773. PatientId: patient.ID,
  14774. Certno: res.Output.Baseinfo.Certno,
  14775. Gend: res.Output.Baseinfo.Gend,
  14776. Naty: res.Output.Baseinfo.Naty,
  14777. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14778. PsnName: res.Output.Baseinfo.PsnName,
  14779. Idetinfo: idetinfoStr,
  14780. Insuinfo: infoStr,
  14781. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14782. CardInfo: basStr,
  14783. InsuplcAdmdvs: insuplc_admdvs,
  14784. VerifyNumber: "",
  14785. }
  14786. service.CreateHisPsn(psn)
  14787. c.ServeSuccessJSON(map[string]interface{}{
  14788. "patient": patient,
  14789. "number": basNumber,
  14790. "insutype": insutype,
  14791. })
  14792. }
  14793. } else {
  14794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14795. return
  14796. }
  14797. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14798. fmt.Println(initFlag)
  14799. fmt.Println("initFlag")
  14800. if initFlag == 0 {
  14801. c.TestGetHnBasBaseInit()
  14802. }
  14803. basStr := c.GetBasBaseInfo()
  14804. if len(basStr) == 0 {
  14805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14806. return
  14807. }
  14808. fmt.Println(basStr)
  14809. bas := strings.Split(basStr, "|")
  14810. basNumber := bas[1]
  14811. fmt.Println(basNumber)
  14812. card_sn := bas[3]
  14813. card_no := bas[2]
  14814. fmt.Println(card_sn)
  14815. name := bas[4]
  14816. name = ConvertToString(name, "gbk", "utf-8")
  14817. 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)
  14818. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14819. var dat map[string]interface{}
  14820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14821. fmt.Println(dat)
  14822. } else {
  14823. fmt.Println(err)
  14824. }
  14825. userJSONBytes, _ := json.Marshal(dat)
  14826. var res ResultTwo
  14827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14828. utils.ErrorLog("解析失败:%v", err)
  14829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14830. return
  14831. }
  14832. if res.Infcode == 0 {
  14833. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14834. if err == gorm.ErrRecordNotFound {
  14835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14836. return
  14837. } else if err != nil {
  14838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14839. return
  14840. } else {
  14841. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14842. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14843. infoStr := string(Iinfos)
  14844. idetinfoStr := string(Idetinfos)
  14845. psn := &models.HisPsn{
  14846. PsnNo: res.Output.Baseinfo.PsnNo,
  14847. PatientId: patient.ID,
  14848. Certno: res.Output.Baseinfo.Certno,
  14849. Gend: res.Output.Baseinfo.Gend,
  14850. Naty: res.Output.Baseinfo.Naty,
  14851. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14852. PsnName: res.Output.Baseinfo.PsnName,
  14853. Idetinfo: idetinfoStr,
  14854. Insuinfo: infoStr,
  14855. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14856. CardInfo: basStr,
  14857. VerifyNumber: "",
  14858. }
  14859. service.CreateHisPsn(psn)
  14860. var rf []*ResultFive
  14861. json.Unmarshal([]byte(infoStr), &rf)
  14862. var insutypes []*ResultFive
  14863. var insutype string
  14864. var is390 int = 0
  14865. var is310 int = 0
  14866. for _, item := range rf {
  14867. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14868. insutypes = append(insutypes, item)
  14869. }
  14870. }
  14871. if len(insutypes) == 1 {
  14872. insutype = insutypes[0].Insutype
  14873. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14874. } else {
  14875. for _, i := range insutypes {
  14876. if i.Insutype == "390" {
  14877. is390 = 1
  14878. }
  14879. if i.Insutype == "310" {
  14880. is310 = 1
  14881. }
  14882. }
  14883. }
  14884. if is390 == 1 {
  14885. insutype = "390"
  14886. }
  14887. if is310 == 1 {
  14888. insutype = "310"
  14889. }
  14890. if len(insutypes) == 0 {
  14891. insutype = "310"
  14892. }
  14893. c.ServeSuccessJSON(map[string]interface{}{
  14894. "patient": patient,
  14895. "number": basNumber,
  14896. "insutype": insutype,
  14897. })
  14898. }
  14899. } else {
  14900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14901. return
  14902. }
  14903. } else if miConfig.MdtrtareaAdmvs == "150404" {
  14904. var api string
  14905. 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 +
  14906. "&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
  14907. fmt.Println(api)
  14908. resp, requestErr := http.Get(api)
  14909. if requestErr != nil {
  14910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14911. return
  14912. }
  14913. body, ioErr := ioutil.ReadAll(resp.Body)
  14914. if ioErr != nil {
  14915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14917. return
  14918. }
  14919. var respJSON map[string]interface{}
  14920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14923. return
  14924. }
  14925. var res ResultTwo //1101结果
  14926. var res10265 ResultTwo10265 //1101结果
  14927. var card_info string //卡信息
  14928. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14929. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14930. result, _ := json.Marshal(respJSON)
  14931. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14932. utils.ErrorLog("解析失败:%v", err)
  14933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14934. return
  14935. }
  14936. res.ErrMsg = res10265.ErrMsg
  14937. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14938. res.Infcode = infocode
  14939. res.Output = res10265.Output
  14940. res.InfRefmsgid = res10265.InfRefmsgid
  14941. if res.Infcode == 0 {
  14942. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14943. if err == gorm.ErrRecordNotFound {
  14944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14945. return
  14946. } else if err != nil {
  14947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14948. return
  14949. } else {
  14950. bas := strings.Split(card_info, "|")
  14951. basNumber := bas[2]
  14952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14953. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14954. infoStr := string(Iinfos)
  14955. idetinfoStr := string(Idetinfos)
  14956. psn := &models.HisPsn{
  14957. PsnNo: res.Output.Baseinfo.PsnNo,
  14958. PatientId: patient.ID,
  14959. Certno: res.Output.Baseinfo.Certno,
  14960. Gend: res.Output.Baseinfo.Gend,
  14961. Naty: res.Output.Baseinfo.Naty,
  14962. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14963. PsnName: res.Output.Baseinfo.PsnName,
  14964. Idetinfo: idetinfoStr,
  14965. Insuinfo: infoStr,
  14966. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14967. CardInfo: card_info,
  14968. VerifyNumber: token,
  14969. }
  14970. service.CreateHisPsn(psn)
  14971. var rf []*ResultFive
  14972. json.Unmarshal([]byte(infoStr), &rf)
  14973. var insutypes []*ResultFive
  14974. var insutype string
  14975. var is390 int = 0
  14976. var is310 int = 0
  14977. for _, item := range rf {
  14978. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14979. insutypes = append(insutypes, item)
  14980. }
  14981. }
  14982. if len(insutypes) == 1 {
  14983. insutype = insutypes[0].Insutype
  14984. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14985. } else {
  14986. for _, i := range insutypes {
  14987. if i.Insutype == "390" {
  14988. is390 = 1
  14989. }
  14990. if i.Insutype == "310" {
  14991. is310 = 1
  14992. }
  14993. }
  14994. }
  14995. if is390 == 1 {
  14996. insutype = "390"
  14997. }
  14998. if is310 == 1 {
  14999. insutype = "310"
  15000. }
  15001. if len(insutypes) == 0 {
  15002. insutype = "310"
  15003. }
  15004. c.ServeSuccessJSON(map[string]interface{}{
  15005. "patient": patient,
  15006. "number": basNumber,
  15007. "insutype": insutype,
  15008. })
  15009. }
  15010. } else {
  15011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15012. return
  15013. }
  15014. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15015. res := c.GetoleInfo()
  15016. if res.Infcode == 0 {
  15017. var result string
  15018. if res.Output.MdtrtCertType == "01" {
  15019. 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)
  15020. } else if res.Output.MdtrtCertType == "02" {
  15021. 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)
  15022. } else if res.Output.MdtrtCertType == "03" {
  15023. 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)
  15024. }
  15025. var dat map[string]interface{}
  15026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15027. fmt.Println(dat)
  15028. } else {
  15029. fmt.Println(err)
  15030. }
  15031. userJSONBytes, _ := json.Marshal(dat)
  15032. var res2 ResultTwo
  15033. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15034. utils.ErrorLog("解析失败:%v", err)
  15035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15036. return
  15037. }
  15038. if res2.Infcode == 0 {
  15039. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15040. if err == gorm.ErrRecordNotFound {
  15041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15042. return
  15043. } else if err != nil {
  15044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15045. return
  15046. } else {
  15047. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15048. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15049. infoStr := string(Iinfos)
  15050. idetinfoStr := string(Idetinfos)
  15051. var rf []*ResultFive
  15052. json.Unmarshal([]byte(infoStr), &rf)
  15053. var insutypes []*ResultFive
  15054. var insutype string
  15055. var is390 int = 0
  15056. var is310 int = 0
  15057. //var insuplc_admdvs string
  15058. for _, item := range rf {
  15059. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15060. insutypes = append(insutypes, item)
  15061. }
  15062. }
  15063. if len(insutypes) == 1 {
  15064. insutype = insutypes[0].Insutype
  15065. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15066. } else {
  15067. for _, i := range insutypes {
  15068. if i.Insutype == "390" {
  15069. is390 = 1
  15070. }
  15071. if i.Insutype == "310" {
  15072. is310 = 1
  15073. }
  15074. }
  15075. }
  15076. if is390 == 1 {
  15077. insutype = "390"
  15078. }
  15079. if is310 == 1 {
  15080. insutype = "310"
  15081. }
  15082. if len(insutypes) == 0 {
  15083. insutype = "310"
  15084. }
  15085. psn := &models.HisPsn{
  15086. PsnNo: res2.Output.Baseinfo.PsnNo,
  15087. PatientId: patient.ID,
  15088. Certno: res2.Output.Baseinfo.Certno,
  15089. Gend: res2.Output.Baseinfo.Gend,
  15090. Naty: res2.Output.Baseinfo.Naty,
  15091. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15092. PsnName: res2.Output.Baseinfo.PsnName,
  15093. Idetinfo: idetinfoStr,
  15094. Insuinfo: infoStr,
  15095. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15096. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15097. VerifyNumber: res.Output.EcToken,
  15098. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15099. }
  15100. if res.Output.MdtrtCertType == "01" {
  15101. psn.VerifyNumber = res.Output.EcToken
  15102. //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)
  15103. } else if res.Output.MdtrtCertType == "02" {
  15104. psn.VerifyNumber = res.Output.MdtrtCertNo
  15105. //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)
  15106. } else if res.Output.MdtrtCertType == "03" {
  15107. psn.VerifyNumber = res.Output.MdtrtCertNo
  15108. //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)
  15109. }
  15110. var balc float64
  15111. for _, item := range rf {
  15112. if item.Insutype == insutype {
  15113. balc = item.Balc
  15114. }
  15115. }
  15116. service.CreateHisPsn(psn)
  15117. c.ServeSuccessJSON(map[string]interface{}{
  15118. "patient": patient,
  15119. "number": res.Output.CardNo,
  15120. "insutype": insutype,
  15121. "blac": balc,
  15122. "desc": idetinfoStr,
  15123. })
  15124. }
  15125. } else {
  15126. c.ServeSuccessJSON(map[string]interface{}{
  15127. "failed_code": -10,
  15128. "msg": res2.ErrMsg,
  15129. })
  15130. }
  15131. } else {
  15132. c.ServeSuccessJSON(map[string]interface{}{
  15133. "failed_code": -10,
  15134. "msg": res.ErrMsg,
  15135. })
  15136. }
  15137. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15138. var api string
  15139. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15140. "&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
  15141. fmt.Println(api)
  15142. resp, requestErr := http.Get(api)
  15143. if requestErr != nil {
  15144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15145. return
  15146. }
  15147. body, ioErr := ioutil.ReadAll(resp.Body)
  15148. if ioErr != nil {
  15149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15151. return
  15152. }
  15153. var respJSON map[string]interface{}
  15154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15157. return
  15158. }
  15159. var status string
  15160. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15161. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15162. //console.log()
  15163. fmt.Println("type===")
  15164. fmt.Println(card_type)
  15165. var token string
  15166. var res ResultTwo //1101结果
  15167. //var res10265 ResultTwoesultTwo10265 //1101结果
  15168. var card_info string //卡信息
  15169. var busi_card_info string
  15170. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15171. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15172. if status == "0" { //读卡成功
  15173. if card_type == "1" {
  15174. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15175. result, _ := json.Marshal(respJSON)
  15176. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15177. utils.ErrorLog("解析失败:%v", err)
  15178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15179. return
  15180. }
  15181. } else {
  15182. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15183. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15184. result, _ := json.Marshal(respJSON)
  15185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15186. utils.ErrorLog("解析失败:%v", err)
  15187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15188. return
  15189. }
  15190. }
  15191. if res.Infcode == 0 {
  15192. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15193. if err == gorm.ErrRecordNotFound {
  15194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15195. return
  15196. } else if err != nil {
  15197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15198. return
  15199. } else {
  15200. if card_type == "1" {
  15201. bas := strings.Split(card_info, "|")
  15202. basNumber := bas[2]
  15203. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15204. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15205. infoStr := string(Iinfos)
  15206. idetinfoStr := string(Idetinfos)
  15207. psn := &models.HisPsn{
  15208. PsnNo: res.Output.Baseinfo.PsnNo,
  15209. PatientId: patient.ID,
  15210. Certno: res.Output.Baseinfo.Certno,
  15211. Gend: res.Output.Baseinfo.Gend,
  15212. Naty: res.Output.Baseinfo.Naty,
  15213. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15214. PsnName: res.Output.Baseinfo.PsnName,
  15215. Idetinfo: idetinfoStr,
  15216. Insuinfo: infoStr,
  15217. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15218. CardInfo: card_info,
  15219. VerifyNumber: busi_card_info,
  15220. }
  15221. service.CreateHisPsn(psn)
  15222. var rf []*ResultFive
  15223. json.Unmarshal([]byte(infoStr), &rf)
  15224. var insutypes []*ResultFive
  15225. var insutype string
  15226. var is390 int = 0
  15227. var is310 int = 0
  15228. for _, item := range rf {
  15229. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15230. insutypes = append(insutypes, item)
  15231. }
  15232. }
  15233. if len(insutypes) == 1 {
  15234. insutype = insutypes[0].Insutype
  15235. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15236. } else {
  15237. for _, i := range insutypes {
  15238. if i.Insutype == "390" {
  15239. is390 = 1
  15240. }
  15241. if i.Insutype == "310" {
  15242. is310 = 1
  15243. }
  15244. }
  15245. }
  15246. if is390 == 1 {
  15247. insutype = "390"
  15248. }
  15249. if is310 == 1 {
  15250. insutype = "310"
  15251. }
  15252. if len(insutypes) == 0 {
  15253. insutype = "310"
  15254. }
  15255. c.ServeSuccessJSON(map[string]interface{}{
  15256. "patient": patient,
  15257. "number": basNumber,
  15258. "insutype": insutype,
  15259. })
  15260. } else {
  15261. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15262. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15263. infoStr := string(Iinfos)
  15264. idetinfoStr := string(Idetinfos)
  15265. psn := &models.HisPsn{
  15266. PsnNo: res.Output.Baseinfo.PsnNo,
  15267. PatientId: patient.ID,
  15268. Certno: res.Output.Baseinfo.Certno,
  15269. Gend: res.Output.Baseinfo.Gend,
  15270. Naty: res.Output.Baseinfo.Naty,
  15271. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15272. PsnName: res.Output.Baseinfo.PsnName,
  15273. Idetinfo: idetinfoStr,
  15274. Insuinfo: infoStr,
  15275. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15276. CardInfo: card_info,
  15277. VerifyNumber: token,
  15278. }
  15279. service.CreateHisPsn(psn)
  15280. c.ServeSuccessJSON(map[string]interface{}{
  15281. "patient": patient,
  15282. "number": token,
  15283. })
  15284. }
  15285. }
  15286. } else {
  15287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15288. return
  15289. }
  15290. } else { //读卡失败
  15291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15292. return
  15293. }
  15294. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15295. var api string
  15296. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15297. "&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
  15298. fmt.Println(api)
  15299. resp, requestErr := http.Get(api)
  15300. if requestErr != nil {
  15301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15302. return
  15303. }
  15304. body, ioErr := ioutil.ReadAll(resp.Body)
  15305. if ioErr != nil {
  15306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15308. return
  15309. }
  15310. var respJSON map[string]interface{}
  15311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15314. return
  15315. }
  15316. var status string
  15317. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15318. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15319. //console.log()
  15320. fmt.Println("type===")
  15321. fmt.Println(card_type)
  15322. var token string
  15323. var res ResultTwo //1101结果
  15324. //var res10265 ResultTwoesultTwo10265 //1101结果
  15325. var card_info string //卡信息
  15326. //var busi_card_info string
  15327. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15328. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15329. if status == "0" { //读卡成功
  15330. if card_type == "1" {
  15331. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15332. result, _ := json.Marshal(respJSON)
  15333. fmt.Println(result)
  15334. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15335. utils.ErrorLog("解析失败:%v", err)
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. return
  15338. }
  15339. fmt.Println(res)
  15340. } else {
  15341. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15342. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15343. result, _ := json.Marshal(respJSON)
  15344. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15345. utils.ErrorLog("解析失败:%v", err)
  15346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15347. return
  15348. }
  15349. }
  15350. if res.Infcode == 0 {
  15351. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15352. if err == gorm.ErrRecordNotFound {
  15353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15354. return
  15355. } else if err != nil {
  15356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15357. return
  15358. } else {
  15359. if card_type == "1" {
  15360. bas := strings.Split(card_info, "|")
  15361. basNumber := bas[2]
  15362. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15363. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15364. infoStr := string(Iinfos)
  15365. idetinfoStr := string(Idetinfos)
  15366. psn := &models.HisPsn{
  15367. PsnNo: res.Output.Baseinfo.PsnNo,
  15368. PatientId: patient.ID,
  15369. Certno: res.Output.Baseinfo.Certno,
  15370. Gend: res.Output.Baseinfo.Gend,
  15371. Naty: res.Output.Baseinfo.Naty,
  15372. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15373. PsnName: res.Output.Baseinfo.PsnName,
  15374. Idetinfo: idetinfoStr,
  15375. Insuinfo: infoStr,
  15376. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15377. CardInfo: card_info,
  15378. //VerifyNumber: busi_card_info,
  15379. }
  15380. service.CreateHisPsn(psn)
  15381. var rf []*ResultFive
  15382. json.Unmarshal([]byte(infoStr), &rf)
  15383. var insutypes []*ResultFive
  15384. var insutype string
  15385. var is390 int = 0
  15386. var is310 int = 0
  15387. for _, item := range rf {
  15388. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15389. insutypes = append(insutypes, item)
  15390. }
  15391. }
  15392. if len(insutypes) == 1 {
  15393. insutype = insutypes[0].Insutype
  15394. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15395. } else {
  15396. for _, i := range insutypes {
  15397. if i.Insutype == "390" {
  15398. is390 = 1
  15399. }
  15400. if i.Insutype == "310" {
  15401. is310 = 1
  15402. }
  15403. }
  15404. }
  15405. if is390 == 1 {
  15406. insutype = "390"
  15407. }
  15408. if is310 == 1 {
  15409. insutype = "310"
  15410. }
  15411. if len(insutypes) == 0 {
  15412. insutype = "310"
  15413. }
  15414. c.ServeSuccessJSON(map[string]interface{}{
  15415. "patient": patient,
  15416. "number": basNumber,
  15417. "insutype": insutype,
  15418. })
  15419. } else {
  15420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15422. infoStr := string(Iinfos)
  15423. idetinfoStr := string(Idetinfos)
  15424. psn := &models.HisPsn{
  15425. PsnNo: res.Output.Baseinfo.PsnNo,
  15426. PatientId: patient.ID,
  15427. Certno: res.Output.Baseinfo.Certno,
  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. service.CreateHisPsn(psn)
  15439. c.ServeSuccessJSON(map[string]interface{}{
  15440. "patient": patient,
  15441. "number": token,
  15442. })
  15443. }
  15444. }
  15445. } else {
  15446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15447. return
  15448. }
  15449. } else { //读卡失败
  15450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15451. return
  15452. }
  15453. } else {
  15454. if initFlag == 0 {
  15455. c.TestGetBasBaseInit()
  15456. }
  15457. basStr := c.GetBasBaseInfo()
  15458. if len(basStr) == 0 {
  15459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15460. return
  15461. }
  15462. fmt.Println(basStr)
  15463. bas := strings.Split(basStr, "|")
  15464. basNumber := bas[1]
  15465. fmt.Println(basNumber)
  15466. card_sn := bas[3]
  15467. fmt.Println(card_sn)
  15468. cardNumber := bas[2]
  15469. fmt.Println(cardNumber)
  15470. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15471. var result string
  15472. if bas[0][:2] == "44" {
  15473. 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)
  15474. } else {
  15475. 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)
  15476. }
  15477. var dat map[string]interface{}
  15478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15479. fmt.Println(dat)
  15480. } else {
  15481. fmt.Println(err)
  15482. }
  15483. userJSONBytes, _ := json.Marshal(dat)
  15484. var res ResultTwo
  15485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15486. utils.ErrorLog("解析失败:%v", err)
  15487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15488. return
  15489. }
  15490. if res.Infcode == 0 {
  15491. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15492. if err == gorm.ErrRecordNotFound {
  15493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15494. return
  15495. } else if err != nil {
  15496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15497. return
  15498. } else {
  15499. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15500. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15501. infoStr := string(Iinfos)
  15502. idetinfoStr := string(Idetinfos)
  15503. var rf []*ResultFive
  15504. json.Unmarshal([]byte(infoStr), &rf)
  15505. var insutypes []*ResultFive
  15506. var insutype string
  15507. var is390 int = 0
  15508. var is310 int = 0
  15509. var insuplc_admdvs string
  15510. for _, item := range rf {
  15511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15512. insutypes = append(insutypes, item)
  15513. }
  15514. }
  15515. if len(insutypes) == 1 {
  15516. insutype = insutypes[0].Insutype
  15517. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15518. } else {
  15519. for _, i := range insutypes {
  15520. if i.Insutype == "390" {
  15521. is390 = 1
  15522. }
  15523. if i.Insutype == "310" {
  15524. is310 = 1
  15525. }
  15526. }
  15527. }
  15528. if is390 == 1 {
  15529. insutype = "390"
  15530. }
  15531. if is310 == 1 {
  15532. insutype = "310"
  15533. }
  15534. if len(insutypes) == 0 {
  15535. insutype = "310"
  15536. }
  15537. for _, item := range rf {
  15538. if item.Insutype == insutype {
  15539. insuplc_admdvs = item.InsuplcAdmdvs
  15540. }
  15541. }
  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: basStr,
  15554. VerifyNumber: "",
  15555. InsuplcAdmdvs: insuplc_admdvs,
  15556. }
  15557. service.CreateHisPsn(psn)
  15558. c.ServeSuccessJSON(map[string]interface{}{
  15559. "patient": patient,
  15560. "insutype": insutype,
  15561. "number": basNumber,
  15562. })
  15563. }
  15564. } else {
  15565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15566. return
  15567. }
  15568. break
  15569. }
  15570. case 2:
  15571. if miConfig.MdtrtareaAdmvs == "430800" {
  15572. if initFlag == 0 {
  15573. c.TestGetHnBasBaseInit()
  15574. }
  15575. SFZStr := c.GetSFZBaseInfo()
  15576. if len(SFZStr) == 0 {
  15577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15578. return
  15579. }
  15580. fmt.Println(SFZStr)
  15581. id_card_str := strings.Split(SFZStr, "^")
  15582. card_no := id_card_str[0]
  15583. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15584. //name := id_card_str[1]
  15585. //name = ConvertToString(name, "gbk", "utf-8")
  15586. 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)
  15587. var dat map[string]interface{}
  15588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15589. fmt.Println(dat)
  15590. } else {
  15591. fmt.Println(err)
  15592. }
  15593. userJSONBytes, _ := json.Marshal(dat)
  15594. var res ResultTwo
  15595. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15596. utils.ErrorLog("解析失败:%v", err)
  15597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15598. return
  15599. }
  15600. if res.Infcode == 0 {
  15601. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15602. if err == gorm.ErrRecordNotFound {
  15603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15604. return
  15605. } else if err != nil {
  15606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15607. return
  15608. } else {
  15609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15611. infoStr := string(Iinfos)
  15612. idetinfoStr := string(Idetinfos)
  15613. var rf []*ResultFive
  15614. json.Unmarshal([]byte(infoStr), &rf)
  15615. var insutypes []*ResultFive
  15616. var insutype string
  15617. var is390 int = 0
  15618. var is310 int = 0
  15619. for _, item := range rf {
  15620. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15621. insutypes = append(insutypes, item)
  15622. }
  15623. }
  15624. if len(insutypes) == 1 {
  15625. insutype = insutypes[0].Insutype
  15626. } else {
  15627. for _, i := range insutypes {
  15628. if i.Insutype == "390" {
  15629. is390 = 1
  15630. }
  15631. if i.Insutype == "310" {
  15632. is310 = 1
  15633. }
  15634. }
  15635. }
  15636. if is390 == 1 {
  15637. insutype = "390"
  15638. }
  15639. if is310 == 1 {
  15640. insutype = "310"
  15641. }
  15642. if len(insutypes) == 0 {
  15643. insutype = "310"
  15644. }
  15645. var InsuplcAdmdvs string
  15646. for _, item := range rf {
  15647. if item.Insutype == insutype {
  15648. InsuplcAdmdvs = item.InsuplcAdmdvs
  15649. }
  15650. }
  15651. psn := &models.HisPsn{
  15652. PsnNo: res.Output.Baseinfo.PsnNo,
  15653. PatientId: patient.ID,
  15654. Certno: res.Output.Baseinfo.Certno,
  15655. Gend: res.Output.Baseinfo.Gend,
  15656. Naty: res.Output.Baseinfo.Naty,
  15657. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15658. PsnName: res.Output.Baseinfo.PsnName,
  15659. Idetinfo: idetinfoStr,
  15660. Insuinfo: infoStr,
  15661. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15662. CardInfo: SFZStr,
  15663. VerifyNumber: "",
  15664. InsuplcAdmdvs: InsuplcAdmdvs,
  15665. }
  15666. service.CreateHisPsn(psn)
  15667. c.ServeSuccessJSON(map[string]interface{}{
  15668. "patient": patient,
  15669. "number": card_no,
  15670. "insutype": insutype,
  15671. })
  15672. }
  15673. } else {
  15674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15675. return
  15676. }
  15677. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15678. var res ResultTwo
  15679. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15680. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15681. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  15682. resp, requestErr := http.Get(api)
  15683. if requestErr != nil {
  15684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15685. return
  15686. }
  15687. body, ioErr := ioutil.ReadAll(resp.Body)
  15688. if ioErr != nil {
  15689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15691. return
  15692. }
  15693. var respJSON map[string]interface{}
  15694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15697. return
  15698. }
  15699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15700. result, _ := json.Marshal(respJSON)
  15701. fmt.Println("log")
  15702. fmt.Println(string(result))
  15703. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15704. utils.ErrorLog("解析失败:%v", err)
  15705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15706. return
  15707. }
  15708. if res.Infcode == 0 {
  15709. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15710. if err == gorm.ErrRecordNotFound {
  15711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15712. return
  15713. } else if err != nil {
  15714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15715. return
  15716. } else {
  15717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15719. infoStr := string(Iinfos)
  15720. idetinfoStr := string(Idetinfos)
  15721. psn := &models.HisPsn{
  15722. PsnNo: res.Output.Baseinfo.PsnNo,
  15723. PatientId: patient.ID,
  15724. Certno: res.Output.Baseinfo.Certno,
  15725. Gend: res.Output.Baseinfo.Gend,
  15726. Naty: res.Output.Baseinfo.Naty,
  15727. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15728. PsnName: res.Output.Baseinfo.PsnName,
  15729. Idetinfo: idetinfoStr,
  15730. Insuinfo: infoStr,
  15731. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15732. }
  15733. service.CreateHisPsn(psn)
  15734. c.ServeSuccessJSON(map[string]interface{}{
  15735. "patient": patient,
  15736. "number": res.Output.Baseinfo.Certno,
  15737. })
  15738. }
  15739. } else {
  15740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15741. return
  15742. }
  15743. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15744. var res ResultTwo
  15745. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15746. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15747. "&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)
  15748. resp, requestErr := http.Get(api)
  15749. if requestErr != nil {
  15750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15751. return
  15752. }
  15753. body, ioErr := ioutil.ReadAll(resp.Body)
  15754. if ioErr != nil {
  15755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15757. return
  15758. }
  15759. var respJSON map[string]interface{}
  15760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15763. return
  15764. }
  15765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15766. result, _ := json.Marshal(respJSON)
  15767. fmt.Println("log")
  15768. fmt.Println(string(result))
  15769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15770. utils.ErrorLog("解析失败:%v", err)
  15771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15772. return
  15773. }
  15774. if res.Infcode == 0 {
  15775. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15776. if err == gorm.ErrRecordNotFound {
  15777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15778. return
  15779. } else if err != nil {
  15780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15781. return
  15782. } else {
  15783. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15784. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15785. infoStr := string(Iinfos)
  15786. idetinfoStr := string(Idetinfos)
  15787. psn := &models.HisPsn{
  15788. PsnNo: res.Output.Baseinfo.PsnNo,
  15789. PatientId: patient.ID,
  15790. Certno: res.Output.Baseinfo.Certno,
  15791. Gend: res.Output.Baseinfo.Gend,
  15792. Naty: res.Output.Baseinfo.Naty,
  15793. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15794. PsnName: res.Output.Baseinfo.PsnName,
  15795. Idetinfo: idetinfoStr,
  15796. Insuinfo: infoStr,
  15797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15798. }
  15799. service.CreateHisPsn(psn)
  15800. c.ServeSuccessJSON(map[string]interface{}{
  15801. "patient": patient,
  15802. "number": res.Output.Baseinfo.Certno,
  15803. })
  15804. }
  15805. } else {
  15806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15807. return
  15808. }
  15809. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15810. var res ResultTwo
  15811. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15812. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15813. "&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)
  15814. resp, requestErr := http.Get(api)
  15815. if requestErr != nil {
  15816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15817. return
  15818. }
  15819. body, ioErr := ioutil.ReadAll(resp.Body)
  15820. if ioErr != nil {
  15821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15823. return
  15824. }
  15825. var respJSON map[string]interface{}
  15826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15829. return
  15830. }
  15831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15832. result, _ := json.Marshal(respJSON)
  15833. fmt.Println("log")
  15834. fmt.Println(string(result))
  15835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15836. utils.ErrorLog("解析失败:%v", err)
  15837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15838. return
  15839. }
  15840. if res.Infcode == 0 {
  15841. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15842. if err == gorm.ErrRecordNotFound {
  15843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15844. return
  15845. } else if err != nil {
  15846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15847. return
  15848. } else {
  15849. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15850. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15851. infoStr := string(Iinfos)
  15852. idetinfoStr := string(Idetinfos)
  15853. var rf []*ResultFive
  15854. json.Unmarshal([]byte(infoStr), &rf)
  15855. var insutypes []*ResultFive
  15856. var insutype string
  15857. var is390 int = 0
  15858. var is310 int = 0
  15859. for _, item := range rf {
  15860. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15861. insutypes = append(insutypes, item)
  15862. }
  15863. }
  15864. if len(insutypes) == 1 {
  15865. insutype = insutypes[0].Insutype
  15866. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15867. } else {
  15868. for _, i := range insutypes {
  15869. if i.Insutype == "390" {
  15870. is390 = 1
  15871. }
  15872. if i.Insutype == "310" {
  15873. is310 = 1
  15874. }
  15875. }
  15876. }
  15877. if is390 == 1 {
  15878. insutype = "390"
  15879. }
  15880. if is310 == 1 {
  15881. insutype = "310"
  15882. }
  15883. if len(insutypes) == 0 {
  15884. insutype = "390"
  15885. }
  15886. var insuplc_admdvs string
  15887. for _, item := range rf {
  15888. if item.Insutype == insutype {
  15889. insuplc_admdvs = item.InsuplcAdmdvs
  15890. }
  15891. }
  15892. psn := &models.HisPsn{
  15893. PsnNo: res.Output.Baseinfo.PsnNo,
  15894. PatientId: patient.ID,
  15895. Certno: res.Output.Baseinfo.Certno,
  15896. Gend: res.Output.Baseinfo.Gend,
  15897. Naty: res.Output.Baseinfo.Naty,
  15898. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15899. PsnName: res.Output.Baseinfo.PsnName,
  15900. Idetinfo: idetinfoStr,
  15901. Insuinfo: infoStr,
  15902. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15903. InsuplcAdmdvs: insuplc_admdvs,
  15904. }
  15905. service.CreateHisPsn(psn)
  15906. c.ServeSuccessJSON(map[string]interface{}{
  15907. "patient": patient,
  15908. "number": res.Output.Baseinfo.Certno,
  15909. })
  15910. }
  15911. } else {
  15912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15913. return
  15914. }
  15915. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15916. res := c.GetoleInfo()
  15917. if res.Infcode == 0 {
  15918. var result string
  15919. if res.Output.MdtrtCertType == "01" {
  15920. 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)
  15921. } else if res.Output.MdtrtCertType == "02" {
  15922. 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)
  15923. } else if res.Output.MdtrtCertType == "03" {
  15924. 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)
  15925. }
  15926. var dat map[string]interface{}
  15927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15928. fmt.Println(dat)
  15929. } else {
  15930. fmt.Println(err)
  15931. }
  15932. userJSONBytes, _ := json.Marshal(dat)
  15933. var res2 ResultTwo
  15934. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15935. utils.ErrorLog("解析失败:%v", err)
  15936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15937. return
  15938. }
  15939. if res2.Infcode == 0 {
  15940. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15941. if err == gorm.ErrRecordNotFound {
  15942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15943. return
  15944. } else if err != nil {
  15945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15946. return
  15947. } else {
  15948. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15949. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15950. infoStr := string(Iinfos)
  15951. idetinfoStr := string(Idetinfos)
  15952. var rf []*ResultFive
  15953. json.Unmarshal([]byte(infoStr), &rf)
  15954. var insutypes []*ResultFive
  15955. var insutype string
  15956. var is390 int = 0
  15957. var is310 int = 0
  15958. //var insuplc_admdvs string
  15959. for _, item := range rf {
  15960. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15961. insutypes = append(insutypes, item)
  15962. }
  15963. }
  15964. if len(insutypes) == 1 {
  15965. insutype = insutypes[0].Insutype
  15966. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15967. } else {
  15968. for _, i := range insutypes {
  15969. if i.Insutype == "390" {
  15970. is390 = 1
  15971. }
  15972. if i.Insutype == "310" {
  15973. is310 = 1
  15974. }
  15975. }
  15976. }
  15977. if is390 == 1 {
  15978. insutype = "390"
  15979. }
  15980. if is310 == 1 {
  15981. insutype = "310"
  15982. }
  15983. if len(insutypes) == 0 {
  15984. insutype = "310"
  15985. }
  15986. psn := &models.HisPsn{
  15987. PsnNo: res2.Output.Baseinfo.PsnNo,
  15988. PatientId: patient.ID,
  15989. //Brdy: res2.Output.Baseinfo.Brdy,
  15990. Certno: res2.Output.Baseinfo.Certno,
  15991. Gend: res2.Output.Baseinfo.Gend,
  15992. Naty: res2.Output.Baseinfo.Naty,
  15993. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15994. PsnName: res2.Output.Baseinfo.PsnName,
  15995. Idetinfo: idetinfoStr,
  15996. Insuinfo: infoStr,
  15997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15998. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15999. VerifyNumber: res.Output.EcToken,
  16000. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16001. }
  16002. service.CreateHisPsn(psn)
  16003. var balc float64
  16004. for _, item := range rf {
  16005. if item.Insutype == insutype {
  16006. balc = item.Balc
  16007. }
  16008. }
  16009. c.ServeSuccessJSON(map[string]interface{}{
  16010. "patient": patient,
  16011. "number": res.Output.CardNo,
  16012. "insutype": insutype,
  16013. "blac": balc,
  16014. "desc": idetinfoStr,
  16015. })
  16016. }
  16017. } else {
  16018. c.ServeSuccessJSON(map[string]interface{}{
  16019. "failed_code": -10,
  16020. "msg": res2.ErrMsg,
  16021. })
  16022. }
  16023. } else {
  16024. c.ServeSuccessJSON(map[string]interface{}{
  16025. "failed_code": -10,
  16026. "msg": res.ErrMsg,
  16027. })
  16028. }
  16029. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16030. var insuplc_admdvs string
  16031. if len(patient.InsuplcAdmdvs) > 0 {
  16032. insuplc_admdvs = patient.InsuplcAdmdvs
  16033. } else {
  16034. if len(insuplc_admdvs_str) > 0 {
  16035. insuplc_admdvs = insuplc_admdvs_str
  16036. } else {
  16037. insuplc_admdvs = miConfig.InsuplcAdmdvs
  16038. }
  16039. }
  16040. //请求内网数据
  16041. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  16042. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16043. "&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=" + ""
  16044. resp, requestErr := http.Get(api)
  16045. if requestErr != nil {
  16046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16047. return
  16048. }
  16049. body, ioErr := ioutil.ReadAll(resp.Body)
  16050. if ioErr != nil {
  16051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16053. return
  16054. }
  16055. var respJSON map[string]interface{}
  16056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16059. return
  16060. }
  16061. status := respJSON["data"].(map[string]interface{})["status"].(string)
  16062. if status == "0" {
  16063. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  16064. c.ServeSuccessJSON(map[string]interface{}{
  16065. "failed_code": -10,
  16066. "msg": err_msg,
  16067. })
  16068. return
  16069. }
  16070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16071. var res ResultTwo
  16072. result, _ := json.Marshal(respJSON)
  16073. fmt.Println("log")
  16074. fmt.Println(string(result))
  16075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16076. utils.ErrorLog("解析失败:%v", err)
  16077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16078. return
  16079. }
  16080. if res.Infcode == 0 {
  16081. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16082. if err == gorm.ErrRecordNotFound {
  16083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16084. return
  16085. } else if err != nil {
  16086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16087. return
  16088. } else {
  16089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16091. infoStr := string(Iinfos)
  16092. idetinfoStr := string(Idetinfos)
  16093. psn := &models.HisPsn{
  16094. PsnNo: res.Output.Baseinfo.PsnNo,
  16095. PatientId: patient.ID,
  16096. Certno: res.Output.Baseinfo.Certno,
  16097. Gend: res.Output.Baseinfo.Gend,
  16098. Naty: res.Output.Baseinfo.Naty,
  16099. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16100. PsnName: res.Output.Baseinfo.PsnName,
  16101. Idetinfo: idetinfoStr,
  16102. Insuinfo: infoStr,
  16103. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16104. }
  16105. service.CreateHisPsn(psn)
  16106. var rf []*ResultFive
  16107. json.Unmarshal([]byte(infoStr), &rf)
  16108. var insutypes []*ResultFive
  16109. var is390 int = 0
  16110. var is310 int = 0
  16111. var insutype string
  16112. for _, item := range rf {
  16113. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16114. insutypes = append(insutypes, item)
  16115. }
  16116. }
  16117. if len(insutypes) == 1 {
  16118. insutype = insutypes[0].Insutype
  16119. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16120. } else {
  16121. for _, i := range insutypes {
  16122. if i.Insutype == "390" {
  16123. is390 = 1
  16124. }
  16125. if i.Insutype == "310" {
  16126. is310 = 1
  16127. }
  16128. }
  16129. }
  16130. if is390 == 1 {
  16131. insutype = "390"
  16132. }
  16133. if is310 == 1 {
  16134. insutype = "310"
  16135. }
  16136. if len(insutypes) == 0 {
  16137. insutype = "390"
  16138. }
  16139. c.ServeSuccessJSON(map[string]interface{}{
  16140. "patient": patient,
  16141. "insutype": insutype,
  16142. "number": res.Output.Baseinfo.Certno,
  16143. "info": res,
  16144. })
  16145. }
  16146. } else {
  16147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16148. return
  16149. }
  16150. } else {
  16151. SFZStr := c.GetSFZBaseInfo()
  16152. id_card_str := strings.Split(SFZStr, "^")
  16153. id_card_number := id_card_str[0]
  16154. card_sn := ""
  16155. 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)
  16156. var dat map[string]interface{}
  16157. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16158. fmt.Println(dat)
  16159. } else {
  16160. fmt.Println(err)
  16161. }
  16162. userJSONBytes, _ := json.Marshal(dat)
  16163. var res ResultTwo
  16164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16165. utils.ErrorLog("解析失败:%v", err)
  16166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16167. return
  16168. }
  16169. if res.Infcode == 0 {
  16170. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16171. if err == gorm.ErrRecordNotFound {
  16172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16173. return
  16174. } else if err != nil {
  16175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16176. return
  16177. } else {
  16178. c.ServeSuccessJSON(map[string]interface{}{
  16179. "patient": patient,
  16180. "number": id_card_number,
  16181. })
  16182. }
  16183. } else {
  16184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16185. return
  16186. }
  16187. }
  16188. break
  16189. case 3:
  16190. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16191. var api string
  16192. if miConfig.MdtrtareaAdmvs == "320830" {
  16193. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16194. "&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
  16195. fmt.Println(api)
  16196. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16197. 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 +
  16198. "&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
  16199. fmt.Println(api)
  16200. } else {
  16201. 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 +
  16202. "&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)
  16203. }
  16204. resp, requestErr := http.Get(api)
  16205. if requestErr != nil {
  16206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16207. return
  16208. }
  16209. body, ioErr := ioutil.ReadAll(resp.Body)
  16210. if ioErr != nil {
  16211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16213. return
  16214. }
  16215. var respJSON map[string]interface{}
  16216. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16219. return
  16220. }
  16221. var status string
  16222. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16223. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16224. var token string
  16225. var res ResultTwo //1101结果
  16226. var res10265 ResultTwo10265 //1101结果
  16227. var card_info string //卡信息
  16228. var busi_card_info string
  16229. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16230. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16231. if status == "0" { //读卡成功
  16232. if card_type == "1" {
  16233. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16234. result, _ := json.Marshal(respJSON)
  16235. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16236. utils.ErrorLog("解析失败:%v", err)
  16237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16238. return
  16239. }
  16240. res.ErrMsg = res10265.ErrMsg
  16241. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16242. res.Infcode = infocode
  16243. res.Output = res10265.Output
  16244. res.InfRefmsgid = res10265.InfRefmsgid
  16245. } else {
  16246. //var card_info string //卡信息
  16247. //var busi_card_info string
  16248. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16249. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16250. //fmt.Println(card_info)
  16251. //fmt.Println(busi_card_info)
  16252. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16253. result, _ := json.Marshal(respJSON)
  16254. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16255. utils.ErrorLog("解析失败:%v", err)
  16256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16257. return
  16258. }
  16259. res.ErrMsg = res10265.ErrMsg
  16260. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16261. res.Infcode = infocode
  16262. res.Output = res10265.Output
  16263. res.InfRefmsgid = res10265.InfRefmsgid
  16264. }
  16265. if res.Infcode == 0 {
  16266. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16267. if err == gorm.ErrRecordNotFound {
  16268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16269. return
  16270. } else if err != nil {
  16271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16272. return
  16273. } else {
  16274. if card_type == "1" {
  16275. bas := strings.Split(card_info, "|")
  16276. basNumber := bas[2]
  16277. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16278. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16279. infoStr := string(Iinfos)
  16280. idetinfoStr := string(Idetinfos)
  16281. psn := &models.HisPsn{
  16282. PsnNo: res.Output.Baseinfo.PsnNo,
  16283. PatientId: patient.ID,
  16284. Certno: res.Output.Baseinfo.Certno,
  16285. //Brdy: res.Output.Baseinfo.Brdy,
  16286. Gend: res.Output.Baseinfo.Gend,
  16287. Naty: res.Output.Baseinfo.Naty,
  16288. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16289. PsnName: res.Output.Baseinfo.PsnName,
  16290. Idetinfo: idetinfoStr,
  16291. Insuinfo: infoStr,
  16292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16293. CardInfo: card_info,
  16294. VerifyNumber: busi_card_info,
  16295. }
  16296. service.CreateHisPsn(psn)
  16297. c.ServeSuccessJSON(map[string]interface{}{
  16298. "patient": patient,
  16299. "number": basNumber,
  16300. })
  16301. } else {
  16302. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16303. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16304. infoStr := string(Iinfos)
  16305. idetinfoStr := string(Idetinfos)
  16306. psn := &models.HisPsn{
  16307. PsnNo: res.Output.Baseinfo.PsnNo,
  16308. PatientId: patient.ID,
  16309. Certno: res.Output.Baseinfo.Certno,
  16310. Gend: res.Output.Baseinfo.Gend,
  16311. Naty: res.Output.Baseinfo.Naty,
  16312. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16313. PsnName: res.Output.Baseinfo.PsnName,
  16314. Idetinfo: idetinfoStr,
  16315. Insuinfo: infoStr,
  16316. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16317. CardInfo: card_info,
  16318. VerifyNumber: token,
  16319. }
  16320. service.CreateHisPsn(psn)
  16321. var rf []*ResultFive
  16322. json.Unmarshal([]byte(infoStr), &rf)
  16323. var insutypes []*ResultFive
  16324. var insutype string
  16325. var is390 int = 0
  16326. var is310 int = 0
  16327. for _, item := range rf {
  16328. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16329. insutypes = append(insutypes, item)
  16330. }
  16331. }
  16332. if len(insutypes) == 1 {
  16333. insutype = insutypes[0].Insutype
  16334. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16335. } else {
  16336. for _, i := range insutypes {
  16337. if i.Insutype == "390" {
  16338. is390 = 1
  16339. }
  16340. if i.Insutype == "310" {
  16341. is310 = 1
  16342. }
  16343. }
  16344. }
  16345. if is390 == 1 {
  16346. insutype = "390"
  16347. }
  16348. if is310 == 1 {
  16349. insutype = "310"
  16350. }
  16351. if len(insutypes) == 0 {
  16352. insutype = "310"
  16353. }
  16354. c.ServeSuccessJSON(map[string]interface{}{
  16355. "patient": patient,
  16356. "number": token,
  16357. "insutype": insutype,
  16358. })
  16359. }
  16360. }
  16361. } else {
  16362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16363. return
  16364. }
  16365. } else { //读卡失败
  16366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16367. return
  16368. }
  16369. }
  16370. break
  16371. case 4:
  16372. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16373. var api string
  16374. if miConfig.MdtrtareaAdmvs == "320830" {
  16375. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16376. "&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
  16377. fmt.Println(api)
  16378. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16379. 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 +
  16380. "&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
  16381. fmt.Println(api)
  16382. } else {
  16383. 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 +
  16384. "&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)
  16385. }
  16386. resp, requestErr := http.Get(api)
  16387. if requestErr != nil {
  16388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16389. return
  16390. }
  16391. body, ioErr := ioutil.ReadAll(resp.Body)
  16392. if ioErr != nil {
  16393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16395. return
  16396. }
  16397. var respJSON map[string]interface{}
  16398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16401. return
  16402. }
  16403. var status string
  16404. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16405. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16406. var token string
  16407. var res ResultTwo //1101结果
  16408. var res10265 ResultTwo10265 //1101结果
  16409. if status == "0" { //读卡成功
  16410. var card_info string //卡信息
  16411. var busi_card_info string
  16412. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16413. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16414. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16415. fmt.Println(card_info)
  16416. fmt.Println(busi_card_info)
  16417. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16418. result, _ := json.Marshal(respJSON)
  16419. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16420. utils.ErrorLog("解析失败:%v", err)
  16421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16422. return
  16423. }
  16424. res.ErrMsg = res10265.ErrMsg
  16425. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16426. res.Infcode = infocode
  16427. res.Output = res10265.Output
  16428. res.InfRefmsgid = res10265.InfRefmsgid
  16429. if res.Infcode == 0 {
  16430. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16431. if err == gorm.ErrRecordNotFound {
  16432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16433. return
  16434. } else if err != nil {
  16435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16436. return
  16437. } else {
  16438. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16439. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16440. infoStr := string(Iinfos)
  16441. idetinfoStr := string(Idetinfos)
  16442. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16443. psn := &models.HisPsn{
  16444. PsnNo: res.Output.Baseinfo.PsnNo,
  16445. PatientId: patient.ID,
  16446. Certno: res.Output.Baseinfo.Certno,
  16447. Brdy: b,
  16448. Age: float64(age),
  16449. //Brdy: res.Output.Baseinfo.Brdy,
  16450. Gend: res.Output.Baseinfo.Gend,
  16451. Naty: res.Output.Baseinfo.Naty,
  16452. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16453. PsnName: res.Output.Baseinfo.PsnName,
  16454. Idetinfo: idetinfoStr,
  16455. Insuinfo: infoStr,
  16456. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16457. CardInfo: card_info,
  16458. VerifyNumber: token,
  16459. }
  16460. var rf []*ResultFive
  16461. json.Unmarshal([]byte(infoStr), &rf)
  16462. var insutypes []*ResultFive
  16463. var insutype string
  16464. var is390 int = 0
  16465. var is310 int = 0
  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. service.CreateHisPsn(psn)
  16494. c.ServeSuccessJSON(map[string]interface{}{
  16495. "patient": patient,
  16496. "number": token,
  16497. "insutype": insutype,
  16498. })
  16499. }
  16500. } else {
  16501. c.ServeSuccessJSON(map[string]interface{}{
  16502. "failed_code": -10,
  16503. "msg": res.ErrMsg,
  16504. })
  16505. }
  16506. } else { //读卡失败
  16507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16508. return
  16509. }
  16510. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16511. var api string
  16512. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16513. "&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
  16514. resp, requestErr := http.Get(api)
  16515. if requestErr != nil {
  16516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16517. return
  16518. }
  16519. body, ioErr := ioutil.ReadAll(resp.Body)
  16520. if ioErr != nil {
  16521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. var respJSON map[string]interface{}
  16526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. return
  16530. }
  16531. var status string
  16532. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16533. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16534. var token string
  16535. var res ResultTwo //1101结果
  16536. if status == "1" { //读卡成功
  16537. var card_info string //卡信息
  16538. var busi_card_info string
  16539. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16540. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16541. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16542. fmt.Println(card_info)
  16543. fmt.Println(busi_card_info)
  16544. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16545. result, _ := json.Marshal(respJSON)
  16546. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16547. utils.ErrorLog("解析失败:%v", err)
  16548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16549. return
  16550. }
  16551. if res.Infcode == 0 {
  16552. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16553. if err == gorm.ErrRecordNotFound {
  16554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16555. return
  16556. } else if err != nil {
  16557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16558. return
  16559. } else {
  16560. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16561. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16562. infoStr := string(Iinfos)
  16563. idetinfoStr := string(Idetinfos)
  16564. psn := &models.HisPsn{
  16565. PsnNo: res.Output.Baseinfo.PsnNo,
  16566. PatientId: patient.ID,
  16567. Certno: res.Output.Baseinfo.Certno,
  16568. Gend: res.Output.Baseinfo.Gend,
  16569. Naty: res.Output.Baseinfo.Naty,
  16570. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16571. PsnName: res.Output.Baseinfo.PsnName,
  16572. Idetinfo: idetinfoStr,
  16573. Insuinfo: infoStr,
  16574. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16575. CardInfo: card_info,
  16576. VerifyNumber: token,
  16577. }
  16578. var rf []*ResultFive
  16579. json.Unmarshal([]byte(infoStr), &rf)
  16580. var insutypes []*ResultFive
  16581. var insutype string
  16582. var is390 int = 0
  16583. var is310 int = 0
  16584. for _, item := range rf {
  16585. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16586. insutypes = append(insutypes, item)
  16587. }
  16588. }
  16589. if len(insutypes) == 1 {
  16590. insutype = insutypes[0].Insutype
  16591. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16592. } else {
  16593. for _, i := range insutypes {
  16594. if i.Insutype == "390" {
  16595. is390 = 1
  16596. }
  16597. if i.Insutype == "310" {
  16598. is310 = 1
  16599. }
  16600. }
  16601. }
  16602. if is390 == 1 {
  16603. insutype = "390"
  16604. }
  16605. if is310 == 1 {
  16606. insutype = "310"
  16607. }
  16608. if len(insutypes) == 0 {
  16609. insutype = "310"
  16610. }
  16611. service.CreateHisPsn(psn)
  16612. c.ServeSuccessJSON(map[string]interface{}{
  16613. "patient": patient,
  16614. "number": token,
  16615. "insutype": insutype,
  16616. })
  16617. }
  16618. } else {
  16619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16620. return
  16621. }
  16622. } else { //读卡失败
  16623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16624. return
  16625. }
  16626. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16627. var api string
  16628. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16629. "&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
  16630. resp, requestErr := http.Get(api)
  16631. if requestErr != nil {
  16632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16633. return
  16634. }
  16635. body, ioErr := ioutil.ReadAll(resp.Body)
  16636. if ioErr != nil {
  16637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16639. return
  16640. }
  16641. var respJSON map[string]interface{}
  16642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16645. return
  16646. }
  16647. var status string
  16648. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16649. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16650. var token string
  16651. var res ResultTwo //1101结果
  16652. if status == "1" { //读卡成功
  16653. var card_info string //卡信息
  16654. var busi_card_info string
  16655. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16656. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16657. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16658. fmt.Println(card_info)
  16659. fmt.Println(busi_card_info)
  16660. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16661. result, _ := json.Marshal(respJSON)
  16662. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16663. utils.ErrorLog("解析失败:%v", err)
  16664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16665. return
  16666. }
  16667. if res.Infcode == 0 {
  16668. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16669. if err == gorm.ErrRecordNotFound {
  16670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16671. return
  16672. } else if err != nil {
  16673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16674. return
  16675. } else {
  16676. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16677. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16678. infoStr := string(Iinfos)
  16679. idetinfoStr := string(Idetinfos)
  16680. psn := &models.HisPsn{
  16681. PsnNo: res.Output.Baseinfo.PsnNo,
  16682. PatientId: patient.ID,
  16683. Certno: res.Output.Baseinfo.Certno,
  16684. Gend: res.Output.Baseinfo.Gend,
  16685. Naty: res.Output.Baseinfo.Naty,
  16686. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16687. PsnName: res.Output.Baseinfo.PsnName,
  16688. Idetinfo: idetinfoStr,
  16689. Insuinfo: infoStr,
  16690. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16691. CardInfo: card_info,
  16692. VerifyNumber: token,
  16693. }
  16694. var rf []*ResultFive
  16695. json.Unmarshal([]byte(infoStr), &rf)
  16696. var insutypes []*ResultFive
  16697. var insutype string
  16698. var is390 int = 0
  16699. var is310 int = 0
  16700. for _, item := range rf {
  16701. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16702. insutypes = append(insutypes, item)
  16703. }
  16704. }
  16705. if len(insutypes) == 1 {
  16706. insutype = insutypes[0].Insutype
  16707. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16708. } else {
  16709. for _, i := range insutypes {
  16710. if i.Insutype == "390" {
  16711. is390 = 1
  16712. }
  16713. if i.Insutype == "310" {
  16714. is310 = 1
  16715. }
  16716. }
  16717. }
  16718. if is390 == 1 {
  16719. insutype = "390"
  16720. }
  16721. if is310 == 1 {
  16722. insutype = "310"
  16723. }
  16724. if len(insutypes) == 0 {
  16725. insutype = "390"
  16726. }
  16727. service.CreateHisPsn(psn)
  16728. c.ServeSuccessJSON(map[string]interface{}{
  16729. "patient": patient,
  16730. "number": token,
  16731. "insutype": insutype,
  16732. })
  16733. }
  16734. } else {
  16735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16736. return
  16737. }
  16738. } else { //读卡失败
  16739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16740. return
  16741. }
  16742. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16743. //idNo := c.GetString("idNo")
  16744. //userName := c.GetString("userName")
  16745. //ecToken := c.GetString("ecToken")
  16746. //insuOrg := c.GetString("insuOrg")
  16747. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16748. utils.ErrorLog("解析失败:%v", json_result)
  16749. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16750. type ELeData struct {
  16751. Data struct {
  16752. IdNo string `json:"idNo"`
  16753. IdType string `json:"idType"`
  16754. UserName string `json:"userName"`
  16755. EcToken string `json:"ecToken"`
  16756. InsuOrg string `json:"insuOrg"`
  16757. Gender string `json:"gender"`
  16758. Birthday string `json:"birthday"`
  16759. Nationality string `json:"nationality"`
  16760. Email string `json:"email"`
  16761. Extra string `json:"extra"`
  16762. } `json:"data"`
  16763. Code int `json:"code"`
  16764. Message string `json:"message"`
  16765. }
  16766. var ele ELeData
  16767. err := json.Unmarshal([]byte(json_result), &ele)
  16768. if err != nil {
  16769. utils.ErrorLog("解析失败:%v", err)
  16770. }
  16771. token := ele.Data.EcToken
  16772. token = Remove0000(token)
  16773. 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)
  16774. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16775. var res ResultTwo
  16776. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16777. utils.ErrorLog("解析失败:%v", err)
  16778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16779. return
  16780. }
  16781. if res.Infcode == 0 {
  16782. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16783. if err == gorm.ErrRecordNotFound {
  16784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16785. return
  16786. } else if err != nil {
  16787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16788. return
  16789. } else {
  16790. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16791. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16792. infoStr := string(Iinfos)
  16793. idetinfoStr := string(Idetinfos)
  16794. psn := &models.HisPsn{
  16795. PsnNo: res.Output.Baseinfo.PsnNo,
  16796. PatientId: patient.ID,
  16797. Certno: res.Output.Baseinfo.Certno,
  16798. Gend: res.Output.Baseinfo.Gend,
  16799. Naty: res.Output.Baseinfo.Naty,
  16800. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16801. PsnName: res.Output.Baseinfo.PsnName,
  16802. Idetinfo: idetinfoStr,
  16803. Insuinfo: infoStr,
  16804. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16805. CardInfo: "",
  16806. Stage: "1",
  16807. VerifyNumber: token,
  16808. InsuplcAdmdvs: ele.Data.InsuOrg,
  16809. }
  16810. service.CreateHisPsn(psn)
  16811. var rf []*ResultFive
  16812. json.Unmarshal([]byte(infoStr), &rf)
  16813. var insutypes []*ResultFive
  16814. var insutype string
  16815. var is390 int = 0
  16816. var is310 int = 0
  16817. for _, item := range rf {
  16818. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16819. insutypes = append(insutypes, item)
  16820. }
  16821. }
  16822. if len(insutypes) == 1 {
  16823. insutype = insutypes[0].Insutype
  16824. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16825. } else {
  16826. for _, i := range insutypes {
  16827. if i.Insutype == "390" {
  16828. is390 = 1
  16829. }
  16830. if i.Insutype == "310" {
  16831. is310 = 1
  16832. }
  16833. }
  16834. }
  16835. if is390 == 1 {
  16836. insutype = "390"
  16837. }
  16838. if is310 == 1 {
  16839. insutype = "310"
  16840. }
  16841. if len(insutypes) == 0 {
  16842. insutype = "310"
  16843. }
  16844. c.ServeSuccessJSON(map[string]interface{}{
  16845. "patient": patient,
  16846. "number": token,
  16847. "insutype": insutype,
  16848. })
  16849. }
  16850. } else {
  16851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16852. return
  16853. }
  16854. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16855. //if initFlag == 0 {
  16856. //c.TestGetJiangXiBasBaseInit()
  16857. //}
  16858. //if initEleFlag == 0 {
  16859. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16860. //}
  16861. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16862. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16863. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16864. type ELeData struct {
  16865. Data struct {
  16866. IdNo string `json:"idNo"`
  16867. IdType string `json:"idType"`
  16868. UserName string `json:"userName"`
  16869. EcToken string `json:"ecToken"`
  16870. InsuOrg string `json:"insuOrg"`
  16871. Gender string `json:"gender"`
  16872. Birthday string `json:"birthday"`
  16873. Nationality string `json:"nationality"`
  16874. Email string `json:"email"`
  16875. Extra string `json:"extra"`
  16876. } `json:"data"`
  16877. Code int `json:"code"`
  16878. Message string `json:"message"`
  16879. }
  16880. var ele ELeData
  16881. err := json.Unmarshal([]byte(result), &ele)
  16882. if err != nil {
  16883. utils.ErrorLog("解析失败:%v", err)
  16884. }
  16885. token := ele.Data.EcToken
  16886. token = Remove0000(token)
  16887. 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)
  16888. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16889. var res ResultTwo
  16890. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16891. utils.ErrorLog("解析失败:%v", err)
  16892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16893. return
  16894. }
  16895. if res.Infcode == 0 {
  16896. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16897. if err == gorm.ErrRecordNotFound {
  16898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16899. return
  16900. } else if err != nil {
  16901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16902. return
  16903. } else {
  16904. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16905. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16906. infoStr := string(Iinfos)
  16907. idetinfoStr := string(Idetinfos)
  16908. psn := &models.HisPsn{
  16909. PsnNo: res.Output.Baseinfo.PsnNo,
  16910. PatientId: patient.ID,
  16911. Certno: res.Output.Baseinfo.Certno,
  16912. Gend: res.Output.Baseinfo.Gend,
  16913. Naty: res.Output.Baseinfo.Naty,
  16914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16915. PsnName: res.Output.Baseinfo.PsnName,
  16916. Idetinfo: idetinfoStr,
  16917. Insuinfo: infoStr,
  16918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16919. CardInfo: "",
  16920. VerifyNumber: token,
  16921. InsuplcAdmdvs: ele.Data.InsuOrg,
  16922. }
  16923. service.CreateHisPsn(psn)
  16924. var rf []*ResultFive
  16925. json.Unmarshal([]byte(infoStr), &rf)
  16926. var insutypes []*ResultFive
  16927. var insutype string
  16928. var is390 int = 0
  16929. var is310 int = 0
  16930. for _, item := range rf {
  16931. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16932. insutypes = append(insutypes, item)
  16933. }
  16934. }
  16935. if len(insutypes) == 1 {
  16936. insutype = insutypes[0].Insutype
  16937. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16938. } else {
  16939. for _, i := range insutypes {
  16940. if i.Insutype == "390" {
  16941. is390 = 1
  16942. }
  16943. if i.Insutype == "310" {
  16944. is310 = 1
  16945. }
  16946. }
  16947. }
  16948. if is390 == 1 {
  16949. insutype = "390"
  16950. }
  16951. if is310 == 1 {
  16952. insutype = "310"
  16953. }
  16954. if len(insutypes) == 0 {
  16955. insutype = "310"
  16956. }
  16957. c.ServeSuccessJSON(map[string]interface{}{
  16958. "patient": patient,
  16959. "number": token,
  16960. "insutype": insutype,
  16961. })
  16962. }
  16963. } else {
  16964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16965. return
  16966. }
  16967. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16968. //if initFlag == 0 {
  16969. //c.TestGetJiangXiBasBaseInit()
  16970. //}
  16971. //if initEleFlag == 0 {
  16972. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16973. //}
  16974. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16975. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16976. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16977. type ELeData struct {
  16978. Data struct {
  16979. IdNo string `json:"idNo"`
  16980. IdType string `json:"idType"`
  16981. UserName string `json:"userName"`
  16982. EcToken string `json:"ecToken"`
  16983. InsuOrg string `json:"insuOrg"`
  16984. Gender string `json:"gender"`
  16985. Birthday string `json:"birthday"`
  16986. Nationality string `json:"nationality"`
  16987. Email string `json:"email"`
  16988. Extra string `json:"extra"`
  16989. } `json:"data"`
  16990. Code int `json:"code"`
  16991. Message string `json:"message"`
  16992. }
  16993. var ele ELeData
  16994. err := json.Unmarshal([]byte(result), &ele)
  16995. if err != nil {
  16996. utils.ErrorLog("解析失败:%v", err)
  16997. }
  16998. token := ele.Data.EcToken
  16999. token = Remove0000(token)
  17000. 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)
  17001. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17002. var res ResultTwo
  17003. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17004. utils.ErrorLog("解析失败:%v", err)
  17005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17006. return
  17007. }
  17008. if res.Infcode == 0 {
  17009. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17010. if err == gorm.ErrRecordNotFound {
  17011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17012. return
  17013. } else if err != nil {
  17014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17015. return
  17016. } else {
  17017. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17018. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17019. infoStr := string(Iinfos)
  17020. idetinfoStr := string(Idetinfos)
  17021. psn := &models.HisPsn{
  17022. PsnNo: res.Output.Baseinfo.PsnNo,
  17023. PatientId: patient.ID,
  17024. Certno: res.Output.Baseinfo.Certno,
  17025. Gend: res.Output.Baseinfo.Gend,
  17026. Naty: res.Output.Baseinfo.Naty,
  17027. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17028. PsnName: res.Output.Baseinfo.PsnName,
  17029. Idetinfo: idetinfoStr,
  17030. Insuinfo: infoStr,
  17031. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17032. CardInfo: "",
  17033. VerifyNumber: token,
  17034. InsuplcAdmdvs: ele.Data.InsuOrg,
  17035. }
  17036. service.CreateHisPsn(psn)
  17037. var rf []*ResultFive
  17038. json.Unmarshal([]byte(infoStr), &rf)
  17039. var insutypes []*ResultFive
  17040. var insutype string
  17041. var is390 int = 0
  17042. var is310 int = 0
  17043. for _, item := range rf {
  17044. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17045. insutypes = append(insutypes, item)
  17046. }
  17047. }
  17048. if len(insutypes) == 1 {
  17049. insutype = insutypes[0].Insutype
  17050. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17051. } else {
  17052. for _, i := range insutypes {
  17053. if i.Insutype == "390" {
  17054. is390 = 1
  17055. }
  17056. if i.Insutype == "310" {
  17057. is310 = 1
  17058. }
  17059. }
  17060. }
  17061. if is390 == 1 {
  17062. insutype = "390"
  17063. }
  17064. if is310 == 1 {
  17065. insutype = "310"
  17066. }
  17067. if len(insutypes) == 0 {
  17068. insutype = "310"
  17069. }
  17070. c.ServeSuccessJSON(map[string]interface{}{
  17071. "patient": patient,
  17072. "number": token,
  17073. "insutype": insutype,
  17074. })
  17075. }
  17076. } else {
  17077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17078. return
  17079. }
  17080. } else if miConfig.MdtrtareaAdmvs == "360100" {
  17081. //if initFlag == 0 {
  17082. //c.TestGetJiangXiBasBaseInit()
  17083. //}
  17084. //if initEleFlag == 0 {
  17085. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17086. //}
  17087. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  17088. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  17089. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17090. type ELeData struct {
  17091. Data struct {
  17092. IdNo string `json:"idNo"`
  17093. IdType string `json:"idType"`
  17094. UserName string `json:"userName"`
  17095. EcToken string `json:"ecToken"`
  17096. InsuOrg string `json:"insuOrg"`
  17097. Gender string `json:"gender"`
  17098. Birthday string `json:"birthday"`
  17099. Nationality string `json:"nationality"`
  17100. Email string `json:"email"`
  17101. Extra string `json:"extra"`
  17102. } `json:"data"`
  17103. Code int `json:"code"`
  17104. Message string `json:"message"`
  17105. }
  17106. var ele ELeData
  17107. err := json.Unmarshal([]byte(result), &ele)
  17108. if err != nil {
  17109. utils.ErrorLog("解析失败:%v", err)
  17110. }
  17111. token := ele.Data.EcToken
  17112. token = Remove0000(token)
  17113. 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)
  17114. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17115. var res ResultTwo
  17116. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17117. utils.ErrorLog("解析失败:%v", err)
  17118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17119. return
  17120. }
  17121. if res.Infcode == 0 {
  17122. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17123. if err == gorm.ErrRecordNotFound {
  17124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17125. return
  17126. } else if err != nil {
  17127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17128. return
  17129. } else {
  17130. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17131. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17132. infoStr := string(Iinfos)
  17133. idetinfoStr := string(Idetinfos)
  17134. psn := &models.HisPsn{
  17135. PsnNo: res.Output.Baseinfo.PsnNo,
  17136. PatientId: patient.ID,
  17137. Certno: res.Output.Baseinfo.Certno,
  17138. Gend: res.Output.Baseinfo.Gend,
  17139. Naty: res.Output.Baseinfo.Naty,
  17140. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17141. PsnName: res.Output.Baseinfo.PsnName,
  17142. Idetinfo: idetinfoStr,
  17143. Insuinfo: infoStr,
  17144. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17145. CardInfo: "",
  17146. VerifyNumber: token,
  17147. InsuplcAdmdvs: ele.Data.InsuOrg,
  17148. }
  17149. service.CreateHisPsn(psn)
  17150. var rf []*ResultFive
  17151. json.Unmarshal([]byte(infoStr), &rf)
  17152. var insutypes []*ResultFive
  17153. var insutype string
  17154. var is390 int = 0
  17155. var is310 int = 0
  17156. for _, item := range rf {
  17157. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17158. insutypes = append(insutypes, item)
  17159. }
  17160. }
  17161. if len(insutypes) == 1 {
  17162. insutype = insutypes[0].Insutype
  17163. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17164. } else {
  17165. for _, i := range insutypes {
  17166. if i.Insutype == "390" {
  17167. is390 = 1
  17168. }
  17169. if i.Insutype == "310" {
  17170. is310 = 1
  17171. }
  17172. }
  17173. }
  17174. if is390 == 1 {
  17175. insutype = "390"
  17176. }
  17177. if is310 == 1 {
  17178. insutype = "310"
  17179. }
  17180. if len(insutypes) == 0 {
  17181. insutype = "310"
  17182. }
  17183. c.ServeSuccessJSON(map[string]interface{}{
  17184. "patient": patient,
  17185. "number": token,
  17186. "insutype": insutype,
  17187. })
  17188. }
  17189. } else {
  17190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17191. return
  17192. }
  17193. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17194. //if initFlag == 0 {
  17195. c.TestGetJiangXiBasBaseInit()
  17196. //}
  17197. //if initEleFlag == 0 {
  17198. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17199. //}
  17200. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17201. type ELeData struct {
  17202. Data struct {
  17203. IdNo string `json:"idNo"`
  17204. IdType string `json:"idType"`
  17205. UserName string `json:"userName"`
  17206. EcToken string `json:"ecToken"`
  17207. InsuOrg string `json:"insuOrg"`
  17208. Gender string `json:"gender"`
  17209. Birthday string `json:"birthday"`
  17210. Nationality string `json:"nationality"`
  17211. Email string `json:"email"`
  17212. Extra string `json:"extra"`
  17213. } `json:"data"`
  17214. Code int `json:"code"`
  17215. Message string `json:"message"`
  17216. }
  17217. var ele ELeData
  17218. err := json.Unmarshal([]byte(json_result), &ele)
  17219. if err != nil {
  17220. utils.ErrorLog("解析失败:%v", err)
  17221. }
  17222. token := ele.Data.EcToken
  17223. token = Remove0000(token)
  17224. 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)
  17225. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17226. var res ResultTwo
  17227. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17228. utils.ErrorLog("解析失败:%v", err)
  17229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17230. return
  17231. }
  17232. if res.Infcode == 0 {
  17233. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17234. if err == gorm.ErrRecordNotFound {
  17235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17236. return
  17237. } else if err != nil {
  17238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17239. return
  17240. } else {
  17241. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17242. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17243. infoStr := string(Iinfos)
  17244. idetinfoStr := string(Idetinfos)
  17245. psn := &models.HisPsn{
  17246. PsnNo: res.Output.Baseinfo.PsnNo,
  17247. PatientId: patient.ID,
  17248. Certno: res.Output.Baseinfo.Certno,
  17249. Gend: res.Output.Baseinfo.Gend,
  17250. Naty: res.Output.Baseinfo.Naty,
  17251. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17252. PsnName: res.Output.Baseinfo.PsnName,
  17253. Idetinfo: idetinfoStr,
  17254. Insuinfo: infoStr,
  17255. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17256. CardInfo: "",
  17257. VerifyNumber: token,
  17258. }
  17259. service.CreateHisPsn(psn)
  17260. var rf []*ResultFive
  17261. json.Unmarshal([]byte(infoStr), &rf)
  17262. var insutypes []*ResultFive
  17263. var insutype string
  17264. var is390 int = 0
  17265. var is310 int = 0
  17266. for _, item := range rf {
  17267. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17268. insutypes = append(insutypes, item)
  17269. }
  17270. }
  17271. if len(insutypes) == 1 {
  17272. insutype = insutypes[0].Insutype
  17273. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17274. } else {
  17275. for _, i := range insutypes {
  17276. if i.Insutype == "390" {
  17277. is390 = 1
  17278. }
  17279. if i.Insutype == "310" {
  17280. is310 = 1
  17281. }
  17282. }
  17283. }
  17284. if is390 == 1 {
  17285. insutype = "390"
  17286. }
  17287. if is310 == 1 {
  17288. insutype = "310"
  17289. }
  17290. if len(insutypes) == 0 {
  17291. insutype = "310"
  17292. }
  17293. c.ServeSuccessJSON(map[string]interface{}{
  17294. "patient": patient,
  17295. "number": token,
  17296. "insutype": insutype,
  17297. })
  17298. }
  17299. } else {
  17300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17301. return
  17302. }
  17303. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17304. type ELeData struct {
  17305. Code string `json:"code"`
  17306. Data struct {
  17307. Aac002 string `json:"aac002"`
  17308. Aaz500 string `json:"aaz500"`
  17309. ActCardNo string `json:"actCardNo"`
  17310. Bab520 string `json:"bab520"`
  17311. Bkz543 string `json:"bkz543"`
  17312. BusinessType string `json:"businessType"`
  17313. CertfCodg string `json:"certfCodg"`
  17314. EcIndexNo string `json:"ecIndexNo"`
  17315. EcToken string `json:"ecToken"`
  17316. ID0000 string `json:"id0000"`
  17317. IDNo string `json:"idNo"`
  17318. IDType string `json:"idType"`
  17319. Idcode string `json:"idcode"`
  17320. IdentityToken string `json:"identity_token"`
  17321. InsuOrg string `json:"insuOrg"`
  17322. OfficeID string `json:"officeId"`
  17323. OfficeName string `json:"officeName"`
  17324. OperatorID string `json:"operatorId"`
  17325. OperatorName string `json:"operatorName"`
  17326. OrgID string `json:"orgId"`
  17327. UserName string `json:"userName"`
  17328. } `json:"data"`
  17329. Infno interface{} `json:"infno"`
  17330. Message string `json:"message"`
  17331. OrgID string `json:"orgId"`
  17332. TransType string `json:"transType"`
  17333. }
  17334. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17335. outPutInfo = Remove0000(outPutInfo)
  17336. if len(outPutInfo) > 0 {
  17337. var ele ELeData
  17338. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17339. if err != nil {
  17340. utils.ErrorLog("解析失败:%v", err)
  17341. }
  17342. token := ele.Data.EcToken
  17343. fmt.Println(inputInfo)
  17344. fmt.Println(outPutInfo)
  17345. 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)
  17346. saveLog(result, requestLog, "1101", "获取人员信息")
  17347. var dat map[string]interface{}
  17348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17349. fmt.Println(dat)
  17350. } else {
  17351. fmt.Println(err)
  17352. }
  17353. userJSONBytes, _ := json.Marshal(dat)
  17354. var res ResultTwo
  17355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17356. utils.ErrorLog("解析失败:%v", err)
  17357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17358. return
  17359. }
  17360. res.ErrMsg = errMsgLog
  17361. if res.Infcode == 0 {
  17362. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17363. if err == gorm.ErrRecordNotFound {
  17364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17365. return
  17366. } else if err != nil {
  17367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17368. return
  17369. } else {
  17370. fmt.Println(res)
  17371. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17372. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17373. infoStr := string(Iinfos)
  17374. idetinfoStr := string(Idetinfos)
  17375. psn := &models.HisPsn{
  17376. PsnNo: res.Output.Baseinfo.PsnNo,
  17377. PatientId: patient.ID,
  17378. Certno: res.Output.Baseinfo.Certno,
  17379. Gend: res.Output.Baseinfo.Gend,
  17380. Naty: res.Output.Baseinfo.Naty,
  17381. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17382. PsnName: res.Output.Baseinfo.PsnName,
  17383. Idetinfo: idetinfoStr,
  17384. Insuinfo: infoStr,
  17385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17386. CardInfo: outPutInfo,
  17387. VerifyNumber: token,
  17388. InsuplcAdmdvs: ele.Data.InsuOrg,
  17389. }
  17390. service.CreateHisPsn(psn)
  17391. var rf []*ResultFive
  17392. json.Unmarshal([]byte(infoStr), &rf)
  17393. var insutypes []*ResultFive
  17394. var insutype string
  17395. var is390 int = 0
  17396. var is310 int = 0
  17397. for _, item := range rf {
  17398. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17399. insutypes = append(insutypes, item)
  17400. }
  17401. }
  17402. if len(insutypes) == 1 {
  17403. insutype = insutypes[0].Insutype
  17404. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17405. } else {
  17406. for _, i := range insutypes {
  17407. if i.Insutype == "390" {
  17408. is390 = 1
  17409. }
  17410. if i.Insutype == "310" {
  17411. is310 = 1
  17412. }
  17413. }
  17414. }
  17415. if is390 == 1 {
  17416. insutype = "390"
  17417. }
  17418. if is310 == 1 {
  17419. insutype = "310"
  17420. }
  17421. if len(insutypes) == 0 {
  17422. insutype = "310"
  17423. }
  17424. c.ServeSuccessJSON(map[string]interface{}{
  17425. "patient": patient,
  17426. "number": token,
  17427. "insutype": insutype,
  17428. })
  17429. }
  17430. } else {
  17431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17432. return
  17433. }
  17434. }
  17435. } else if miConfig.MdtrtareaAdmvs == "150404" {
  17436. var api string
  17437. 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 +
  17438. "&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
  17439. resp, requestErr := http.Get(api)
  17440. if requestErr != nil {
  17441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17442. return
  17443. }
  17444. body, ioErr := ioutil.ReadAll(resp.Body)
  17445. if ioErr != nil {
  17446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17448. return
  17449. }
  17450. var respJSON map[string]interface{}
  17451. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17454. return
  17455. }
  17456. var status string
  17457. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17458. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17459. var token string
  17460. var res ResultTwo //1101结果
  17461. var res10265 ResultTwo10265 //1101结果
  17462. if status == "0" { //读卡成功
  17463. var card_info string //卡信息
  17464. var busi_card_info string
  17465. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17466. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17467. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17468. fmt.Println(card_info)
  17469. fmt.Println(busi_card_info)
  17470. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17471. result, _ := json.Marshal(respJSON)
  17472. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17473. utils.ErrorLog("解析失败:%v", err)
  17474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17475. return
  17476. }
  17477. res.ErrMsg = res10265.ErrMsg
  17478. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17479. res.Infcode = infocode
  17480. res.Output = res10265.Output
  17481. res.InfRefmsgid = res10265.InfRefmsgid
  17482. if res.Infcode == 0 {
  17483. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17484. if err == gorm.ErrRecordNotFound {
  17485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17486. return
  17487. } else if err != nil {
  17488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17489. return
  17490. } else {
  17491. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17492. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17493. infoStr := string(Iinfos)
  17494. idetinfoStr := string(Idetinfos)
  17495. psn := &models.HisPsn{
  17496. PsnNo: res.Output.Baseinfo.PsnNo,
  17497. PatientId: patient.ID,
  17498. Certno: res.Output.Baseinfo.Certno,
  17499. Gend: res.Output.Baseinfo.Gend,
  17500. Naty: res.Output.Baseinfo.Naty,
  17501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17502. PsnName: res.Output.Baseinfo.PsnName,
  17503. Idetinfo: idetinfoStr,
  17504. Insuinfo: infoStr,
  17505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17506. CardInfo: card_info,
  17507. VerifyNumber: token,
  17508. }
  17509. var rf []*ResultFive
  17510. json.Unmarshal([]byte(infoStr), &rf)
  17511. var insutypes []*ResultFive
  17512. var insutype string
  17513. var is390 int = 0
  17514. var is310 int = 0
  17515. for _, item := range rf {
  17516. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17517. insutypes = append(insutypes, item)
  17518. }
  17519. }
  17520. if len(insutypes) == 1 {
  17521. insutype = insutypes[0].Insutype
  17522. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17523. } else {
  17524. for _, i := range insutypes {
  17525. if i.Insutype == "390" {
  17526. is390 = 1
  17527. }
  17528. if i.Insutype == "310" {
  17529. is310 = 1
  17530. }
  17531. }
  17532. }
  17533. if is390 == 1 {
  17534. insutype = "390"
  17535. }
  17536. if is310 == 1 {
  17537. insutype = "310"
  17538. }
  17539. if len(insutypes) == 0 {
  17540. insutype = "310"
  17541. }
  17542. service.CreateHisPsn(psn)
  17543. c.ServeSuccessJSON(map[string]interface{}{
  17544. "patient": patient,
  17545. "number": token,
  17546. "insutype": insutype,
  17547. })
  17548. }
  17549. } else {
  17550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17551. return
  17552. }
  17553. } else { //读卡失败
  17554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17555. return
  17556. }
  17557. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17558. res := c.GetoleInfo()
  17559. if res.Infcode == 0 {
  17560. var result string
  17561. if res.Output.MdtrtCertType == "01" {
  17562. 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)
  17563. } else if res.Output.MdtrtCertType == "02" {
  17564. 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)
  17565. } else if res.Output.MdtrtCertType == "03" {
  17566. 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)
  17567. }
  17568. var dat map[string]interface{}
  17569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17570. fmt.Println(dat)
  17571. } else {
  17572. fmt.Println(err)
  17573. }
  17574. userJSONBytes, _ := json.Marshal(dat)
  17575. var res2 ResultTwo
  17576. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17577. utils.ErrorLog("解析失败:%v", err)
  17578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17579. return
  17580. }
  17581. if res2.Infcode == 0 {
  17582. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17583. if err == gorm.ErrRecordNotFound {
  17584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17585. return
  17586. } else if err != nil {
  17587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17588. return
  17589. } else {
  17590. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17591. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17592. infoStr := string(Iinfos)
  17593. idetinfoStr := string(Idetinfos)
  17594. var rf []*ResultFive
  17595. json.Unmarshal([]byte(infoStr), &rf)
  17596. var insutypes []*ResultFive
  17597. var insutype string
  17598. var is390 int = 0
  17599. var is310 int = 0
  17600. //var insuplc_admdvs string
  17601. for _, item := range rf {
  17602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17603. insutypes = append(insutypes, item)
  17604. }
  17605. }
  17606. if len(insutypes) == 1 {
  17607. insutype = insutypes[0].Insutype
  17608. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17609. } else {
  17610. for _, i := range insutypes {
  17611. if i.Insutype == "390" {
  17612. is390 = 1
  17613. }
  17614. if i.Insutype == "310" {
  17615. is310 = 1
  17616. }
  17617. }
  17618. }
  17619. if is390 == 1 {
  17620. insutype = "390"
  17621. }
  17622. if is310 == 1 {
  17623. insutype = "310"
  17624. }
  17625. if len(insutypes) == 0 {
  17626. insutype = "310"
  17627. }
  17628. psn := &models.HisPsn{
  17629. PsnNo: res2.Output.Baseinfo.PsnNo,
  17630. PatientId: patient.ID,
  17631. Certno: res2.Output.Baseinfo.Certno,
  17632. Gend: res2.Output.Baseinfo.Gend,
  17633. Naty: res2.Output.Baseinfo.Naty,
  17634. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17635. PsnName: res2.Output.Baseinfo.PsnName,
  17636. Idetinfo: idetinfoStr,
  17637. Insuinfo: infoStr,
  17638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17639. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17640. VerifyNumber: res.Output.EcToken,
  17641. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17642. }
  17643. if res.Output.MdtrtCertType == "01" {
  17644. psn.VerifyNumber = res.Output.EcToken
  17645. //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)
  17646. } else if res.Output.MdtrtCertType == "02" {
  17647. psn.VerifyNumber = res.Output.CardNo
  17648. //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)
  17649. } else if res.Output.MdtrtCertType == "03" {
  17650. psn.VerifyNumber = res.Output.MdtrtCertNo
  17651. //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)
  17652. }
  17653. service.CreateHisPsn(psn)
  17654. var balc float64
  17655. for _, item := range rf {
  17656. if item.Insutype == insutype {
  17657. balc = item.Balc
  17658. }
  17659. }
  17660. c.ServeSuccessJSON(map[string]interface{}{
  17661. "patient": patient,
  17662. "number": res.Output.CardNo,
  17663. "insutype": insutype,
  17664. "blac": balc,
  17665. "desc": idetinfoStr,
  17666. })
  17667. }
  17668. } else {
  17669. c.ServeSuccessJSON(map[string]interface{}{
  17670. "failed_code": -10,
  17671. "msg": res2.ErrMsg,
  17672. })
  17673. }
  17674. } else {
  17675. c.ServeSuccessJSON(map[string]interface{}{
  17676. "failed_code": -10,
  17677. "msg": res.ErrMsg,
  17678. })
  17679. }
  17680. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17681. var res ResultTwo
  17682. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17683. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17684. "&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)
  17685. resp, requestErr := http.Get(api)
  17686. if requestErr != nil {
  17687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17688. return
  17689. }
  17690. body, ioErr := ioutil.ReadAll(resp.Body)
  17691. if ioErr != nil {
  17692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17694. return
  17695. }
  17696. var respJSON map[string]interface{}
  17697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17700. return
  17701. }
  17702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17703. result, _ := json.Marshal(respJSON)
  17704. fmt.Println("log")
  17705. fmt.Println(string(result))
  17706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17707. utils.ErrorLog("解析失败:%v", err)
  17708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17709. return
  17710. }
  17711. if res.Infcode == 0 {
  17712. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17713. if err == gorm.ErrRecordNotFound {
  17714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17715. return
  17716. } else if err != nil {
  17717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17718. return
  17719. } else {
  17720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17722. infoStr := string(Iinfos)
  17723. idetinfoStr := string(Idetinfos)
  17724. var rf []*ResultFive
  17725. json.Unmarshal([]byte(infoStr), &rf)
  17726. var insutypes []*ResultFive
  17727. var insutype string
  17728. var is390 int = 0
  17729. var is310 int = 0
  17730. for _, item := range rf {
  17731. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17732. insutypes = append(insutypes, item)
  17733. }
  17734. }
  17735. if len(insutypes) == 1 {
  17736. insutype = insutypes[0].Insutype
  17737. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17738. } else {
  17739. for _, i := range insutypes {
  17740. if i.Insutype == "390" {
  17741. is390 = 1
  17742. }
  17743. if i.Insutype == "310" {
  17744. is310 = 1
  17745. }
  17746. }
  17747. }
  17748. if is390 == 1 {
  17749. insutype = "390"
  17750. }
  17751. if is310 == 1 {
  17752. insutype = "310"
  17753. }
  17754. if len(insutypes) == 0 {
  17755. insutype = "390"
  17756. }
  17757. var insuplc_admdvs string
  17758. for _, item := range rf {
  17759. if item.Insutype == insutype {
  17760. insuplc_admdvs = item.InsuplcAdmdvs
  17761. }
  17762. }
  17763. psn := &models.HisPsn{
  17764. PsnNo: res.Output.Baseinfo.PsnNo,
  17765. PatientId: patient.ID,
  17766. Certno: res.Output.Baseinfo.Certno,
  17767. Gend: res.Output.Baseinfo.Gend,
  17768. Naty: res.Output.Baseinfo.Naty,
  17769. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17770. PsnName: res.Output.Baseinfo.PsnName,
  17771. Idetinfo: idetinfoStr,
  17772. Insuinfo: infoStr,
  17773. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17774. InsuplcAdmdvs: insuplc_admdvs,
  17775. }
  17776. service.CreateHisPsn(psn)
  17777. c.ServeSuccessJSON(map[string]interface{}{
  17778. "patient": patient,
  17779. "number": res.Output.Baseinfo.Certno,
  17780. })
  17781. }
  17782. } else {
  17783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17784. return
  17785. }
  17786. } else {
  17787. type ELeData struct {
  17788. Code string `json:"code"`
  17789. Data struct {
  17790. Aac002 string `json:"aac002"`
  17791. Aaz500 string `json:"aaz500"`
  17792. ActCardNo string `json:"actCardNo"`
  17793. Bab520 string `json:"bab520"`
  17794. Bkz543 string `json:"bkz543"`
  17795. BusinessType string `json:"businessType"`
  17796. CertfCodg string `json:"certfCodg"`
  17797. EcIndexNo string `json:"ecIndexNo"`
  17798. EcToken string `json:"ecToken"`
  17799. ID0000 string `json:"id0000"`
  17800. IDNo string `json:"idNo"`
  17801. IDType string `json:"idType"`
  17802. Idcode string `json:"idcode"`
  17803. IdentityToken string `json:"identity_token"`
  17804. InsuOrg string `json:"insuOrg"`
  17805. OfficeID string `json:"officeId"`
  17806. OfficeName string `json:"officeName"`
  17807. OperatorID string `json:"operatorId"`
  17808. OperatorName string `json:"operatorName"`
  17809. OrgID string `json:"orgId"`
  17810. UserName string `json:"userName"`
  17811. } `json:"data"`
  17812. Infno interface{} `json:"infno"`
  17813. Message string `json:"message"`
  17814. OrgID string `json:"orgId"`
  17815. TransType string `json:"transType"`
  17816. }
  17817. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17818. fmt.Println(result)
  17819. outPutInfo := Remove0000(result)
  17820. fmt.Println(outPutInfo)
  17821. if len(outPutInfo) > 0 {
  17822. var ele ELeData
  17823. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17824. if err != nil {
  17825. utils.ErrorLog("解析失败:%v", err)
  17826. }
  17827. token := ele.Data.EcToken
  17828. fmt.Println(outPutInfo)
  17829. 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)
  17830. saveLog(result, requestLog, "1101", "获取人员信息")
  17831. var dat map[string]interface{}
  17832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17833. fmt.Println(dat)
  17834. } else {
  17835. fmt.Println(err)
  17836. }
  17837. userJSONBytes, _ := json.Marshal(dat)
  17838. var res ResultTwo
  17839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17840. utils.ErrorLog("解析失败:%v", err)
  17841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17842. return
  17843. }
  17844. if res.Infcode == 0 {
  17845. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17846. if err == gorm.ErrRecordNotFound {
  17847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17848. return
  17849. } else if err != nil {
  17850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17851. return
  17852. } else {
  17853. fmt.Println(res)
  17854. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17855. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17856. infoStr := string(Iinfos)
  17857. idetinfoStr := string(Idetinfos)
  17858. psn := &models.HisPsn{
  17859. PsnNo: res.Output.Baseinfo.PsnNo,
  17860. PatientId: patient.ID,
  17861. Certno: res.Output.Baseinfo.Certno,
  17862. Gend: res.Output.Baseinfo.Gend,
  17863. Naty: res.Output.Baseinfo.Naty,
  17864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17865. PsnName: res.Output.Baseinfo.PsnName,
  17866. Idetinfo: idetinfoStr,
  17867. Insuinfo: infoStr,
  17868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17869. CardInfo: outPutInfo,
  17870. VerifyNumber: token,
  17871. InsuplcAdmdvs: ele.Data.InsuOrg,
  17872. }
  17873. service.CreateHisPsn(psn)
  17874. var rf []*ResultFive
  17875. json.Unmarshal([]byte(infoStr), &rf)
  17876. var insutypes []*ResultFive
  17877. var insutype string
  17878. var is390 int = 0
  17879. var is310 int = 0
  17880. for _, item := range rf {
  17881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17882. insutypes = append(insutypes, item)
  17883. }
  17884. }
  17885. if len(insutypes) == 1 {
  17886. insutype = insutypes[0].Insutype
  17887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17888. } else {
  17889. for _, i := range insutypes {
  17890. if i.Insutype == "390" {
  17891. is390 = 1
  17892. }
  17893. if i.Insutype == "310" {
  17894. is310 = 1
  17895. }
  17896. }
  17897. }
  17898. if is390 == 1 {
  17899. insutype = "390"
  17900. }
  17901. if is310 == 1 {
  17902. insutype = "310"
  17903. }
  17904. if len(insutypes) == 0 {
  17905. insutype = "310"
  17906. }
  17907. c.ServeSuccessJSON(map[string]interface{}{
  17908. "patient": patient,
  17909. "number": token,
  17910. "insutype": insutype,
  17911. })
  17912. }
  17913. } else {
  17914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17915. return
  17916. }
  17917. }
  17918. //fmt.Println(result)
  17919. //
  17920. //if initFlag == 0 {
  17921. // c.TestGetBasBaseInit()
  17922. //}
  17923. //token := c.GetEleBaseInfo()
  17924. //
  17925. //token = Remove0000(token)
  17926. //
  17927. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17928. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17929. ////
  17930. //var res ResultTwo
  17931. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17932. // utils.ErrorLog("解析失败:%v", err)
  17933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17934. // return
  17935. //}
  17936. //
  17937. //if res.Infcode == 0 {
  17938. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17939. // if err == gorm.ErrRecordNotFound {
  17940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17941. // return
  17942. // } else if err != nil {
  17943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17944. // return
  17945. //
  17946. // } else {
  17947. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17948. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17949. // infoStr := string(Iinfos)
  17950. // idetinfoStr := string(Idetinfos)
  17951. //
  17952. //
  17953. //
  17954. //
  17955. // var rf []*ResultFive
  17956. // json.Unmarshal([]byte(infoStr), &rf)
  17957. //
  17958. // var insutypes []*ResultFive
  17959. // var insutype string
  17960. // var is390 int = 0
  17961. // var is310 int = 0
  17962. // var insuplc_admdvs string
  17963. //
  17964. // for _, item := range rf {
  17965. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17966. // insutypes = append(insutypes, item)
  17967. // }
  17968. // }
  17969. //
  17970. // if len(insutypes) == 1 {
  17971. // insutype = insutypes[0].Insutype
  17972. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17973. // } else {
  17974. // for _, i := range insutypes {
  17975. // if i.Insutype == "390" {
  17976. // is390 = 1
  17977. // }
  17978. //
  17979. // if i.Insutype == "310" {
  17980. // is310 = 1
  17981. // }
  17982. // }
  17983. // }
  17984. // if is390 == 1 {
  17985. // insutype = "390"
  17986. // }
  17987. //
  17988. // if is310 == 1 {
  17989. // insutype = "310"
  17990. // }
  17991. // if len(insutypes) == 0 {
  17992. // insutype = "310"
  17993. // }
  17994. // for _, item := range rf {
  17995. // if item.Insutype == insutype {
  17996. // insuplc_admdvs = item.InsuplcAdmdvs
  17997. // }
  17998. // }
  17999. // psn := &models.HisPsn{
  18000. // PsnNo: res.Output.Baseinfo.PsnNo,
  18001. // Age: res.Output.Baseinfo.Age,
  18002. // PatientId: patient.ID,
  18003. // Certno: res.Output.Baseinfo.Certno,
  18004. // Brdy: res.Output.Baseinfo.Brdy,
  18005. // Gend: res.Output.Baseinfo.Gend,
  18006. // Naty: res.Output.Baseinfo.Naty,
  18007. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  18008. // PsnName: res.Output.Baseinfo.PsnName,
  18009. // Idetinfo: idetinfoStr,
  18010. // Insuinfo: infoStr,
  18011. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18012. // CardInfo: "",
  18013. // VerifyNumber: token,
  18014. // InsuplcAdmdvs: insuplc_admdvs,
  18015. // }
  18016. // service.CreateHisPsn(psn)
  18017. //
  18018. // c.ServeSuccessJSON(map[string]interface{}{
  18019. // "patient": patient,
  18020. // "number": token,
  18021. // })
  18022. // }
  18023. //} else {
  18024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18025. // return
  18026. //}
  18027. }
  18028. break
  18029. case 5:
  18030. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  18031. var api string
  18032. if miConfig.MdtrtareaAdmvs == "320830" {
  18033. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  18034. "&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
  18035. fmt.Println(api)
  18036. } else if miConfig.MdtrtareaAdmvs == "320921" {
  18037. 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 +
  18038. "&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
  18039. fmt.Println(api)
  18040. } else {
  18041. 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 +
  18042. "&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)
  18043. }
  18044. resp, requestErr := http.Get(api)
  18045. if requestErr != nil {
  18046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18047. return
  18048. }
  18049. body, ioErr := ioutil.ReadAll(resp.Body)
  18050. if ioErr != nil {
  18051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18053. return
  18054. }
  18055. var respJSON map[string]interface{}
  18056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18059. return
  18060. }
  18061. var status string
  18062. status = respJSON["data"].(map[string]interface{})["status"].(string)
  18063. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  18064. var token string
  18065. var res ResultTwo //1101结果
  18066. var res10265 ResultTwo10265 //1101结果
  18067. if status == "0" { //读卡成功
  18068. var card_info string //卡信息
  18069. //var busi_card_info string
  18070. var auth_info string
  18071. token = respJSON["data"].(map[string]interface{})["token"].(string)
  18072. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  18073. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  18074. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  18075. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  18076. result, _ := json.Marshal(respJSON)
  18077. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18078. utils.ErrorLog("解析失败:%v", err)
  18079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18080. return
  18081. }
  18082. res.ErrMsg = res10265.ErrMsg
  18083. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18084. res.Infcode = infocode
  18085. res.Output = res10265.Output
  18086. res.InfRefmsgid = res10265.InfRefmsgid
  18087. if res.Infcode == 0 {
  18088. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  18089. if err == gorm.ErrRecordNotFound {
  18090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18091. return
  18092. } else if err != nil {
  18093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18094. return
  18095. } else {
  18096. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18097. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18098. infoStr := string(Iinfos)
  18099. idetinfoStr := string(Idetinfos)
  18100. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  18101. psn := &models.HisPsn{
  18102. PsnNo: res.Output.Baseinfo.PsnNo,
  18103. PatientId: patient.ID,
  18104. Certno: res.Output.Baseinfo.Certno,
  18105. Gend: res.Output.Baseinfo.Gend,
  18106. Brdy: b,
  18107. Age: float64(age),
  18108. Naty: res.Output.Baseinfo.Naty,
  18109. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18110. PsnName: res.Output.Baseinfo.PsnName,
  18111. Idetinfo: idetinfoStr,
  18112. Insuinfo: infoStr,
  18113. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18114. CardInfo: card_info,
  18115. VerifyNumber: token,
  18116. AuthInfo: auth_info,
  18117. }
  18118. var rf []*ResultFive
  18119. json.Unmarshal([]byte(infoStr), &rf)
  18120. var insutypes []*ResultFive
  18121. var insutype string
  18122. var is390 int = 0
  18123. var is310 int = 0
  18124. for _, item := range rf {
  18125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18126. insutypes = append(insutypes, item)
  18127. }
  18128. }
  18129. if len(insutypes) == 1 {
  18130. insutype = insutypes[0].Insutype
  18131. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18132. } else {
  18133. for _, i := range insutypes {
  18134. if i.Insutype == "390" {
  18135. is390 = 1
  18136. }
  18137. if i.Insutype == "310" {
  18138. is310 = 1
  18139. }
  18140. }
  18141. }
  18142. if is390 == 1 {
  18143. insutype = "390"
  18144. }
  18145. if is310 == 1 {
  18146. insutype = "310"
  18147. }
  18148. if len(insutypes) == 0 {
  18149. insutype = "310"
  18150. }
  18151. service.CreateHisPsn(psn)
  18152. c.ServeSuccessJSON(map[string]interface{}{
  18153. "patient": patient,
  18154. "number": token,
  18155. "insutype": insutype,
  18156. })
  18157. }
  18158. } else {
  18159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18160. return
  18161. }
  18162. } else { //读卡失败
  18163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18164. return
  18165. }
  18166. }
  18167. break
  18168. }
  18169. }
  18170. var initFlag int64 = 0
  18171. var initEleFlag int64 = 0
  18172. func (c *HisApiController) TestGetBasBaseInit() {
  18173. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18174. Iinit := DllDef.MustFindProc("Init")
  18175. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18176. url := ""
  18177. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18178. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18179. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18180. url = ""
  18181. } else {
  18182. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18183. }
  18184. fmt.Println("SSCard的报错原因:", url)
  18185. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18186. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18187. if ret != 0 {
  18188. fmt.Println("SSCard的报错原因:", err)
  18189. fmt.Println("SSCard的运算结果为:", ret)
  18190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18191. return
  18192. }
  18193. result := int(ret)
  18194. fmt.Println("SSCard的运算结果为1:", result)
  18195. initFlag = 1
  18196. return
  18197. }
  18198. func (c *HisApiController) HandleJiangXiReadCard() {
  18199. fmt.Println("~~~~~~")
  18200. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18201. admin_user_id, _ := c.GetInt64("admin_user_id")
  18202. id_card_type, _ := c.GetInt64("id_card_type")
  18203. //certificates, _ := c.GetInt64("certificates")
  18204. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18205. if initFlag == 0 {
  18206. c.TestGetJiangXiBasBaseInit()
  18207. }
  18208. basStr := c.GetBasBaseInfo()
  18209. if len(basStr) == 0 {
  18210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18211. return
  18212. }
  18213. fmt.Println(basStr)
  18214. bas := strings.Split(basStr, "|")
  18215. basNumber := bas[1]
  18216. fmt.Println(basNumber)
  18217. card_sn := bas[3]
  18218. fmt.Println(card_sn)
  18219. 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, "")
  18220. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18221. var dat map[string]interface{}
  18222. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18223. fmt.Println(dat)
  18224. } else {
  18225. fmt.Println(err)
  18226. }
  18227. userJSONBytes, _ := json.Marshal(dat)
  18228. var res ResultTwo
  18229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18230. utils.ErrorLog("解析失败:%v", err)
  18231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18232. return
  18233. }
  18234. if res.Infcode == 0 {
  18235. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18236. if err == gorm.ErrRecordNotFound {
  18237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18238. return
  18239. } else if err != nil {
  18240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18241. return
  18242. } else {
  18243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18245. infoStr := string(Iinfos)
  18246. idetinfoStr := string(Idetinfos)
  18247. psn := &models.HisPsn{
  18248. PsnNo: res.Output.Baseinfo.PsnNo,
  18249. PatientId: patient.ID,
  18250. Certno: res.Output.Baseinfo.Certno,
  18251. Gend: res.Output.Baseinfo.Gend,
  18252. Naty: res.Output.Baseinfo.Naty,
  18253. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18254. PsnName: res.Output.Baseinfo.PsnName,
  18255. Idetinfo: idetinfoStr,
  18256. Insuinfo: infoStr,
  18257. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18258. CardInfo: basStr,
  18259. VerifyNumber: "",
  18260. }
  18261. service.CreateHisPsn(psn)
  18262. c.ServeSuccessJSON(map[string]interface{}{
  18263. "patient": patient,
  18264. "number": basNumber,
  18265. })
  18266. }
  18267. } else {
  18268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18269. return
  18270. }
  18271. }
  18272. func (c *HisApiController) TestGetHnBasBaseInit() {
  18273. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18274. Iinit := DllDef.MustFindProc("Init")
  18275. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18276. //http://10.77.211.236/CSB/hsa-fsi-1303
  18277. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18278. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18279. // 调用 Init 函数
  18280. 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"))))
  18281. //if ret != 0 {
  18282. fmt.Println("SSCard的报错原因:", err)
  18283. fmt.Println("SSCard的运算结果为:", ret)
  18284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18285. // return
  18286. //}
  18287. result := int(ret)
  18288. fmt.Println("SSCard的运算结果为1:", result)
  18289. initFlag = 1
  18290. return
  18291. }
  18292. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18293. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18294. Iinit := DllDef.MustFindProc("Init")
  18295. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18296. //http://10.77.211.236/CSB/hsa-fsi-1303
  18297. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18298. if ret != 0 {
  18299. fmt.Println("SSCard的报错原因:", err)
  18300. fmt.Println("SSCard的运算结果为:", ret)
  18301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18302. return
  18303. }
  18304. result := int(ret)
  18305. fmt.Println("SSCard的运算结果为1:", result)
  18306. initFlag = 1
  18307. return
  18308. }
  18309. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18310. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18311. Iinit := DllDef.MustFindProc("Init")
  18312. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18313. //http://10.77.211.236/CSB/hsa-fsi-1303
  18314. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18315. if ret != 0 {
  18316. fmt.Println("SSCard的报错原因:", err)
  18317. fmt.Println("SSCard的运算结果为:", ret)
  18318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18319. return
  18320. }
  18321. result := int(ret)
  18322. fmt.Println("SSCard的运算结果为1:", result)
  18323. initFlag = 1
  18324. return
  18325. }
  18326. func (c *HisApiController) GetSFZBaseInfo() string {
  18327. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18328. readCard := DllDef.MustFindProc("ReadSFZ")
  18329. if readCard == nil {
  18330. fmt.Println("readcard is nil")
  18331. readCard = DllDef.MustFindProc("ReadSFZ")
  18332. }
  18333. str := make([]byte, 8096)
  18334. str1 := make([]byte, 8096)
  18335. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18336. fmt.Println(r)
  18337. return Remove0000(string(str))
  18338. }
  18339. func (c *HisApiController) GetEleBaseInfo() string {
  18340. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18341. readCard := DllDef.MustFindProc("GetQRBase")
  18342. fmt.Println(readCard)
  18343. if readCard == nil {
  18344. fmt.Println("readcard is nil")
  18345. readCard = DllDef.MustFindProc("GetQRBase")
  18346. }
  18347. str := make([]byte, 1024)
  18348. str1 := make([]byte, 1024)
  18349. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18350. fmt.Println(ret2)
  18351. fmt.Println(string(str1))
  18352. fmt.Println(string(str))
  18353. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18354. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18355. if ret2 != 0 {
  18356. return ""
  18357. }
  18358. return string(str)
  18359. }
  18360. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18361. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18362. readCard := DllDef.MustFindProc("NationEcTrans")
  18363. fmt.Println(readCard)
  18364. fmt.Println("!!!!!")
  18365. pBusiCardInfo := make([]byte, 2048)
  18366. input := make(map[string]interface{})
  18367. inputData := make(map[string]interface{})
  18368. inputData["orgId"] = code
  18369. inputData["businessType"] = "01101"
  18370. inputData["operatorId"] = "1"
  18371. inputData["operatorName"] = "admin"
  18372. inputData["officeId"] = "001"
  18373. inputData["officeName"] = "血透室"
  18374. inputData["deviceType"] = ""
  18375. input["data"] = inputData
  18376. input["orgId"] = code
  18377. input["transType"] = "ec.query"
  18378. bytesData, _ := json.Marshal(input)
  18379. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18380. fmt.Println(ret2)
  18381. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18382. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18383. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18384. }
  18385. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18386. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18387. readCard := DllDef.MustFindProc("NationEcTrans")
  18388. fmt.Println(readCard)
  18389. fmt.Println("!!!!!")
  18390. pBusiCardInfo := make([]byte, 2048)
  18391. input := make(map[string]interface{})
  18392. inputData := make(map[string]interface{})
  18393. inputData["orgId"] = code
  18394. inputData["businessType"] = "01101"
  18395. inputData["operatorId"] = "9"
  18396. inputData["operatorName"] = "admin"
  18397. inputData["officeId"] = "001"
  18398. inputData["officeName"] = "血透室"
  18399. inputData["deviceType"] = ""
  18400. input["data"] = inputData
  18401. input["orgId"] = code
  18402. input["transType"] = "ec.query"
  18403. bytesData, _ := json.Marshal(input)
  18404. 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])))
  18405. fmt.Println(ret2)
  18406. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18407. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18408. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18409. }
  18410. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18411. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18412. readCard := DllDef.MustFindProc("NationEcTrans")
  18413. fmt.Println(readCard)
  18414. fmt.Println("!!!!!")
  18415. pBusiCardInfo := make([]byte, 2048)
  18416. input := make(map[string]interface{})
  18417. inputData := make(map[string]interface{})
  18418. inputData["orgId"] = code
  18419. inputData["businessType"] = "01301"
  18420. inputData["operatorId"] = "9"
  18421. inputData["operatorName"] = "admin"
  18422. inputData["officeId"] = "001"
  18423. inputData["officeName"] = "血透室"
  18424. inputData["deviceType"] = ""
  18425. input["data"] = inputData
  18426. input["orgId"] = code
  18427. input["transType"] = "ec.query"
  18428. bytesData, _ := json.Marshal(input)
  18429. 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])))
  18430. fmt.Println(ret2)
  18431. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18432. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18433. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18434. }
  18435. func GetJxEleBaseInfo(org_id int64) string {
  18436. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18437. readCard := DllDef.MustFindProc("NationEcTrans")
  18438. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18439. if readCard == nil {
  18440. fmt.Println("readcard is nil")
  18441. readCard = DllDef.MustFindProc("NationEcTrans")
  18442. }
  18443. str1 := make([]byte, 1024)
  18444. data := make(map[string]interface{})
  18445. inputData := make(map[string]interface{})
  18446. inputData["orgId"] = miConfig.Code
  18447. inputData["businessType"] = "01101"
  18448. inputData["operatorId"] = "test001"
  18449. inputData["operatorName"] = "cn"
  18450. inputData["officeId"] = "32760"
  18451. inputData["officeName"] = "waike"
  18452. inputData["deviceType"] = ""
  18453. data["data"] = inputData
  18454. data["transType"] = "ec.query"
  18455. data["extra "] = ""
  18456. data["orgId"] = miConfig.Code
  18457. bytesData, _ := json.Marshal(data)
  18458. //bytesData, _ := json.Marshal(data)
  18459. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18460. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18461. fmt.Println(ret2)
  18462. fmt.Println(string(str1))
  18463. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18464. if ret2 != 0 {
  18465. return ""
  18466. }
  18467. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18468. }
  18469. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18470. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18471. // readCard := DllDef.MustFindProc("NationEcTrans")
  18472. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18473. //
  18474. // if readCard == nil {
  18475. // fmt.Println("readcard is nil")
  18476. // readCard = DllDef.MustFindProc("NationEcTrans")
  18477. // }
  18478. // str1 := make([]byte, 1024)
  18479. //
  18480. // data := make(map[string]interface{})
  18481. //
  18482. // inputData := make(map[string]interface{})
  18483. // inputData["orgId"] = miConfig.Code
  18484. // inputData["businessType"] = "01101"
  18485. // inputData["operatorId"] = "test001"
  18486. // inputData["operatorName"] = "cn"
  18487. // inputData["officeId"] = "32760"
  18488. // inputData["officeName"] = "waike"
  18489. // inputData["deviceType"] = ""
  18490. //
  18491. // data["data"] = inputData
  18492. // data["transType"] = "ec.query"
  18493. // data["extra "] = ""
  18494. // data["orgId"] = miConfig.Code
  18495. // bytesData, _ := json.Marshal(data)
  18496. // //bytesData, _ := json.Marshal(data)
  18497. //
  18498. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18499. //
  18500. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18501. // fmt.Println(ret2)
  18502. // fmt.Println(string(str1))
  18503. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18504. //
  18505. // if ret2 != 0 {
  18506. // return ""
  18507. // }
  18508. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18509. //}
  18510. func GetJxEleBaseInitInfo(org_id int64) string {
  18511. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18512. readCard := DllDef.MustFindProc("NationEcTrans")
  18513. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18514. if readCard == nil {
  18515. fmt.Println("readcard is nil")
  18516. readCard = DllDef.MustFindProc("NationEcTrans")
  18517. }
  18518. str1 := make([]byte, 2048)
  18519. data := make(map[string]interface{})
  18520. inputData := make(map[string]interface{})
  18521. inputData["orgId"] = miConfig.Code
  18522. inputData["businessType"] = "01101"
  18523. inputData["operatorId"] = "1"
  18524. inputData["operatorName"] = "huangchuang"
  18525. inputData["officeId"] = "101"
  18526. inputData["officeName"] = "xuetou"
  18527. inputData["deviceType"] = ""
  18528. data["data"] = inputData
  18529. data["transType"] = "ec.query"
  18530. data["orgId"] = miConfig.Code
  18531. bytesData, _ := json.Marshal(data)
  18532. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18533. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18534. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18535. fmt.Println(ret2)
  18536. fmt.Println(string(str1))
  18537. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18538. if ret2 != 0 {
  18539. return ""
  18540. }
  18541. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18542. initEleFlag = 1
  18543. }
  18544. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18545. }
  18546. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18547. // // 构建命令
  18548. // cmd := exec.Command("python", "b.py")
  18549. //
  18550. // // 执行命令并等待完成
  18551. // output, err := cmd.CombinedOutput()
  18552. // if err != nil {
  18553. // fmt.Println("Error executing Python script:", err)
  18554. // return
  18555. // }
  18556. //
  18557. // // 打印Python脚本的输出
  18558. // fmt.Println(string(output))
  18559. //}
  18560. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18561. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18562. readCard := DllDef.MustFindProc("gxyb_call")
  18563. if readCard == nil {
  18564. fmt.Println("readcard is nil")
  18565. readCard = DllDef.MustFindProc("gxyb_call")
  18566. }
  18567. str := make([]byte, 1024)
  18568. str1 := make([]byte, 1024)
  18569. //data := make(map[string]interface{})
  18570. currentTime := time.Now()
  18571. // 格式化时间为 "YYYYMMDDHH24MISS"
  18572. formattedTime := currentTime.Format("20060102150405")
  18573. inputData := make(map[string]interface{})
  18574. inputData2 := make(map[string]interface{})
  18575. inputData["transNo"] = "1401"
  18576. inputData["transType"] = "passwordCheck"
  18577. inputData["timestamp"] = formattedTime
  18578. inputData2["fixmedinsCode"] = code
  18579. inputData2["psnNo"] = ""
  18580. inputData["data"] = inputData2
  18581. jsonBytes, err := json.Marshal(inputData)
  18582. if err != nil {
  18583. fmt.Println("Error encoding map to JSON:", err)
  18584. }
  18585. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18586. fmt.Println(string(str1))
  18587. fmt.Println(string(str))
  18588. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18589. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18590. if ret2 != 0 {
  18591. return ""
  18592. }
  18593. return string(str)
  18594. }
  18595. func (c *HisApiController) GetoleInfo() Response {
  18596. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18597. defer ole.CoUninitialize()
  18598. // Replace with the ProgID or CLSID of your COM object
  18599. progID := "YinHai.XJ.Actual.Interface.New"
  18600. // Create COM object
  18601. unknown, err := oleutil.CreateObject(progID)
  18602. if err != nil {
  18603. fmt.Println("Unable to create COM object:", err)
  18604. }
  18605. defer unknown.Release()
  18606. // Query for the IDispatch interface
  18607. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18608. if err != nil {
  18609. fmt.Println("Unable to get IDispatch interface:", err)
  18610. }
  18611. defer dispatch.Release()
  18612. // Prepare parameters
  18613. transNo := "1401"
  18614. transType := "passwordCheck"
  18615. timestamp := time.Now().Unix()
  18616. fixmedinsCode := "H45072101171"
  18617. psnNo := ""
  18618. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18619. result2 := ""
  18620. // Call COM object's method using the IDispatch interface
  18621. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18622. fmt.Println(resulr)
  18623. fmt.Println(result2)
  18624. if err != nil {
  18625. fmt.Println("调用COM对象方法失败:", err)
  18626. }
  18627. var response Response
  18628. err2 := json.Unmarshal([]byte(result2), &response)
  18629. if err2 != nil {
  18630. fmt.Println("解析JSON失败:", err)
  18631. }
  18632. return response
  18633. }
  18634. func (c *HisApiController) GetBasBaseInfo() string {
  18635. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18636. readCard := DllDef.MustFindProc("ReadCardBas")
  18637. if readCard == nil {
  18638. fmt.Println("readcard is nil")
  18639. readCard = DllDef.MustFindProc("ReadCardBas")
  18640. }
  18641. str := make([]byte, 1024)
  18642. str1 := make([]byte, 1024)
  18643. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18644. fmt.Println(string(str1))
  18645. fmt.Println(string(str))
  18646. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18647. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18648. if ret2 != 0 {
  18649. return ""
  18650. }
  18651. return string(str)
  18652. }
  18653. type Program struct {
  18654. FunctionID string `xml:"function_id"`
  18655. CardInfo string `xml:"cardinfo"`
  18656. User string `xml:"user"`
  18657. }
  18658. func (c *HisApiController) GetBasBaseInfo1111() string {
  18659. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18660. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18661. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18662. if readCard == nil {
  18663. fmt.Println("readcard is nil")
  18664. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18665. }
  18666. if readCard2 == nil {
  18667. fmt.Println("readcard is nil")
  18668. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18669. }
  18670. str := make([]byte, 1024)
  18671. str1 := make([]byte, 1024)
  18672. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18673. str3 := make([]byte, 1024)
  18674. str4 := make([]byte, 1024)
  18675. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18676. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18677. //if err != nil {
  18678. // fmt.Println("Error opening file:", err)
  18679. //}
  18680. //defer file.Close()
  18681. //
  18682. //var lastProgram Program
  18683. //scanner := bufio.NewScanner(file)
  18684. //inProgram := false
  18685. //
  18686. //for scanner.Scan() {
  18687. // line := scanner.Text()
  18688. // if strings.Contains(line, "<program>") {
  18689. // inProgram = true
  18690. // programXML := "<program>"
  18691. // for scanner.Scan() {
  18692. // line = scanner.Text()
  18693. // programXML += line
  18694. // if strings.Contains(line, "</program>") {
  18695. // programXML += "</program>"
  18696. // break
  18697. // }
  18698. // }
  18699. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18700. // // 解析成功,更新最后的 Program
  18701. // }
  18702. // inProgram = false
  18703. // }
  18704. //}
  18705. //
  18706. // fmt.Println("Error reading file:", inProgram)
  18707. //
  18708. //if err := scanner.Err(); err != nil {
  18709. // fmt.Println("Error reading file:", err)
  18710. //}
  18711. // 输出最后一次的 Program
  18712. //fmt.Printf("最后一次的 <program>:\n")
  18713. //fmt.Printf("<program>\n")
  18714. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18715. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18716. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18717. //fmt.Printf("</program>\n")
  18718. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18719. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18720. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18721. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18722. return ConvertToString(string(str), "gbk", "utf-8")
  18723. }
  18724. func (c *HisApiController) GetBasBaseInfo22222() string {
  18725. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18726. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18727. if readCard == nil {
  18728. fmt.Println("readcard is nil")
  18729. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18730. }
  18731. str := make([]byte, 1024)
  18732. str1 := make([]byte, 1024)
  18733. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18734. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18735. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18736. //if err != nil {
  18737. // fmt.Println("Error opening file:", err)
  18738. //}
  18739. //defer file.Close()
  18740. //
  18741. //var lastProgram Program
  18742. //scanner := bufio.NewScanner(file)
  18743. //inProgram := false
  18744. //
  18745. //for scanner.Scan() {
  18746. // line := scanner.Text()
  18747. // if strings.Contains(line, "<program>") {
  18748. // inProgram = true
  18749. // programXML := "<program>"
  18750. // for scanner.Scan() {
  18751. // line = scanner.Text()
  18752. // programXML += line
  18753. // if strings.Contains(line, "</program>") {
  18754. // programXML += "</program>"
  18755. // break
  18756. // }
  18757. // }
  18758. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18759. // // 解析成功,更新最后的 Program
  18760. // }
  18761. // inProgram = false
  18762. // }
  18763. //}
  18764. //
  18765. // fmt.Println("Error reading file:", inProgram)
  18766. //
  18767. //if err := scanner.Err(); err != nil {
  18768. // fmt.Println("Error reading file:", err)
  18769. //}
  18770. // 输出最后一次的 Program
  18771. //fmt.Printf("最后一次的 <program>:\n")
  18772. //fmt.Printf("<program>\n")
  18773. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18774. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18775. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18776. //fmt.Printf("</program>\n")
  18777. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18778. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18779. return ConvertToString(string(str1), "gbk", "utf-8")
  18780. }
  18781. func (c *HisApiController) GetahBasBaseInfo() string {
  18782. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18783. readCard := DllDef.MustFindProc("iReadCardBas")
  18784. if readCard == nil {
  18785. fmt.Println("readcard is nil")
  18786. readCard = DllDef.MustFindProc("iReadCardBas")
  18787. }
  18788. //str := make([]byte, 1024)
  18789. str1 := make([]byte, 1024)
  18790. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18791. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18792. //if err != nil {
  18793. // fmt.Println("Error opening file:", err)
  18794. //}
  18795. //defer file.Close()
  18796. //
  18797. //var lastProgram Program
  18798. //scanner := bufio.NewScanner(file)
  18799. //inProgram := false
  18800. //
  18801. //for scanner.Scan() {
  18802. // line := scanner.Text()
  18803. // if strings.Contains(line, "<program>") {
  18804. // inProgram = true
  18805. // programXML := "<program>"
  18806. // for scanner.Scan() {
  18807. // line = scanner.Text()
  18808. // programXML += line
  18809. // if strings.Contains(line, "</program>") {
  18810. // programXML += "</program>"
  18811. // break
  18812. // }
  18813. // }
  18814. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18815. // // 解析成功,更新最后的 Program
  18816. // }
  18817. // inProgram = false
  18818. // }
  18819. //}
  18820. //
  18821. // fmt.Println("Error reading file:", inProgram)
  18822. //
  18823. //if err := scanner.Err(); err != nil {
  18824. // fmt.Println("Error reading file:", err)
  18825. //}
  18826. // 输出最后一次的 Program
  18827. //fmt.Printf("最后一次的 <program>:\n")
  18828. //fmt.Printf("<program>\n")
  18829. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18830. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18831. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18832. //fmt.Printf("</program>\n")
  18833. fmt.Println(string(str1))
  18834. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18835. if ret2 != 0 {
  18836. return ""
  18837. }
  18838. return string(str1)
  18839. }
  18840. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18841. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18842. readCard := DllDef.MustFindProc("read_cardinfo")
  18843. if readCard == nil {
  18844. fmt.Println("readcard is nil")
  18845. readCard = DllDef.MustFindProc("read_cardinfo")
  18846. }
  18847. str := make([]byte, 1024) //卡号
  18848. str1 := make([]byte, 1024) //卡识别码
  18849. str2 := make([]byte, 1024) //身份证号
  18850. str3 := make([]byte, 1024) //姓名
  18851. str4 := make([]byte, 1024) //错误信息
  18852. 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])))
  18853. fmt.Println(string(str1))
  18854. fmt.Println(string(str))
  18855. fmt.Println(string(str2))
  18856. fmt.Println(string(str3))
  18857. fmt.Println(string(str4))
  18858. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18859. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18860. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18861. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18862. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18863. if ret2 != 0 {
  18864. return "", "", "", "", ""
  18865. }
  18866. return string(str), string(str1), string(str2), string(str3), string(str4)
  18867. }
  18868. type CustomFundPay struct {
  18869. FundPayType string `json:"fund_pay_type"`
  18870. FundPayamt float64 `json:"fund_payamt"`
  18871. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18872. }
  18873. //func (c *HisApiController) GetBatchSettleList() {
  18874. // start_time_str := c.GetString("start_time")
  18875. // //end_time_str := c.GetString("end_time")
  18876. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18877. //
  18878. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18879. //
  18880. // for _, item := range orders {
  18881. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18882. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18883. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18884. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18885. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18886. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18887. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18888. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18889. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18890. //
  18891. // if order.ID == 0 {
  18892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18893. // return
  18894. // }
  18895. //
  18896. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18897. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18898. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18899. // //fmt.Println(count)
  18900. // //var zero string
  18901. // //number := count + 1
  18902. // //if number >= 1000 {
  18903. // // zero = "0000" + strconv.FormatInt(number, 10)
  18904. // //} else if number >= 10000 {
  18905. // // zero = "000" + strconv.FormatInt(number, 10)
  18906. // //} else if number >= 100000 {
  18907. // // zero = "00" + strconv.FormatInt(number, 10)
  18908. // //} else if number >= 1000000 {
  18909. // // zero = "0" + strconv.FormatInt(number, 10)
  18910. // //} else {
  18911. // // zero = strconv.FormatInt(number, 10)
  18912. // //}
  18913. // //fmt.Println(zero)
  18914. //
  18915. // struct4101 := service.Struct4101{
  18916. // PsnNo: order.PsnNo,
  18917. // MdtrtId: order.MdtrtId,
  18918. // SetlId: order.SetlId,
  18919. // PsnName: order.PsnName,
  18920. // Gend: order.Gend,
  18921. // Brdy: his.Brdy,
  18922. // Age: his.Age,
  18923. // Naty: order.Naty,
  18924. // PatnCertType: "01",
  18925. // Certno: order.Certno,
  18926. // Prfs: "90",
  18927. // ConerName: roles[0].UserName,
  18928. // PatnRlts: "99",
  18929. // ConerAddr: miConfig.OrgName,
  18930. // ConerTel: admin.Mobile,
  18931. // HiType: order.Insutype,
  18932. // Insuplc: miConfig.InsuplcAdmdvs,
  18933. // MaindiagFlag: "1",
  18934. // BillCode: order.SetlId,
  18935. // BillNo: order.SetlId,
  18936. // BizSn: order.Number,
  18937. // PsnSelfPay: order.PsnPartAmt,
  18938. // PsnOwnPay: order.PsnPartAmt,
  18939. // AcctPay: order.AcctPay,
  18940. // PsnCashpay: order.PsnCashPay,
  18941. // HiPaymtd: "1",
  18942. // Hsorg: miConfig.InsuplcAdmdvs,
  18943. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18944. // MedinsFillPsn: curRoles.UserName,
  18945. // MedinsFillDept: miConfig.OrgName,
  18946. // IptMedType: "2",
  18947. // }
  18948. // struct4101.SetlBegnDate = order.SetlTime
  18949. // struct4101.SetlEndDate = order.SetlTime
  18950. // time_arr := strings.Split(order.SetlTime, " ")
  18951. // struct4101.AdmTime = time_arr[0]
  18952. // struct4101.AdmEndTime = time_arr[0]
  18953. //
  18954. // var rf []CustomFundPay
  18955. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18956. //
  18957. // var tempFunPays []service.CustomStruct
  18958. // for _, item := range rf {
  18959. // var tempFunPay service.CustomStruct
  18960. // tempFunPay.FundPayamt = item.FundPayamt
  18961. // tempFunPay.FundPayType = item.FundPayType
  18962. // tempFunPays = append(tempFunPays, tempFunPay)
  18963. // }
  18964. // struct4101.CustomStruct = tempFunPays
  18965. //
  18966. // var tempDiaginfos []service.DiaginfoStructTwo
  18967. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18968. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18969. //
  18970. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18971. // var config []*models.HisXtDiagnoseConfig
  18972. // for _, item := range diagnosis_ids {
  18973. // id, _ := strconv.ParseInt(item, 10, 64)
  18974. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18975. // config = append(config, &diagnosisConfig)
  18976. // }
  18977. //
  18978. // for index, item := range config {
  18979. // if index == 0 {
  18980. // var tempDiaginfo service.DiaginfoStructTwo
  18981. // tempDiaginfo.DiagCode = item.CountryCode
  18982. // tempDiaginfo.DiagName = item.CountryContentName
  18983. // tempDiaginfo.DiagType = "1"
  18984. // tempDiaginfo.MaindiagFlag = "1"
  18985. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18986. // } else {
  18987. // var tempDiaginfo service.DiaginfoStructTwo
  18988. // tempDiaginfo.DiagCode = item.CountryCode
  18989. // tempDiaginfo.DiagName = item.CountryContentName
  18990. // tempDiaginfo.DiagType = "1"
  18991. // tempDiaginfo.MaindiagFlag = "0"
  18992. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18993. // }
  18994. // }
  18995. // struct4101.Diseinfo = tempDiaginfos
  18996. //
  18997. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18998. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18999. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19000. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19001. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19002. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19003. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19004. //
  19005. // var iteminfo service.IteminfoStruct
  19006. //
  19007. // var bedCostTotal float64 = 0 //床位总费
  19008. // var bedCostSelfTotal float64 = 0 //床位自费
  19009. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19010. //
  19011. // var operationCostTotal float64 = 0 //手术费
  19012. // var operationCostSelfTotal float64 = 0 //手术费
  19013. // var operationCostPartSelfTotal float64 = 0 //手术费
  19014. //
  19015. // var otherCostTotal float64 = 0 //其他费用
  19016. // var otherCostSelfTotal float64 = 0 //其他费用
  19017. // var otherCostPartSelfTotal float64 = 0 //其他费用
  19018. //
  19019. // var materialCostTotal float64 = 0 //材料费
  19020. // var materialCostSelfTotal float64 = 0 //材料费
  19021. // var materialCostPartSelfTotal float64 = 0 //材料费
  19022. //
  19023. // var westernMedicineCostTotal float64 = 0 //西药费
  19024. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  19025. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19026. //
  19027. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19028. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19029. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19030. //
  19031. // var checkCostTotal float64 = 0 //检查费
  19032. // var checkCostSelfTotal float64 = 0 //检查费
  19033. // var checkCostPartSelfTotal float64 = 0 //检查费
  19034. //
  19035. // var laboratoryCostTotal float64 = 0 //化验费
  19036. // var laboratoryCostSelfTotal float64 = 0 //化验费
  19037. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19038. //
  19039. // var treatCostTotal float64 = 0 //治疗费用
  19040. // var treatCostSelfTotal float64 = 0 //治疗费用
  19041. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  19042. //
  19043. // decimal.DivisionPrecision = 2
  19044. //
  19045. // var bed_fulamt_ownpay_amt float64 = 0
  19046. // var operation_fulamt_ownpay_amt float64 = 0
  19047. // var other_fulamt_ownpay_amt float64 = 0
  19048. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  19049. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19050. // var check_fulamt_ownpay_amt float64 = 0
  19051. // var material_fulamt_ownpay_amt float64 = 0
  19052. // var laboratory_fulamt_ownpay_amt float64 = 0
  19053. // var treat_fulamt_ownpay_amt float64 = 0
  19054. //
  19055. // var bed_claa_sunmfee float64 = 0
  19056. // var bed_clab_amt float64 = 0
  19057. // var bed_other_amt float64 = 0
  19058. //
  19059. // var operation_claa_sunmfee float64 = 0
  19060. // var operation_clab_amt float64 = 0
  19061. // var operation_other_amt float64 = 0
  19062. //
  19063. // var other_claa_sunmfee float64 = 0
  19064. // var other_clab_amt float64 = 0
  19065. // var other_other_amt float64 = 0
  19066. //
  19067. // var westernMedicine_claa_sunmfee float64 = 0
  19068. // var westernMedicine_clab_amt float64 = 0
  19069. // var westernMedicine_other_amt float64 = 0
  19070. //
  19071. // var chineseTraditional_claa_sunmfee float64 = 0
  19072. // var chineseTraditional_clab_amt float64 = 0
  19073. // var chineseTraditional_other_amt float64 = 0
  19074. //
  19075. // var check_claa_sunmfee float64 = 0
  19076. // var check_clab_amt float64 = 0
  19077. // var check_other_amt float64 = 0
  19078. //
  19079. // var material_claa_sunmfee float64 = 0
  19080. // var material_clab_amt float64 = 0
  19081. // var material_other_amt float64 = 0
  19082. //
  19083. // var laboratory_claa_sunmfee float64 = 0
  19084. // var laboratory_clab_amt float64 = 0
  19085. // var laboratory_other_amt float64 = 0
  19086. //
  19087. // var treat_claa_sunmfee float64 = 0
  19088. // var treat_clab_amt float64 = 0
  19089. // var treat_other_amt float64 = 0
  19090. //
  19091. // for _, item := range order.HisOrderInfo {
  19092. // if item.MedChrgitmType == "01" { //床位费
  19093. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19094. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19095. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19096. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19097. // if item.ChrgitmLv == "1" {
  19098. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19099. // }
  19100. // if item.ChrgitmLv == "2" {
  19101. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19102. //
  19103. // }
  19104. // if item.ChrgitmLv == "3" {
  19105. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19106. // }
  19107. //
  19108. // }
  19109. //
  19110. // if item.MedChrgitmType == "03" { //检查费
  19111. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19112. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19113. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19114. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19115. // if item.ChrgitmLv == "1" {
  19116. //
  19117. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19118. //
  19119. // }
  19120. // if item.ChrgitmLv == "2" {
  19121. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19122. //
  19123. // }
  19124. // if item.ChrgitmLv == "3" {
  19125. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19126. // }
  19127. // }
  19128. //
  19129. // if item.MedChrgitmType == "04" { //化验费
  19130. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19131. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19132. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19133. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19134. // if item.ChrgitmLv == "1" {
  19135. //
  19136. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19137. //
  19138. // }
  19139. // if item.ChrgitmLv == "2" {
  19140. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19141. //
  19142. // }
  19143. // if item.ChrgitmLv == "3" {
  19144. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19145. // }
  19146. // }
  19147. //
  19148. // if item.MedChrgitmType == "05" { //治疗费
  19149. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19150. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19151. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19152. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19153. // if item.ChrgitmLv == "1" {
  19154. //
  19155. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19156. //
  19157. // }
  19158. // if item.ChrgitmLv == "2" {
  19159. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19160. //
  19161. // }
  19162. // if item.ChrgitmLv == "3" {
  19163. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19164. // }
  19165. // }
  19166. //
  19167. // if item.MedChrgitmType == "06" { //手术费
  19168. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19169. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19170. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19171. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19172. //
  19173. // if item.ChrgitmLv == "1" {
  19174. //
  19175. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19176. //
  19177. // }
  19178. // if item.ChrgitmLv == "2" {
  19179. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19180. //
  19181. // }
  19182. // if item.ChrgitmLv == "3" {
  19183. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19184. // }
  19185. // }
  19186. //
  19187. // if item.MedChrgitmType == "08" { //材料费
  19188. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19189. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19190. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19191. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19192. // if item.ChrgitmLv == "1" {
  19193. //
  19194. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19195. //
  19196. // }
  19197. // if item.ChrgitmLv == "2" {
  19198. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19199. //
  19200. // }
  19201. // if item.ChrgitmLv == "3" {
  19202. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19203. // }
  19204. // }
  19205. //
  19206. // if item.MedChrgitmType == "09" { //西药费
  19207. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19208. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19209. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19210. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19211. // if item.ChrgitmLv == "1" {
  19212. //
  19213. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19214. //
  19215. // }
  19216. // if item.ChrgitmLv == "2" {
  19217. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19218. //
  19219. // }
  19220. // if item.ChrgitmLv == "3" {
  19221. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19222. // }
  19223. // }
  19224. //
  19225. // if item.MedChrgitmType == "11" { //中成费
  19226. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19227. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19228. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19229. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19230. // if item.ChrgitmLv == "1" {
  19231. //
  19232. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19233. //
  19234. // }
  19235. // if item.ChrgitmLv == "2" {
  19236. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19237. //
  19238. // }
  19239. // if item.ChrgitmLv == "3" {
  19240. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19241. // }
  19242. // }
  19243. //
  19244. // if item.MedChrgitmType == "14" { //其他费
  19245. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19246. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19247. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19248. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19249. // if item.ChrgitmLv == "1" {
  19250. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19251. //
  19252. // }
  19253. // if item.ChrgitmLv == "2" {
  19254. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19255. //
  19256. // }
  19257. // if item.ChrgitmLv == "3" {
  19258. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19259. // }
  19260. // }
  19261. //
  19262. // }
  19263. //
  19264. // var iteminfoStructs []service.IteminfoStruct
  19265. //
  19266. // if bedCostTotal != 0 {
  19267. // iteminfo.MedChrgitm = "01"
  19268. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19269. // iteminfo.Amt = bedCostTotal
  19270. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19271. // iteminfo.ClabAmt = bed_clab_amt
  19272. // iteminfo.OthAmt = bed_other_amt
  19273. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19274. // }
  19275. //
  19276. // if checkCostTotal != 0 {
  19277. // iteminfo.MedChrgitm = "03"
  19278. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19279. // iteminfo.Amt = checkCostTotal
  19280. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19281. // iteminfo.ClabAmt = check_clab_amt
  19282. // iteminfo.OthAmt = check_other_amt
  19283. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19284. //
  19285. // }
  19286. //
  19287. // if laboratoryCostTotal != 0 {
  19288. // iteminfo.MedChrgitm = "04"
  19289. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19290. // iteminfo.Amt = laboratoryCostTotal
  19291. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19292. // iteminfo.ClabAmt = laboratory_clab_amt
  19293. // iteminfo.OthAmt = laboratory_other_amt
  19294. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19295. //
  19296. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19297. //
  19298. // }
  19299. //
  19300. // if treatCostTotal != 0 {
  19301. // iteminfo.MedChrgitm = "05"
  19302. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19303. // iteminfo.Amt = treatCostTotal
  19304. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19305. // iteminfo.ClabAmt = treat_clab_amt
  19306. // iteminfo.OthAmt = treat_other_amt
  19307. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19308. // //(struct4101.IteminfoStruct, iteminfo)
  19309. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19310. // }
  19311. //
  19312. // if operationCostTotal != 0 {
  19313. // iteminfo.MedChrgitm = "06"
  19314. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19315. // iteminfo.Amt = operationCostTotal
  19316. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19317. // iteminfo.ClabAmt = operation_clab_amt
  19318. // iteminfo.OthAmt = operation_other_amt
  19319. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19320. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19321. // }
  19322. //
  19323. // if materialCostTotal != 0 {
  19324. // iteminfo.MedChrgitm = "08"
  19325. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19326. // iteminfo.Amt = materialCostTotal
  19327. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19328. // iteminfo.ClabAmt = material_clab_amt
  19329. // iteminfo.OthAmt = material_other_amt
  19330. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19331. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19332. // }
  19333. //
  19334. // if westernMedicineCostTotal != 0 {
  19335. // iteminfo.MedChrgitm = "09"
  19336. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19337. // iteminfo.Amt = westernMedicineCostTotal
  19338. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19339. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19340. // iteminfo.OthAmt = westernMedicine_other_amt
  19341. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19342. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19343. //
  19344. // }
  19345. // if chineseTraditionalMedicineCostTotal != 0 {
  19346. // iteminfo.MedChrgitm = "11"
  19347. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19348. // iteminfo.Amt = westernMedicineCostTotal
  19349. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19350. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19351. // iteminfo.OthAmt = westernMedicine_other_amt
  19352. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19353. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19354. //
  19355. // }
  19356. // if otherCostTotal != 0 {
  19357. // iteminfo.MedChrgitm = "14"
  19358. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19359. // iteminfo.Amt = otherCostTotal
  19360. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19361. // iteminfo.ClabAmt = other_clab_amt
  19362. // iteminfo.OthAmt = other_other_amt
  19363. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19364. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19365. //
  19366. // }
  19367. // struct4101.IteminfoStruct = iteminfoStructs
  19368. // struct4101.Ntly = "中国"
  19369. // struct4101.AdmCaty = "A03.06"
  19370. //
  19371. // struct4101.DoctorName = doctor.UserName
  19372. // struct4101.DoctorCode = doctor.DoctorNumber
  19373. //
  19374. // var res ResultSeventeen
  19375. //
  19376. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19377. // struct4101.BillCode = order.Number
  19378. // struct4101.BillNo = order.SetlId
  19379. // var resOther ResultSeventeenOther
  19380. // var pp models.PublicParams
  19381. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19382. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19383. // pp.FixmedinsName = miConfig.OrgName
  19384. // pp.FixmedinsCode = miConfig.Code
  19385. // pp.RequestUrl = miConfig.Url
  19386. // pp.Cainfo = miConfig.Cainfo
  19387. // pp.SecretKey = miConfig.SecretKey
  19388. // pp.AccessKey = miConfig.AccessKey
  19389. // pp.OpterName = curRoles.UserName
  19390. //
  19391. // client := &http.Client{}
  19392. // var req *http.Request
  19393. // data := make(map[string]interface{})
  19394. // data["struct4101"] = struct4101
  19395. // data["pp"] = pp
  19396. // bytesData, _ := json.Marshal(data)
  19397. // if miConfig.MdtrtareaAdmvs == "320921" {
  19398. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19399. // } else {
  19400. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19401. // }
  19402. // resp, _ := client.Do(req)
  19403. // defer resp.Body.Close()
  19404. // body, ioErr := ioutil.ReadAll(resp.Body)
  19405. // if ioErr != nil {
  19406. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19408. // return
  19409. // }
  19410. // var respJSON map[string]interface{}
  19411. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19412. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19414. // return
  19415. // }
  19416. //
  19417. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19418. // userJSONBytes, _ := json.Marshal(respJSON)
  19419. // fmt.Println("log")
  19420. // fmt.Println(string(userJSONBytes))
  19421. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19422. // utils.ErrorLog("解析失败:%v", err)
  19423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19424. // return
  19425. // }
  19426. // res.InfRefmsgid = resOther.InfRefmsgid
  19427. // res.Output = resOther.Output
  19428. // res.ErrMsg = resOther.ErrMsg
  19429. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19430. // res.Infcode = infocode
  19431. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19432. //
  19433. // var pp models.PublicParams
  19434. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19435. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19436. // pp.FixmedinsName = miConfig.OrgName
  19437. // pp.FixmedinsCode = miConfig.Code
  19438. // pp.RequestUrl = miConfig.Url
  19439. // pp.Cainfo = miConfig.Cainfo
  19440. // pp.SecretKey = miConfig.SecretKey
  19441. // pp.AccessKey = miConfig.AccessKey
  19442. // pp.OpterName = curRoles.UserName
  19443. // result, _ := service.Jxyb4101(struct4101, pp)
  19444. // var dat map[string]interface{}
  19445. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19446. // fmt.Println(dat)
  19447. // } else {
  19448. // fmt.Println(err)
  19449. // }
  19450. // userJSONBytes, _ := json.Marshal(dat)
  19451. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19452. // utils.ErrorLog("解析失败:%v", err)
  19453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19454. // return
  19455. // }
  19456. //
  19457. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19458. // var pp models.PublicParams
  19459. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19460. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19461. // pp.FixmedinsName = miConfig.OrgName
  19462. // pp.FixmedinsCode = miConfig.Code
  19463. // pp.RequestUrl = miConfig.Url
  19464. // pp.Cainfo = miConfig.Cainfo
  19465. // pp.SecretKey = miConfig.SecretKey
  19466. // pp.AccessKey = miConfig.AccessKey
  19467. // pp.OpterName = curRoles.UserName
  19468. // result, _ := service.Hnyb4101(struct4101, pp)
  19469. // var dat map[string]interface{}
  19470. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19471. // fmt.Println(dat)
  19472. // } else {
  19473. // fmt.Println(err)
  19474. // }
  19475. // userJSONBytes, _ := json.Marshal(dat)
  19476. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19477. // utils.ErrorLog("解析失败:%v", err)
  19478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19479. // return
  19480. // }
  19481. //
  19482. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  19483. // var resOther ResultSeventeenOther
  19484. //
  19485. // var pp models.PublicParams
  19486. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19487. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19488. // pp.FixmedinsName = miConfig.OrgName
  19489. // pp.FixmedinsCode = miConfig.Code
  19490. // pp.RequestUrl = miConfig.Url
  19491. // pp.Cainfo = miConfig.Cainfo
  19492. // pp.SecretKey = miConfig.SecretKey
  19493. // pp.AccessKey = miConfig.AccessKey
  19494. // pp.OpterName = curRoles.UserName
  19495. // client := &http.Client{}
  19496. // var req *http.Request
  19497. // data := make(map[string]interface{})
  19498. // data["struct4101"] = struct4101
  19499. // data["pp"] = pp
  19500. // bytesData, _ := json.Marshal(data)
  19501. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19502. // resp, _ := client.Do(req)
  19503. // defer resp.Body.Close()
  19504. // body, ioErr := ioutil.ReadAll(resp.Body)
  19505. // if ioErr != nil {
  19506. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19508. // return
  19509. // }
  19510. // var respJSON map[string]interface{}
  19511. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19512. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19514. // return
  19515. // }
  19516. //
  19517. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19518. // userJSONBytes, _ := json.Marshal(respJSON)
  19519. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19520. // utils.ErrorLog("解析失败:%v", err)
  19521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19522. // return
  19523. // }
  19524. // res.InfRefmsgid = resOther.InfRefmsgid
  19525. // res.Output = resOther.Output
  19526. // res.ErrMsg = resOther.ErrMsg
  19527. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19528. // res.Infcode = infocode
  19529. //
  19530. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19531. // var pp models.PublicParams
  19532. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19533. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19534. // pp.FixmedinsName = miConfig.OrgName
  19535. // pp.FixmedinsCode = miConfig.Code
  19536. // pp.RequestUrl = miConfig.Url
  19537. // pp.Cainfo = miConfig.Cainfo
  19538. // pp.SecretKey = miConfig.SecretKey
  19539. // pp.AccessKey = miConfig.AccessKey
  19540. // pp.OpterName = curRoles.UserName
  19541. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19542. // fmt.Println(requestLog)
  19543. // fmt.Println(errMsgLog)
  19544. //
  19545. // saveLog(result, requestLog, "4101a", "上传清单")
  19546. //
  19547. // var dat map[string]interface{}
  19548. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19549. // fmt.Println(dat)
  19550. // } else {
  19551. // fmt.Println(err)
  19552. // }
  19553. // userJSONBytes, _ := json.Marshal(dat)
  19554. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19555. // utils.ErrorLog("解析失败:%v", err)
  19556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19557. // return
  19558. // }
  19559. //
  19560. // } else {
  19561. //
  19562. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19563. // var dat map[string]interface{}
  19564. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19565. // fmt.Println(dat)
  19566. // } else {
  19567. // fmt.Println(err)
  19568. // }
  19569. // userJSONBytes, _ := json.Marshal(dat)
  19570. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19571. // utils.ErrorLog("解析失败:%v", err)
  19572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19573. // return
  19574. // }
  19575. // }
  19576. //
  19577. // if res.Infcode != 0 {
  19578. // adminUser := c.GetAdminUserInfo()
  19579. // errlog := &models.HisOrderError{
  19580. // UserOrgId: adminUser.CurrentOrgId,
  19581. // Ctime: time.Now().Unix(),
  19582. // Mtime: time.Now().Unix(),
  19583. // ErrMsg: res.ErrMsg,
  19584. // Status: 1,
  19585. // PatientId: order.ID,
  19586. // Stage: 10265,
  19587. // }
  19588. // service.CreateErrMsgLog(errlog)
  19589. // continue
  19590. // } else {
  19591. // //order.FaPiaoNumber = zero
  19592. // //order.FaPiaoCode = last_order.FaPiaoCode
  19593. // //service.UpdateOrder(order)
  19594. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19595. // Number: res.Output.SetlListId,
  19596. // Status: 1,
  19597. // Ctime: time.Now().Unix(),
  19598. // Mtime: time.Now().Unix(),
  19599. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19600. // IsUpload: 1,
  19601. // OrderId: order.ID,
  19602. // }
  19603. // service.CreateUploadRecord(hisFundSettleListResult)
  19604. // c.ServeSuccessJSON(map[string]interface{}{
  19605. // "msg": "上传成功",
  19606. // "result": hisFundSettleListResult,
  19607. // })
  19608. // continue
  19609. // }
  19610. // }
  19611. //}
  19612. func (c *HisApiController) GetbatchSettleList() {
  19613. //order_id, _ := c.GetInt64("order_id")
  19614. admin_user_id, _ := c.GetInt64("admin_user_id")
  19615. start_date := c.GetString("start_date")
  19616. end_date := c.GetString("end_date")
  19617. orders, _ := service.GetAllHisOrderTwo10485(start_date, end_date)
  19618. for _, item := range orders {
  19619. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19620. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19621. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19622. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19623. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19624. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19625. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19626. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19627. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19628. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19629. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19630. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19631. //fmt.Println(count)
  19632. //var zero string
  19633. //number := count + 1
  19634. //if number >= 1000 {
  19635. // zero = "0000" + strconv.FormatInt(number, 10)
  19636. //} else if number >= 10000 {
  19637. // zero = "000" + strconv.FormatInt(number, 10)
  19638. //} else if number >= 100000 {
  19639. // zero = "00" + strconv.FormatInt(number, 10)
  19640. //} else if number >= 1000000 {
  19641. // zero = "0" + strconv.FormatInt(number, 10)
  19642. //} else {
  19643. // zero = strconv.FormatInt(number, 10)
  19644. //}
  19645. //fmt.Println(zero)
  19646. struct4101 := service.Struct4101{
  19647. PsnNo: order.PsnNo,
  19648. MdtrtId: order.MdtrtId,
  19649. SetlId: order.SetlId,
  19650. PsnName: order.PsnName,
  19651. Gend: order.Gend,
  19652. Brdy: his.Brdy,
  19653. Age: his.Age,
  19654. Naty: order.Naty,
  19655. PatnCertType: "01",
  19656. Certno: order.Certno,
  19657. Prfs: "90",
  19658. ConerName: roles[0].UserName,
  19659. PatnRlts: "99",
  19660. ConerAddr: miConfig.OrgName,
  19661. ConerTel: admin.Mobile,
  19662. HiType: order.Insutype,
  19663. Insuplc: miConfig.InsuplcAdmdvs,
  19664. MaindiagFlag: "1",
  19665. BillCode: order.SetlId,
  19666. BillNo: order.SetlId,
  19667. BizSn: order.Number,
  19668. PsnSelfPay: order.PsnPartAmt,
  19669. PsnOwnPay: order.PsnPartAmt,
  19670. AcctPay: order.AcctPay,
  19671. PsnCashpay: order.PsnCashPay,
  19672. HiPaymtd: "1",
  19673. Hsorg: miConfig.InsuplcAdmdvs,
  19674. HsorgOpter: miConfig.InsuplcAdmdvs,
  19675. MedinsFillPsn: curRoles.UserName,
  19676. MedinsFillDept: miConfig.OrgName,
  19677. IptMedType: "2",
  19678. }
  19679. struct4101.SetlBegnDate = order.SetlTime
  19680. struct4101.SetlEndDate = order.SetlTime
  19681. time_arr := strings.Split(order.SetlTime, " ")
  19682. struct4101.AdmTime = time_arr[0]
  19683. struct4101.AdmEndTime = time_arr[0]
  19684. //var rf []CustomFundPay
  19685. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19686. //
  19687. //var tempFunPays []service.CustomStruct
  19688. //for _, item := range rf {
  19689. // var tempFunPay service.CustomStruct
  19690. // tempFunPay.FundPayamt = item.FundPayamt
  19691. // tempFunPay.FundPayType = item.FundPayType
  19692. // tempFunPays = append(tempFunPays, tempFunPay)
  19693. //}
  19694. //struct4101.CustomStruct = tempFunPays
  19695. var tempDiaginfos []service.DiaginfoStructTwo
  19696. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19697. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19698. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19699. var config []*models.HisXtDiagnoseConfig
  19700. for _, item := range diagnosis_ids {
  19701. id, _ := strconv.ParseInt(item, 10, 64)
  19702. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19703. config = append(config, &diagnosisConfig)
  19704. }
  19705. for index, item := range config {
  19706. if index == 0 {
  19707. var tempDiaginfo service.DiaginfoStructTwo
  19708. tempDiaginfo.DiagCode = item.CountryCode
  19709. tempDiaginfo.DiagName = item.CountryContentName
  19710. tempDiaginfo.DiagType = "1"
  19711. tempDiaginfo.MaindiagFlag = "1"
  19712. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19713. } else {
  19714. var tempDiaginfo service.DiaginfoStructTwo
  19715. tempDiaginfo.DiagCode = item.CountryCode
  19716. tempDiaginfo.DiagName = item.CountryContentName
  19717. tempDiaginfo.DiagType = "1"
  19718. tempDiaginfo.MaindiagFlag = "0"
  19719. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19720. }
  19721. }
  19722. struct4101.Diseinfo = tempDiaginfos
  19723. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19724. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19725. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19726. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19727. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19728. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19729. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19730. var iteminfo service.IteminfoStruct
  19731. var bedCostTotal float64 = 0 //床位总费
  19732. var bedCostSelfTotal float64 = 0 //床位自费
  19733. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19734. var operationCostTotal float64 = 0 //手术费
  19735. var operationCostSelfTotal float64 = 0 //手术费
  19736. var operationCostPartSelfTotal float64 = 0 //手术费
  19737. var otherCostTotal float64 = 0 //其他费用
  19738. var otherCostSelfTotal float64 = 0 //其他费用
  19739. var otherCostPartSelfTotal float64 = 0 //其他费用
  19740. var materialCostTotal float64 = 0 //材料费
  19741. var materialCostSelfTotal float64 = 0 //材料费
  19742. var materialCostPartSelfTotal float64 = 0 //材料费
  19743. var westernMedicineCostTotal float64 = 0 //西药费
  19744. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19745. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19746. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19747. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19748. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19749. var checkCostTotal float64 = 0 //检查费
  19750. var checkCostSelfTotal float64 = 0 //检查费
  19751. var checkCostPartSelfTotal float64 = 0 //检查费
  19752. var laboratoryCostTotal float64 = 0 //化验费
  19753. var laboratoryCostSelfTotal float64 = 0 //化验费
  19754. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19755. var treatCostTotal float64 = 0 //治疗费用
  19756. var treatCostSelfTotal float64 = 0 //治疗费用
  19757. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19758. decimal.DivisionPrecision = 2
  19759. var bed_fulamt_ownpay_amt float64 = 0
  19760. var operation_fulamt_ownpay_amt float64 = 0
  19761. var other_fulamt_ownpay_amt float64 = 0
  19762. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19763. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19764. var check_fulamt_ownpay_amt float64 = 0
  19765. var material_fulamt_ownpay_amt float64 = 0
  19766. var laboratory_fulamt_ownpay_amt float64 = 0
  19767. var treat_fulamt_ownpay_amt float64 = 0
  19768. var bed_claa_sunmfee float64 = 0
  19769. var bed_clab_amt float64 = 0
  19770. var bed_other_amt float64 = 0
  19771. var operation_claa_sunmfee float64 = 0
  19772. var operation_clab_amt float64 = 0
  19773. var operation_other_amt float64 = 0
  19774. var other_claa_sunmfee float64 = 0
  19775. var other_clab_amt float64 = 0
  19776. var other_other_amt float64 = 0
  19777. var westernMedicine_claa_sunmfee float64 = 0
  19778. var westernMedicine_clab_amt float64 = 0
  19779. var westernMedicine_other_amt float64 = 0
  19780. var chineseTraditional_claa_sunmfee float64 = 0
  19781. var chineseTraditional_clab_amt float64 = 0
  19782. var chineseTraditional_other_amt float64 = 0
  19783. var check_claa_sunmfee float64 = 0
  19784. var check_clab_amt float64 = 0
  19785. var check_other_amt float64 = 0
  19786. var material_claa_sunmfee float64 = 0
  19787. var material_clab_amt float64 = 0
  19788. var material_other_amt float64 = 0
  19789. var laboratory_claa_sunmfee float64 = 0
  19790. var laboratory_clab_amt float64 = 0
  19791. var laboratory_other_amt float64 = 0
  19792. var treat_claa_sunmfee float64 = 0
  19793. var treat_clab_amt float64 = 0
  19794. var treat_other_amt float64 = 0
  19795. for _, item := range order.HisOrderInfo {
  19796. if item.MedChrgitmType == "01" { //床位费
  19797. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19798. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19799. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19800. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19801. if item.ChrgitmLv == "1" {
  19802. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19803. }
  19804. if item.ChrgitmLv == "2" {
  19805. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19806. }
  19807. if item.ChrgitmLv == "3" {
  19808. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19809. }
  19810. }
  19811. if item.MedChrgitmType == "03" { //检查费
  19812. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19813. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19814. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19815. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19816. if item.ChrgitmLv == "1" {
  19817. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19818. }
  19819. if item.ChrgitmLv == "2" {
  19820. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19821. }
  19822. if item.ChrgitmLv == "3" {
  19823. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19824. }
  19825. }
  19826. if item.MedChrgitmType == "04" { //化验费
  19827. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19828. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19829. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19830. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19831. if item.ChrgitmLv == "1" {
  19832. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19833. }
  19834. if item.ChrgitmLv == "2" {
  19835. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19836. }
  19837. if item.ChrgitmLv == "3" {
  19838. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19839. }
  19840. }
  19841. if item.MedChrgitmType == "05" { //治疗费
  19842. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19843. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19844. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19845. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19846. if item.ChrgitmLv == "1" {
  19847. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19848. }
  19849. if item.ChrgitmLv == "2" {
  19850. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19851. }
  19852. if item.ChrgitmLv == "3" {
  19853. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19854. }
  19855. }
  19856. if item.MedChrgitmType == "06" { //手术费
  19857. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19858. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19859. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19860. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19861. if item.ChrgitmLv == "1" {
  19862. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19863. }
  19864. if item.ChrgitmLv == "2" {
  19865. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19866. }
  19867. if item.ChrgitmLv == "3" {
  19868. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19869. }
  19870. }
  19871. if item.MedChrgitmType == "08" { //材料费
  19872. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19873. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19874. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19875. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19876. if item.ChrgitmLv == "1" {
  19877. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19878. }
  19879. if item.ChrgitmLv == "2" {
  19880. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19881. }
  19882. if item.ChrgitmLv == "3" {
  19883. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19884. }
  19885. }
  19886. if item.MedChrgitmType == "09" { //西药费
  19887. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19888. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19889. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19890. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19891. if item.ChrgitmLv == "1" {
  19892. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19893. }
  19894. if item.ChrgitmLv == "2" {
  19895. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19896. }
  19897. if item.ChrgitmLv == "3" {
  19898. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19899. }
  19900. }
  19901. if item.MedChrgitmType == "11" { //中成费
  19902. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19903. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19904. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19905. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19906. if item.ChrgitmLv == "1" {
  19907. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19908. }
  19909. if item.ChrgitmLv == "2" {
  19910. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19911. }
  19912. if item.ChrgitmLv == "3" {
  19913. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19914. }
  19915. }
  19916. if item.MedChrgitmType == "14" { //其他费
  19917. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19918. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19919. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19920. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19921. if item.ChrgitmLv == "1" {
  19922. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19923. }
  19924. if item.ChrgitmLv == "2" {
  19925. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19926. }
  19927. if item.ChrgitmLv == "3" {
  19928. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19929. }
  19930. }
  19931. }
  19932. var iteminfoStructs []service.IteminfoStruct
  19933. if bedCostTotal != 0 {
  19934. iteminfo.MedChrgitm = "01"
  19935. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19936. iteminfo.Amt = bedCostTotal
  19937. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19938. iteminfo.ClabAmt = bed_clab_amt
  19939. iteminfo.OthAmt = bed_other_amt
  19940. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19941. }
  19942. if checkCostTotal != 0 {
  19943. iteminfo.MedChrgitm = "03"
  19944. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19945. iteminfo.Amt = checkCostTotal
  19946. iteminfo.ClaaSumfee = check_claa_sunmfee
  19947. iteminfo.ClabAmt = check_clab_amt
  19948. iteminfo.OthAmt = check_other_amt
  19949. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19950. }
  19951. if laboratoryCostTotal != 0 {
  19952. iteminfo.MedChrgitm = "04"
  19953. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19954. iteminfo.Amt = laboratoryCostTotal
  19955. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19956. iteminfo.ClabAmt = laboratory_clab_amt
  19957. iteminfo.OthAmt = laboratory_other_amt
  19958. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19960. }
  19961. if treatCostTotal != 0 {
  19962. iteminfo.MedChrgitm = "05"
  19963. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19964. iteminfo.Amt = treatCostTotal
  19965. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19966. iteminfo.ClabAmt = treat_clab_amt
  19967. iteminfo.OthAmt = treat_other_amt
  19968. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19969. //(struct4101.IteminfoStruct, iteminfo)
  19970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19971. }
  19972. if operationCostTotal != 0 {
  19973. iteminfo.MedChrgitm = "06"
  19974. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19975. iteminfo.Amt = operationCostTotal
  19976. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19977. iteminfo.ClabAmt = operation_clab_amt
  19978. iteminfo.OthAmt = operation_other_amt
  19979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19981. }
  19982. if materialCostTotal != 0 {
  19983. iteminfo.MedChrgitm = "08"
  19984. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19985. iteminfo.Amt = materialCostTotal
  19986. iteminfo.ClaaSumfee = material_claa_sunmfee
  19987. iteminfo.ClabAmt = material_clab_amt
  19988. iteminfo.OthAmt = material_other_amt
  19989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19991. }
  19992. if westernMedicineCostTotal != 0 {
  19993. iteminfo.MedChrgitm = "09"
  19994. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19995. iteminfo.Amt = westernMedicineCostTotal
  19996. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19997. iteminfo.ClabAmt = westernMedicine_clab_amt
  19998. iteminfo.OthAmt = westernMedicine_other_amt
  19999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20000. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20001. }
  20002. if chineseTraditionalMedicineCostTotal != 0 {
  20003. iteminfo.MedChrgitm = "11"
  20004. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20005. iteminfo.Amt = westernMedicineCostTotal
  20006. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20007. iteminfo.ClabAmt = westernMedicine_clab_amt
  20008. iteminfo.OthAmt = westernMedicine_other_amt
  20009. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20010. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20011. }
  20012. if otherCostTotal != 0 {
  20013. iteminfo.MedChrgitm = "14"
  20014. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20015. iteminfo.Amt = otherCostTotal
  20016. iteminfo.ClaaSumfee = other_claa_sunmfee
  20017. iteminfo.ClabAmt = other_clab_amt
  20018. iteminfo.OthAmt = other_other_amt
  20019. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20020. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20021. }
  20022. struct4101.IteminfoStruct = iteminfoStructs
  20023. struct4101.Ntly = "中国"
  20024. struct4101.AdmCaty = "A03.06"
  20025. struct4101.DoctorName = doctor.UserName
  20026. struct4101.DoctorCode = doctor.DoctorNumber
  20027. var res ResultSeventeen
  20028. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20029. struct4101.BillCode = order.Number
  20030. struct4101.BillNo = order.SetlId
  20031. var resOther ResultSeventeenOther
  20032. var pp models.PublicParams
  20033. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20034. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20035. pp.FixmedinsName = miConfig.OrgName
  20036. pp.FixmedinsCode = miConfig.Code
  20037. pp.RequestUrl = miConfig.Url
  20038. pp.Cainfo = miConfig.Cainfo
  20039. pp.SecretKey = miConfig.SecretKey
  20040. pp.AccessKey = miConfig.AccessKey
  20041. pp.OpterName = curRoles.UserName
  20042. client := &http.Client{}
  20043. var req *http.Request
  20044. data := make(map[string]interface{})
  20045. data["struct4101"] = struct4101
  20046. data["pp"] = pp
  20047. bytesData, _ := json.Marshal(data)
  20048. if miConfig.MdtrtareaAdmvs == "320830" {
  20049. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20050. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20051. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20052. } else {
  20053. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20054. }
  20055. resp, _ := client.Do(req)
  20056. defer resp.Body.Close()
  20057. body, ioErr := ioutil.ReadAll(resp.Body)
  20058. if ioErr != nil {
  20059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20061. return
  20062. }
  20063. var respJSON map[string]interface{}
  20064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20067. return
  20068. }
  20069. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20070. userJSONBytes, _ := json.Marshal(respJSON)
  20071. fmt.Println("log")
  20072. fmt.Println(string(userJSONBytes))
  20073. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20074. utils.ErrorLog("解析失败:%v", err)
  20075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20076. return
  20077. }
  20078. res.InfRefmsgid = resOther.InfRefmsgid
  20079. res.Output = resOther.Output
  20080. res.ErrMsg = resOther.ErrMsg
  20081. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20082. res.Infcode = infocode
  20083. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20084. var pp models.PublicParams
  20085. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20086. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20087. pp.FixmedinsName = miConfig.OrgName
  20088. pp.FixmedinsCode = miConfig.Code
  20089. pp.RequestUrl = miConfig.Url
  20090. pp.Cainfo = miConfig.Cainfo
  20091. pp.SecretKey = miConfig.SecretKey
  20092. pp.AccessKey = miConfig.AccessKey
  20093. pp.OpterName = curRoles.UserName
  20094. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20095. result, _ := service.Jxyb4101(struct4101, pp)
  20096. var dat map[string]interface{}
  20097. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20098. fmt.Println(dat)
  20099. } else {
  20100. fmt.Println(err)
  20101. }
  20102. userJSONBytes, _ := json.Marshal(dat)
  20103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20104. utils.ErrorLog("解析失败:%v", err)
  20105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20106. return
  20107. }
  20108. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20109. var pp models.PublicParams
  20110. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20111. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20112. pp.FixmedinsName = miConfig.OrgName
  20113. pp.FixmedinsCode = miConfig.Code
  20114. pp.RequestUrl = miConfig.Url
  20115. pp.Cainfo = miConfig.Cainfo
  20116. pp.SecretKey = miConfig.SecretKey
  20117. pp.AccessKey = miConfig.AccessKey
  20118. pp.OpterName = curRoles.UserName
  20119. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20120. result, _ := service.Jxyb4101(struct4101, pp)
  20121. var dat map[string]interface{}
  20122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20123. fmt.Println(dat)
  20124. } else {
  20125. fmt.Println(err)
  20126. }
  20127. userJSONBytes, _ := json.Marshal(dat)
  20128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20129. utils.ErrorLog("解析失败:%v", err)
  20130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20131. return
  20132. }
  20133. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20134. var pp models.PublicParams
  20135. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20136. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20137. pp.FixmedinsName = miConfig.OrgName
  20138. pp.FixmedinsCode = miConfig.Code
  20139. pp.RequestUrl = miConfig.Url
  20140. pp.Cainfo = miConfig.Cainfo
  20141. pp.SecretKey = miConfig.SecretKey
  20142. pp.AccessKey = miConfig.AccessKey
  20143. pp.OpterName = curRoles.UserName
  20144. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20145. result, _ := service.Jxyb4101(struct4101, pp)
  20146. var dat map[string]interface{}
  20147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20148. fmt.Println(dat)
  20149. } else {
  20150. fmt.Println(err)
  20151. }
  20152. userJSONBytes, _ := json.Marshal(dat)
  20153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20154. utils.ErrorLog("解析失败:%v", err)
  20155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20156. return
  20157. }
  20158. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20159. var pp models.PublicParams
  20160. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20161. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20162. pp.FixmedinsName = miConfig.OrgName
  20163. pp.FixmedinsCode = miConfig.Code
  20164. pp.RequestUrl = miConfig.Url
  20165. pp.Cainfo = miConfig.Cainfo
  20166. pp.SecretKey = miConfig.SecretKey
  20167. pp.AccessKey = miConfig.AccessKey
  20168. pp.OpterName = curRoles.UserName
  20169. result, _ := service.Hnyb4101(struct4101, pp)
  20170. var dat map[string]interface{}
  20171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20172. fmt.Println(dat)
  20173. } else {
  20174. fmt.Println(err)
  20175. }
  20176. userJSONBytes, _ := json.Marshal(dat)
  20177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20178. utils.ErrorLog("解析失败:%v", err)
  20179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20180. return
  20181. }
  20182. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20183. var resOther ResultSeventeenOther
  20184. var pp models.PublicParams
  20185. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20186. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20187. pp.FixmedinsName = miConfig.OrgName
  20188. pp.FixmedinsCode = miConfig.Code
  20189. pp.RequestUrl = miConfig.Url
  20190. pp.Cainfo = miConfig.Cainfo
  20191. pp.SecretKey = miConfig.SecretKey
  20192. pp.AccessKey = miConfig.AccessKey
  20193. pp.OpterName = curRoles.UserName
  20194. client := &http.Client{}
  20195. var req *http.Request
  20196. data := make(map[string]interface{})
  20197. data["struct4101"] = struct4101
  20198. data["pp"] = pp
  20199. bytesData, _ := json.Marshal(data)
  20200. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20201. resp, _ := client.Do(req)
  20202. defer resp.Body.Close()
  20203. body, ioErr := ioutil.ReadAll(resp.Body)
  20204. if ioErr != nil {
  20205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20207. return
  20208. }
  20209. var respJSON map[string]interface{}
  20210. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20213. return
  20214. }
  20215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20216. userJSONBytes, _ := json.Marshal(respJSON)
  20217. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20218. utils.ErrorLog("解析失败:%v", err)
  20219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20220. return
  20221. }
  20222. res.InfRefmsgid = resOther.InfRefmsgid
  20223. res.Output = resOther.Output
  20224. res.ErrMsg = resOther.ErrMsg
  20225. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20226. res.Infcode = infocode
  20227. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20228. var pp models.PublicParams
  20229. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20230. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20231. pp.FixmedinsName = miConfig.OrgName
  20232. pp.FixmedinsCode = miConfig.Code
  20233. pp.RequestUrl = miConfig.Url
  20234. pp.Cainfo = miConfig.Cainfo
  20235. pp.SecretKey = miConfig.SecretKey
  20236. pp.AccessKey = miConfig.AccessKey
  20237. pp.OpterName = curRoles.UserName
  20238. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20239. fmt.Println(requestLog)
  20240. fmt.Println(errMsgLog)
  20241. saveLog(result, requestLog, "4101a", "上传清单")
  20242. var dat map[string]interface{}
  20243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20244. fmt.Println(dat)
  20245. } else {
  20246. fmt.Println(err)
  20247. }
  20248. userJSONBytes, _ := json.Marshal(dat)
  20249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20250. utils.ErrorLog("解析失败:%v", err)
  20251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20252. return
  20253. }
  20254. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20255. var pp models.PublicParams
  20256. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20257. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20258. pp.FixmedinsName = miConfig.OrgName
  20259. pp.FixmedinsCode = miConfig.Code
  20260. pp.RequestUrl = miConfig.Url
  20261. pp.Cainfo = miConfig.Cainfo
  20262. pp.SecretKey = miConfig.SecretKey
  20263. pp.AccessKey = miConfig.AccessKey
  20264. pp.OpterName = curRoles.UserName
  20265. client := &http.Client{}
  20266. var req *http.Request
  20267. data := make(map[string]interface{})
  20268. data["struct4101"] = struct4101
  20269. data["pp"] = pp
  20270. bytesData, _ := json.Marshal(data)
  20271. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20272. resp, _ := client.Do(req)
  20273. defer resp.Body.Close()
  20274. body, ioErr := ioutil.ReadAll(resp.Body)
  20275. if ioErr != nil {
  20276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20278. return
  20279. }
  20280. var respJSON map[string]interface{}
  20281. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20284. return
  20285. }
  20286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20287. userJSONBytes, _ := json.Marshal(respJSON)
  20288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20289. utils.ErrorLog("解析失败:%v", err)
  20290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20291. return
  20292. }
  20293. } else {
  20294. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20295. var dat map[string]interface{}
  20296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20297. fmt.Println(dat)
  20298. } else {
  20299. fmt.Println(err)
  20300. }
  20301. userJSONBytes, _ := json.Marshal(dat)
  20302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20303. utils.ErrorLog("解析失败:%v", err)
  20304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20305. return
  20306. }
  20307. }
  20308. if res.Infcode != 0 {
  20309. errlog := &models.HisOrderError{
  20310. UserOrgId: order.UserOrgId,
  20311. Ctime: time.Now().Unix(),
  20312. Mtime: time.Now().Unix(),
  20313. ErrMsg: res.ErrMsg + "解析失败",
  20314. Status: 1,
  20315. PatientId: order.ID,
  20316. Stage: 10485,
  20317. }
  20318. service.CreateErrMsgLog(errlog)
  20319. continue
  20320. //c.ServeSuccessJSON(map[string]interface{}{
  20321. // "failed_code": -10,
  20322. // "msg": res.ErrMsg,
  20323. //})
  20324. } else {
  20325. //order.FaPiaoNumber = zero
  20326. //order.FaPiaoCode = last_order.FaPiaoCode
  20327. //service.UpdateOrder(order)
  20328. hisFundSettleListResult := &models.HisFundSettleListResult{
  20329. Number: res.Output.SetlListId,
  20330. Status: 1,
  20331. Ctime: time.Now().Unix(),
  20332. Mtime: time.Now().Unix(),
  20333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20334. IsUpload: 1,
  20335. OrderId: order.ID,
  20336. }
  20337. service.CreateUploadRecord(hisFundSettleListResult)
  20338. continue
  20339. }
  20340. }
  20341. }
  20342. func (c *HisApiController) GetSettleList() {
  20343. order_id, _ := c.GetInt64("order_id")
  20344. admin_user_id, _ := c.GetInt64("admin_user_id")
  20345. order, _ := service.GetHisOrderByIDTwo(order_id)
  20346. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20347. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20348. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20349. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20350. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20351. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20352. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20353. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20354. if order.ID == 0 {
  20355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20356. return
  20357. }
  20358. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20359. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20360. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20361. //fmt.Println(count)
  20362. //var zero string
  20363. //number := count + 1
  20364. //if number >= 1000 {
  20365. // zero = "0000" + strconv.FormatInt(number, 10)
  20366. //} else if number >= 10000 {
  20367. // zero = "000" + strconv.FormatInt(number, 10)
  20368. //} else if number >= 100000 {
  20369. // zero = "00" + strconv.FormatInt(number, 10)
  20370. //} else if number >= 1000000 {
  20371. // zero = "0" + strconv.FormatInt(number, 10)
  20372. //} else {
  20373. // zero = strconv.FormatInt(number, 10)
  20374. //}
  20375. //fmt.Println(zero)
  20376. struct4101 := service.Struct4101{
  20377. PsnNo: order.PsnNo,
  20378. MdtrtId: order.MdtrtId,
  20379. SetlId: order.SetlId,
  20380. PsnName: order.PsnName,
  20381. Gend: order.Gend,
  20382. Brdy: his.Brdy,
  20383. Age: his.Age,
  20384. Naty: order.Naty,
  20385. PatnCertType: "01",
  20386. Certno: order.Certno,
  20387. Prfs: "90",
  20388. ConerName: roles[0].UserName,
  20389. PatnRlts: "99",
  20390. ConerAddr: miConfig.OrgName,
  20391. ConerTel: admin.Mobile,
  20392. HiType: order.Insutype,
  20393. Insuplc: miConfig.InsuplcAdmdvs,
  20394. MaindiagFlag: "1",
  20395. BillCode: order.SetlId,
  20396. BillNo: order.SetlId,
  20397. BizSn: order.Number,
  20398. PsnSelfPay: order.PsnPartAmt,
  20399. PsnOwnPay: order.PsnPartAmt,
  20400. AcctPay: order.AcctPay,
  20401. PsnCashpay: order.PsnCashPay,
  20402. HiPaymtd: "1",
  20403. Hsorg: miConfig.InsuplcAdmdvs,
  20404. HsorgOpter: miConfig.InsuplcAdmdvs,
  20405. MedinsFillPsn: curRoles.UserName,
  20406. MedinsFillDept: miConfig.OrgName,
  20407. IptMedType: "2",
  20408. }
  20409. struct4101.SetlBegnDate = order.SetlTime
  20410. struct4101.SetlEndDate = order.SetlTime
  20411. time_arr := strings.Split(order.SetlTime, " ")
  20412. struct4101.AdmTime = time_arr[0]
  20413. struct4101.AdmEndTime = time_arr[0]
  20414. //
  20415. //var rf []CustomFundPay
  20416. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20417. //
  20418. //var tempFunPays []service.CustomStruct
  20419. //for _, item := range rf {
  20420. // var tempFunPay service.CustomStruct
  20421. // tempFunPay.FundPayamt = item.FundPayamt
  20422. // tempFunPay.FundPayType = item.FundPayType
  20423. // tempFunPays = append(tempFunPays, tempFunPay)
  20424. //}
  20425. //struct4101.CustomStruct = tempFunPays
  20426. var tempDiaginfos []service.DiaginfoStructTwo
  20427. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20428. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20429. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20430. var config []*models.HisXtDiagnoseConfig
  20431. for _, item := range diagnosis_ids {
  20432. id, _ := strconv.ParseInt(item, 10, 64)
  20433. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20434. config = append(config, &diagnosisConfig)
  20435. }
  20436. if miConfig.Code == "H15049901371" {
  20437. //for _, item := range config {
  20438. // if item.ID == 138 {
  20439. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20440. var tempDiaginfo service.DiaginfoStructTwo
  20441. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20442. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20443. tempDiaginfo.DiagType = "1"
  20444. tempDiaginfo.MaindiagFlag = "1"
  20445. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20446. //}
  20447. //}
  20448. for _, item := range config {
  20449. if item.ID != 138 {
  20450. var tempDiaginfo service.DiaginfoStructTwo
  20451. tempDiaginfo.DiagCode = item.CountryCode
  20452. tempDiaginfo.DiagName = item.CountryContentName
  20453. tempDiaginfo.DiagType = "1"
  20454. tempDiaginfo.MaindiagFlag = "0"
  20455. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20456. }
  20457. }
  20458. } else {
  20459. for index, item := range config {
  20460. if index == 0 {
  20461. var tempDiaginfo service.DiaginfoStructTwo
  20462. tempDiaginfo.DiagCode = item.CountryCode
  20463. tempDiaginfo.DiagName = item.CountryContentName
  20464. tempDiaginfo.DiagType = "1"
  20465. tempDiaginfo.MaindiagFlag = "1"
  20466. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20467. } else {
  20468. var tempDiaginfo service.DiaginfoStructTwo
  20469. tempDiaginfo.DiagCode = item.CountryCode
  20470. tempDiaginfo.DiagName = item.CountryContentName
  20471. tempDiaginfo.DiagType = "1"
  20472. tempDiaginfo.MaindiagFlag = "0"
  20473. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20474. }
  20475. }
  20476. }
  20477. struct4101.Diseinfo = tempDiaginfos
  20478. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20479. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20480. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20481. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20482. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20483. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20484. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20485. var iteminfo service.IteminfoStruct
  20486. var bedCostTotal float64 = 0 //床位总费
  20487. var bedCostSelfTotal float64 = 0 //床位自费
  20488. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20489. var operationCostTotal float64 = 0 //手术费
  20490. var operationCostSelfTotal float64 = 0 //手术费
  20491. var operationCostPartSelfTotal float64 = 0 //手术费
  20492. var otherCostTotal float64 = 0 //其他费用
  20493. var otherCostSelfTotal float64 = 0 //其他费用
  20494. var otherCostPartSelfTotal float64 = 0 //其他费用
  20495. var materialCostTotal float64 = 0 //材料费
  20496. var materialCostSelfTotal float64 = 0 //材料费
  20497. var materialCostPartSelfTotal float64 = 0 //材料费
  20498. var westernMedicineCostTotal float64 = 0 //西药费
  20499. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20500. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20501. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20502. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20503. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20504. var checkCostTotal float64 = 0 //检查费
  20505. var checkCostSelfTotal float64 = 0 //检查费
  20506. var checkCostPartSelfTotal float64 = 0 //检查费
  20507. var laboratoryCostTotal float64 = 0 //化验费
  20508. var laboratoryCostSelfTotal float64 = 0 //化验费
  20509. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20510. var treatCostTotal float64 = 0 //治疗费用
  20511. var treatCostSelfTotal float64 = 0 //治疗费用
  20512. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20513. decimal.DivisionPrecision = 2
  20514. var bed_fulamt_ownpay_amt float64 = 0
  20515. var operation_fulamt_ownpay_amt float64 = 0
  20516. var other_fulamt_ownpay_amt float64 = 0
  20517. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20518. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20519. var check_fulamt_ownpay_amt float64 = 0
  20520. var material_fulamt_ownpay_amt float64 = 0
  20521. var laboratory_fulamt_ownpay_amt float64 = 0
  20522. var treat_fulamt_ownpay_amt float64 = 0
  20523. var bed_claa_sunmfee float64 = 0
  20524. var bed_clab_amt float64 = 0
  20525. var bed_other_amt float64 = 0
  20526. var operation_claa_sunmfee float64 = 0
  20527. var operation_clab_amt float64 = 0
  20528. var operation_other_amt float64 = 0
  20529. var other_claa_sunmfee float64 = 0
  20530. var other_clab_amt float64 = 0
  20531. var other_other_amt float64 = 0
  20532. var westernMedicine_claa_sunmfee float64 = 0
  20533. var westernMedicine_clab_amt float64 = 0
  20534. var westernMedicine_other_amt float64 = 0
  20535. var chineseTraditional_claa_sunmfee float64 = 0
  20536. var chineseTraditional_clab_amt float64 = 0
  20537. var chineseTraditional_other_amt float64 = 0
  20538. var check_claa_sunmfee float64 = 0
  20539. var check_clab_amt float64 = 0
  20540. var check_other_amt float64 = 0
  20541. var material_claa_sunmfee float64 = 0
  20542. var material_clab_amt float64 = 0
  20543. var material_other_amt float64 = 0
  20544. var laboratory_claa_sunmfee float64 = 0
  20545. var laboratory_clab_amt float64 = 0
  20546. var laboratory_other_amt float64 = 0
  20547. var treat_claa_sunmfee float64 = 0
  20548. var treat_clab_amt float64 = 0
  20549. var treat_other_amt float64 = 0
  20550. for _, item := range order.HisOrderInfo {
  20551. if item.MedChrgitmType == "01" { //床位费
  20552. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20553. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20554. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20555. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20556. if item.ChrgitmLv == "1" {
  20557. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20558. }
  20559. if item.ChrgitmLv == "2" {
  20560. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20561. }
  20562. if item.ChrgitmLv == "3" {
  20563. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20564. }
  20565. }
  20566. if item.MedChrgitmType == "03" { //检查费
  20567. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20568. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20569. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20570. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20571. if item.ChrgitmLv == "1" {
  20572. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20573. }
  20574. if item.ChrgitmLv == "2" {
  20575. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20576. }
  20577. if item.ChrgitmLv == "3" {
  20578. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20579. }
  20580. }
  20581. if item.MedChrgitmType == "04" { //化验费
  20582. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20583. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20584. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20585. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20586. if item.ChrgitmLv == "1" {
  20587. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20588. }
  20589. if item.ChrgitmLv == "2" {
  20590. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20591. }
  20592. if item.ChrgitmLv == "3" {
  20593. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20594. }
  20595. }
  20596. if item.MedChrgitmType == "05" { //治疗费
  20597. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20598. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20599. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20600. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20601. if item.ChrgitmLv == "1" {
  20602. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20603. }
  20604. if item.ChrgitmLv == "2" {
  20605. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20606. }
  20607. if item.ChrgitmLv == "3" {
  20608. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20609. }
  20610. }
  20611. if item.MedChrgitmType == "06" { //手术费
  20612. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20613. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20614. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20615. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20616. if item.ChrgitmLv == "1" {
  20617. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20618. }
  20619. if item.ChrgitmLv == "2" {
  20620. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20621. }
  20622. if item.ChrgitmLv == "3" {
  20623. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20624. }
  20625. }
  20626. if item.MedChrgitmType == "08" { //材料费
  20627. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20628. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20629. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20630. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20631. if item.ChrgitmLv == "1" {
  20632. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20633. }
  20634. if item.ChrgitmLv == "2" {
  20635. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20636. }
  20637. if item.ChrgitmLv == "3" {
  20638. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20639. }
  20640. }
  20641. if item.MedChrgitmType == "09" { //西药费
  20642. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20643. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20644. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20645. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20646. if item.ChrgitmLv == "1" {
  20647. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20648. }
  20649. if item.ChrgitmLv == "2" {
  20650. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20651. }
  20652. if item.ChrgitmLv == "3" {
  20653. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20654. }
  20655. }
  20656. if item.MedChrgitmType == "11" { //中成费
  20657. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20658. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20659. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20660. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20661. if item.ChrgitmLv == "1" {
  20662. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20663. }
  20664. if item.ChrgitmLv == "2" {
  20665. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20666. }
  20667. if item.ChrgitmLv == "3" {
  20668. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20669. }
  20670. }
  20671. if item.MedChrgitmType == "14" { //其他费
  20672. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20673. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20674. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20675. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20676. if item.ChrgitmLv == "1" {
  20677. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20678. }
  20679. if item.ChrgitmLv == "2" {
  20680. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20681. }
  20682. if item.ChrgitmLv == "3" {
  20683. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20684. }
  20685. }
  20686. }
  20687. var iteminfoStructs []service.IteminfoStruct
  20688. if bedCostTotal != 0 {
  20689. iteminfo.MedChrgitm = "01"
  20690. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20691. iteminfo.Amt = bedCostTotal
  20692. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20693. iteminfo.ClabAmt = bed_clab_amt
  20694. iteminfo.OthAmt = bed_other_amt
  20695. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20696. }
  20697. if checkCostTotal != 0 {
  20698. iteminfo.MedChrgitm = "03"
  20699. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20700. iteminfo.Amt = checkCostTotal
  20701. iteminfo.ClaaSumfee = check_claa_sunmfee
  20702. iteminfo.ClabAmt = check_clab_amt
  20703. iteminfo.OthAmt = check_other_amt
  20704. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20705. }
  20706. if laboratoryCostTotal != 0 {
  20707. iteminfo.MedChrgitm = "04"
  20708. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20709. iteminfo.Amt = laboratoryCostTotal
  20710. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20711. iteminfo.ClabAmt = laboratory_clab_amt
  20712. iteminfo.OthAmt = laboratory_other_amt
  20713. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20714. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20715. }
  20716. if treatCostTotal != 0 {
  20717. iteminfo.MedChrgitm = "05"
  20718. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20719. iteminfo.Amt = treatCostTotal
  20720. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20721. iteminfo.ClabAmt = treat_clab_amt
  20722. iteminfo.OthAmt = treat_other_amt
  20723. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20724. //(struct4101.IteminfoStruct, iteminfo)
  20725. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20726. }
  20727. if operationCostTotal != 0 {
  20728. iteminfo.MedChrgitm = "06"
  20729. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20730. iteminfo.Amt = operationCostTotal
  20731. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20732. iteminfo.ClabAmt = operation_clab_amt
  20733. iteminfo.OthAmt = operation_other_amt
  20734. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20735. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20736. }
  20737. if materialCostTotal != 0 {
  20738. iteminfo.MedChrgitm = "08"
  20739. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20740. iteminfo.Amt = materialCostTotal
  20741. iteminfo.ClaaSumfee = material_claa_sunmfee
  20742. iteminfo.ClabAmt = material_clab_amt
  20743. iteminfo.OthAmt = material_other_amt
  20744. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20745. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20746. }
  20747. if westernMedicineCostTotal != 0 {
  20748. iteminfo.MedChrgitm = "09"
  20749. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20750. iteminfo.Amt = westernMedicineCostTotal
  20751. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20752. iteminfo.ClabAmt = westernMedicine_clab_amt
  20753. iteminfo.OthAmt = westernMedicine_other_amt
  20754. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20755. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20756. }
  20757. if chineseTraditionalMedicineCostTotal != 0 {
  20758. iteminfo.MedChrgitm = "11"
  20759. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20760. iteminfo.Amt = westernMedicineCostTotal
  20761. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20762. iteminfo.ClabAmt = westernMedicine_clab_amt
  20763. iteminfo.OthAmt = westernMedicine_other_amt
  20764. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20766. }
  20767. if otherCostTotal != 0 {
  20768. iteminfo.MedChrgitm = "14"
  20769. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20770. iteminfo.Amt = otherCostTotal
  20771. iteminfo.ClaaSumfee = other_claa_sunmfee
  20772. iteminfo.ClabAmt = other_clab_amt
  20773. iteminfo.OthAmt = other_other_amt
  20774. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20775. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20776. }
  20777. struct4101.IteminfoStruct = iteminfoStructs
  20778. struct4101.Ntly = "中国"
  20779. struct4101.AdmCaty = "A03.06"
  20780. struct4101.DoctorName = doctor.UserName
  20781. struct4101.DoctorCode = doctor.DoctorNumber
  20782. var res ResultSeventeen
  20783. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20784. struct4101.BillCode = order.Number
  20785. struct4101.BillNo = order.SetlId
  20786. var resOther ResultSeventeenOther
  20787. var pp models.PublicParams
  20788. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20789. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20790. pp.FixmedinsName = miConfig.OrgName
  20791. pp.FixmedinsCode = miConfig.Code
  20792. pp.RequestUrl = miConfig.Url
  20793. pp.Cainfo = miConfig.Cainfo
  20794. pp.SecretKey = miConfig.SecretKey
  20795. pp.AccessKey = miConfig.AccessKey
  20796. pp.OpterName = curRoles.UserName
  20797. client := &http.Client{}
  20798. var req *http.Request
  20799. data := make(map[string]interface{})
  20800. data["struct4101"] = struct4101
  20801. data["pp"] = pp
  20802. bytesData, _ := json.Marshal(data)
  20803. if miConfig.MdtrtareaAdmvs == "320830" {
  20804. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20805. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20806. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20807. } else {
  20808. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20809. }
  20810. resp, _ := client.Do(req)
  20811. defer resp.Body.Close()
  20812. body, ioErr := ioutil.ReadAll(resp.Body)
  20813. if ioErr != nil {
  20814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20816. return
  20817. }
  20818. var respJSON map[string]interface{}
  20819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20822. return
  20823. }
  20824. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20825. userJSONBytes, _ := json.Marshal(respJSON)
  20826. fmt.Println("log")
  20827. fmt.Println(string(userJSONBytes))
  20828. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20829. utils.ErrorLog("解析失败:%v", err)
  20830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20831. return
  20832. }
  20833. res.InfRefmsgid = resOther.InfRefmsgid
  20834. res.Output = resOther.Output
  20835. res.ErrMsg = resOther.ErrMsg
  20836. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20837. res.Infcode = infocode
  20838. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20839. var pp models.PublicParams
  20840. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20841. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20842. pp.FixmedinsName = miConfig.OrgName
  20843. pp.FixmedinsCode = miConfig.Code
  20844. pp.RequestUrl = miConfig.Url
  20845. pp.Cainfo = miConfig.Cainfo
  20846. pp.SecretKey = miConfig.SecretKey
  20847. pp.AccessKey = miConfig.AccessKey
  20848. pp.OpterName = curRoles.UserName
  20849. result, _ := service.Jxyb4101(struct4101, pp)
  20850. var dat map[string]interface{}
  20851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20852. fmt.Println(dat)
  20853. } else {
  20854. fmt.Println(err)
  20855. }
  20856. userJSONBytes, _ := json.Marshal(dat)
  20857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20858. utils.ErrorLog("解析失败:%v", err)
  20859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20860. return
  20861. }
  20862. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20863. var pp models.PublicParams
  20864. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20865. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20866. pp.FixmedinsName = miConfig.OrgName
  20867. pp.FixmedinsCode = miConfig.Code
  20868. pp.RequestUrl = miConfig.Url
  20869. pp.Cainfo = miConfig.Cainfo
  20870. pp.SecretKey = miConfig.SecretKey
  20871. pp.AccessKey = miConfig.AccessKey
  20872. pp.OpterName = curRoles.UserName
  20873. result, _ := service.Jxyb4101(struct4101, pp)
  20874. var dat map[string]interface{}
  20875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20876. fmt.Println(dat)
  20877. } else {
  20878. fmt.Println(err)
  20879. }
  20880. userJSONBytes, _ := json.Marshal(dat)
  20881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20882. utils.ErrorLog("解析失败:%v", err)
  20883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20884. return
  20885. }
  20886. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20887. var pp models.PublicParams
  20888. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20889. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20890. pp.FixmedinsName = miConfig.OrgName
  20891. pp.FixmedinsCode = miConfig.Code
  20892. pp.RequestUrl = miConfig.Url
  20893. pp.Cainfo = miConfig.Cainfo
  20894. pp.SecretKey = miConfig.SecretKey
  20895. pp.AccessKey = miConfig.AccessKey
  20896. pp.OpterName = curRoles.UserName
  20897. result, _ := service.Jxyb4101(struct4101, pp)
  20898. var dat map[string]interface{}
  20899. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20900. fmt.Println(dat)
  20901. } else {
  20902. fmt.Println(err)
  20903. }
  20904. userJSONBytes, _ := json.Marshal(dat)
  20905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20906. utils.ErrorLog("解析失败:%v", err)
  20907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20908. return
  20909. }
  20910. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20911. var pp models.PublicParams
  20912. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20913. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20914. pp.FixmedinsName = miConfig.OrgName
  20915. pp.FixmedinsCode = miConfig.Code
  20916. pp.RequestUrl = miConfig.Url
  20917. pp.Cainfo = miConfig.Cainfo
  20918. pp.SecretKey = miConfig.SecretKey
  20919. pp.AccessKey = miConfig.AccessKey
  20920. pp.OpterName = curRoles.UserName
  20921. result, _ := service.Hnyb4101(struct4101, pp)
  20922. var dat map[string]interface{}
  20923. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20924. fmt.Println(dat)
  20925. } else {
  20926. fmt.Println(err)
  20927. }
  20928. userJSONBytes, _ := json.Marshal(dat)
  20929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20930. utils.ErrorLog("解析失败:%v", err)
  20931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20932. return
  20933. }
  20934. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20935. var resOther ResultSeventeenOther
  20936. var pp models.PublicParams
  20937. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20938. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20939. pp.FixmedinsName = miConfig.OrgName
  20940. pp.FixmedinsCode = miConfig.Code
  20941. pp.RequestUrl = miConfig.Url
  20942. pp.Cainfo = miConfig.Cainfo
  20943. pp.SecretKey = miConfig.SecretKey
  20944. pp.AccessKey = miConfig.AccessKey
  20945. pp.OpterName = curRoles.UserName
  20946. client := &http.Client{}
  20947. var req *http.Request
  20948. data := make(map[string]interface{})
  20949. data["struct4101"] = struct4101
  20950. data["pp"] = pp
  20951. bytesData, _ := json.Marshal(data)
  20952. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20953. resp, _ := client.Do(req)
  20954. defer resp.Body.Close()
  20955. body, ioErr := ioutil.ReadAll(resp.Body)
  20956. if ioErr != nil {
  20957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20959. return
  20960. }
  20961. var respJSON map[string]interface{}
  20962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20965. return
  20966. }
  20967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20968. userJSONBytes, _ := json.Marshal(respJSON)
  20969. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20970. utils.ErrorLog("解析失败:%v", err)
  20971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20972. return
  20973. }
  20974. res.InfRefmsgid = resOther.InfRefmsgid
  20975. res.Output = resOther.Output
  20976. res.ErrMsg = resOther.ErrMsg
  20977. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20978. res.Infcode = infocode
  20979. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20980. var pp models.PublicParams
  20981. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20982. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20983. pp.FixmedinsName = miConfig.OrgName
  20984. pp.FixmedinsCode = miConfig.Code
  20985. pp.RequestUrl = miConfig.Url
  20986. pp.Cainfo = miConfig.Cainfo
  20987. pp.SecretKey = miConfig.SecretKey
  20988. pp.AccessKey = miConfig.AccessKey
  20989. pp.OpterName = curRoles.UserName
  20990. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20991. fmt.Println(requestLog)
  20992. fmt.Println(errMsgLog)
  20993. saveLog(result, requestLog, "4101a", "上传清单")
  20994. var dat map[string]interface{}
  20995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20996. fmt.Println(dat)
  20997. } else {
  20998. fmt.Println(err)
  20999. }
  21000. userJSONBytes, _ := json.Marshal(dat)
  21001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21002. utils.ErrorLog("解析失败:%v", err)
  21003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21004. return
  21005. }
  21006. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21007. var pp models.PublicParams
  21008. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21009. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21010. pp.FixmedinsName = miConfig.OrgName
  21011. pp.FixmedinsCode = miConfig.Code
  21012. pp.RequestUrl = miConfig.Url
  21013. pp.Cainfo = miConfig.Cainfo
  21014. pp.SecretKey = miConfig.SecretKey
  21015. pp.AccessKey = miConfig.AccessKey
  21016. pp.OpterName = curRoles.UserName
  21017. client := &http.Client{}
  21018. var req *http.Request
  21019. data := make(map[string]interface{})
  21020. data["struct4101"] = struct4101
  21021. data["pp"] = pp
  21022. bytesData, _ := json.Marshal(data)
  21023. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  21024. resp, _ := client.Do(req)
  21025. defer resp.Body.Close()
  21026. body, ioErr := ioutil.ReadAll(resp.Body)
  21027. if ioErr != nil {
  21028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21030. return
  21031. }
  21032. var respJSON map[string]interface{}
  21033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21036. return
  21037. }
  21038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21039. userJSONBytes, _ := json.Marshal(respJSON)
  21040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21041. utils.ErrorLog("解析失败:%v", err)
  21042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21043. return
  21044. }
  21045. } else {
  21046. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21047. var dat map[string]interface{}
  21048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21049. fmt.Println(dat)
  21050. } else {
  21051. fmt.Println(err)
  21052. }
  21053. userJSONBytes, _ := json.Marshal(dat)
  21054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21055. utils.ErrorLog("解析失败:%v", err)
  21056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21057. return
  21058. }
  21059. }
  21060. if res.Infcode != 0 {
  21061. c.ServeSuccessJSON(map[string]interface{}{
  21062. "failed_code": -10,
  21063. "msg": res.ErrMsg,
  21064. })
  21065. return
  21066. } else {
  21067. //order.FaPiaoNumber = zero
  21068. //order.FaPiaoCode = last_order.FaPiaoCode
  21069. //service.UpdateOrder(order)
  21070. hisFundSettleListResult := &models.HisFundSettleListResult{
  21071. Number: res.Output.SetlListId,
  21072. Status: 1,
  21073. Ctime: time.Now().Unix(),
  21074. Mtime: time.Now().Unix(),
  21075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21076. IsUpload: 1,
  21077. OrderId: order_id,
  21078. }
  21079. service.CreateUploadRecord(hisFundSettleListResult)
  21080. c.ServeSuccessJSON(map[string]interface{}{
  21081. "msg": "上传成功",
  21082. "result": hisFundSettleListResult,
  21083. })
  21084. return
  21085. }
  21086. }
  21087. func (c *HisApiController) GetSettleListHospital() {
  21088. order_id, _ := c.GetInt64("order_id")
  21089. admin_user_id, _ := c.GetInt64("admin_user_id")
  21090. order, _ := service.GetHisOrderByIDTwo(order_id)
  21091. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21092. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  21093. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21094. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  21095. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21097. if order.ID == 0 {
  21098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21099. return
  21100. }
  21101. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  21102. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  21103. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  21104. fmt.Println(count)
  21105. var zero string
  21106. number := count + 1
  21107. if number >= 1000 {
  21108. zero = "0000" + strconv.FormatInt(number, 10)
  21109. } else if number >= 10000 {
  21110. zero = "000" + strconv.FormatInt(number, 10)
  21111. } else if number >= 100000 {
  21112. zero = "00" + strconv.FormatInt(number, 10)
  21113. } else if number >= 1000000 {
  21114. zero = "0" + strconv.FormatInt(number, 10)
  21115. } else {
  21116. zero = strconv.FormatInt(number, 10)
  21117. }
  21118. fmt.Println(zero)
  21119. struct4101 := service.Struct4101{
  21120. PsnNo: order.PsnNo,
  21121. MdtrtId: order.MdtrtId,
  21122. SetlId: order.SetlId,
  21123. PsnName: order.PsnName,
  21124. Gend: order.Gend,
  21125. Brdy: his.Brdy,
  21126. Age: int64(order.Age),
  21127. Naty: order.Naty,
  21128. PatnCertType: "01",
  21129. Certno: order.Certno,
  21130. Prfs: "90",
  21131. ConerName: roles[0].UserName,
  21132. PatnRlts: "99",
  21133. ConerAddr: miConfig.OrgName,
  21134. ConerTel: admin.Mobile,
  21135. HiType: order.Insutype,
  21136. Insuplc: miConfig.InsuplcAdmdvs,
  21137. MaindiagFlag: "1",
  21138. BillCode: order.SetlId,
  21139. BillNo: order.SetlId,
  21140. BizSn: order.Number,
  21141. PsnSelfPay: order.PsnPartAmt,
  21142. PsnOwnPay: order.PsnPartAmt,
  21143. AcctPay: order.AcctPay,
  21144. PsnCashpay: order.PsnCashPay,
  21145. HiPaymtd: "1",
  21146. Hsorg: miConfig.InsuplcAdmdvs,
  21147. HsorgOpter: miConfig.InsuplcAdmdvs,
  21148. MedinsFillPsn: curRoles.UserName,
  21149. MedinsFillDept: depart.Name,
  21150. IptMedType: "2",
  21151. AdmTime: his.InHosptialTime,
  21152. AdmEndTime: his.OutHosptialTime,
  21153. }
  21154. struct4101.SetlBegnDate = order.SetlTime
  21155. struct4101.SetlEndDate = order.SetlTime
  21156. //var rf []CustomFundPay
  21157. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21158. //
  21159. //var tempFunPays []service.CustomStruct
  21160. //for _, item := range rf {
  21161. // var tempFunPay service.CustomStruct
  21162. // tempFunPay.FundPayamt = item.FundPayamt
  21163. // tempFunPay.FundPayType = item.FundPayType
  21164. // tempFunPays = append(tempFunPays, tempFunPay)
  21165. //}
  21166. //struct4101.CustomStruct = tempFunPays
  21167. var tempDiaginfos []service.DiaginfoStructTwo
  21168. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21169. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21170. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21171. //for _, item := range infos {
  21172. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21173. //}
  21174. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21175. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21176. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21177. fmt.Println(diagnosis_ids_arr)
  21178. if order.UserOrgId == 10210 {
  21179. var diagnosis_ids_arr_two []int64
  21180. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21181. var config []*models.HisXtDiagnoseConfig
  21182. for _, id := range diagnosis_ids_arr_two {
  21183. //id, _ := strconv.ParseInt(item, 10, 64)
  21184. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21185. if diagnosisConfig.ID > 0 {
  21186. config = append(config, &diagnosisConfig)
  21187. }
  21188. }
  21189. for index, item := range config {
  21190. if item.ID > 0 {
  21191. if index == 0 {
  21192. var tempDiaginfo service.DiaginfoStructTwo
  21193. tempDiaginfo.DiagCode = item.CountryCode
  21194. tempDiaginfo.DiagName = item.CountryContentName
  21195. tempDiaginfo.DiagType = "1"
  21196. tempDiaginfo.MaindiagFlag = "1"
  21197. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21198. } else {
  21199. var tempDiaginfo service.DiaginfoStructTwo
  21200. tempDiaginfo.DiagCode = item.CountryCode
  21201. tempDiaginfo.DiagName = item.CountryContentName
  21202. tempDiaginfo.DiagType = "1"
  21203. tempDiaginfo.MaindiagFlag = "0"
  21204. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21205. }
  21206. }
  21207. }
  21208. struct4101.Diseinfo = tempDiaginfos
  21209. } else {
  21210. var config []*models.HisXtDiagnoseConfig
  21211. for _, item := range diagnosis_ids_arr {
  21212. id, _ := strconv.ParseInt(item, 10, 64)
  21213. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21214. if diagnosisConfig.ID > 0 {
  21215. config = append(config, &diagnosisConfig)
  21216. }
  21217. }
  21218. for index, item := range config {
  21219. if item.ID > 0 {
  21220. if index == 0 {
  21221. var tempDiaginfo service.DiaginfoStructTwo
  21222. tempDiaginfo.DiagCode = item.CountryCode
  21223. tempDiaginfo.DiagName = item.CountryContentName
  21224. tempDiaginfo.DiagType = "1"
  21225. tempDiaginfo.MaindiagFlag = "1"
  21226. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21227. } else {
  21228. var tempDiaginfo service.DiaginfoStructTwo
  21229. tempDiaginfo.DiagCode = item.CountryCode
  21230. tempDiaginfo.DiagName = item.CountryContentName
  21231. tempDiaginfo.DiagType = "1"
  21232. tempDiaginfo.MaindiagFlag = "0"
  21233. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21234. }
  21235. }
  21236. }
  21237. struct4101.Diseinfo = tempDiaginfos
  21238. }
  21239. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21240. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21241. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21242. tempOpspdiseinfo2.OprnOprtCode = ""
  21243. tempOpspdiseinfo2.OprnOprtName = ""
  21244. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21245. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21246. var iteminfo service.IteminfoStruct
  21247. var bedCostTotal float64 = 0 //床位总费
  21248. var bedCostSelfTotal float64 = 0 //床位自费
  21249. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21250. var operationCostTotal float64 = 0 //手术费
  21251. var operationCostSelfTotal float64 = 0 //手术费
  21252. var operationCostPartSelfTotal float64 = 0 //手术费
  21253. var otherCostTotal float64 = 0 //其他费用
  21254. var otherCostSelfTotal float64 = 0 //其他费用
  21255. var otherCostPartSelfTotal float64 = 0 //其他费用
  21256. var materialCostTotal float64 = 0 //材料费
  21257. var materialCostSelfTotal float64 = 0 //材料费
  21258. var materialCostPartSelfTotal float64 = 0 //材料费
  21259. var westernMedicineCostTotal float64 = 0 //西药费
  21260. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21261. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21262. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21263. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21264. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21265. var checkCostTotal float64 = 0 //检查费
  21266. var checkCostSelfTotal float64 = 0 //检查费
  21267. var checkCostPartSelfTotal float64 = 0 //检查费
  21268. var laboratoryCostTotal float64 = 0 //化验费
  21269. var laboratoryCostSelfTotal float64 = 0 //化验费
  21270. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21271. var treatCostTotal float64 = 0 //治疗费用
  21272. var treatCostSelfTotal float64 = 0 //治疗费用
  21273. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21274. decimal.DivisionPrecision = 2
  21275. var bed_fulamt_ownpay_amt float64 = 0
  21276. var operation_fulamt_ownpay_amt float64 = 0
  21277. var other_fulamt_ownpay_amt float64 = 0
  21278. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21279. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21280. var check_fulamt_ownpay_amt float64 = 0
  21281. var material_fulamt_ownpay_amt float64 = 0
  21282. var laboratory_fulamt_ownpay_amt float64 = 0
  21283. var treat_fulamt_ownpay_amt float64 = 0
  21284. var bed_claa_sunmfee float64 = 0
  21285. var bed_clab_amt float64 = 0
  21286. var bed_other_amt float64 = 0
  21287. var operation_claa_sunmfee float64 = 0
  21288. var operation_clab_amt float64 = 0
  21289. var operation_other_amt float64 = 0
  21290. var other_claa_sunmfee float64 = 0
  21291. var other_clab_amt float64 = 0
  21292. var other_other_amt float64 = 0
  21293. var westernMedicine_claa_sunmfee float64 = 0
  21294. var westernMedicine_clab_amt float64 = 0
  21295. var westernMedicine_other_amt float64 = 0
  21296. var chineseTraditional_claa_sunmfee float64 = 0
  21297. var chineseTraditional_clab_amt float64 = 0
  21298. var chineseTraditional_other_amt float64 = 0
  21299. var check_claa_sunmfee float64 = 0
  21300. var check_clab_amt float64 = 0
  21301. var check_other_amt float64 = 0
  21302. var material_claa_sunmfee float64 = 0
  21303. var material_clab_amt float64 = 0
  21304. var material_other_amt float64 = 0
  21305. var laboratory_claa_sunmfee float64 = 0
  21306. var laboratory_clab_amt float64 = 0
  21307. var laboratory_other_amt float64 = 0
  21308. var treat_claa_sunmfee float64 = 0
  21309. var treat_clab_amt float64 = 0
  21310. var treat_other_amt float64 = 0
  21311. for _, item := range order.HisOrderInfo {
  21312. if item.MedChrgitmType == "01" { //床位费
  21313. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21314. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21315. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21316. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21317. if item.ChrgitmLv == "1" {
  21318. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21319. }
  21320. if item.ChrgitmLv == "2" {
  21321. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21322. }
  21323. if item.ChrgitmLv == "3" {
  21324. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21325. }
  21326. }
  21327. if item.MedChrgitmType == "03" { //检查费
  21328. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21329. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21330. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21331. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21332. if item.ChrgitmLv == "1" {
  21333. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21334. }
  21335. if item.ChrgitmLv == "2" {
  21336. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21337. }
  21338. if item.ChrgitmLv == "3" {
  21339. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21340. }
  21341. }
  21342. if item.MedChrgitmType == "04" { //化验费
  21343. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21344. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21345. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21346. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21347. if item.ChrgitmLv == "1" {
  21348. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21349. }
  21350. if item.ChrgitmLv == "2" {
  21351. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21352. }
  21353. if item.ChrgitmLv == "3" {
  21354. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21355. }
  21356. }
  21357. if item.MedChrgitmType == "05" { //治疗费
  21358. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21359. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21360. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21361. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21362. if item.ChrgitmLv == "1" {
  21363. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21364. }
  21365. if item.ChrgitmLv == "2" {
  21366. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21367. }
  21368. if item.ChrgitmLv == "3" {
  21369. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21370. }
  21371. }
  21372. if item.MedChrgitmType == "06" { //手术费
  21373. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21374. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21375. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21376. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21377. if item.ChrgitmLv == "1" {
  21378. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21379. }
  21380. if item.ChrgitmLv == "2" {
  21381. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21382. }
  21383. if item.ChrgitmLv == "3" {
  21384. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21385. }
  21386. }
  21387. if item.MedChrgitmType == "08" { //材料费
  21388. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21389. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21390. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21391. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21392. if item.ChrgitmLv == "1" {
  21393. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21394. }
  21395. if item.ChrgitmLv == "2" {
  21396. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21397. }
  21398. if item.ChrgitmLv == "3" {
  21399. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21400. }
  21401. }
  21402. if item.MedChrgitmType == "09" { //西药费
  21403. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21404. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21405. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21406. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21407. if item.ChrgitmLv == "1" {
  21408. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21409. }
  21410. if item.ChrgitmLv == "2" {
  21411. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21412. }
  21413. if item.ChrgitmLv == "3" {
  21414. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21415. }
  21416. }
  21417. if item.MedChrgitmType == "11" { //中成费
  21418. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21419. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21420. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21421. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21422. if item.ChrgitmLv == "1" {
  21423. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21424. }
  21425. if item.ChrgitmLv == "2" {
  21426. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21427. }
  21428. if item.ChrgitmLv == "3" {
  21429. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21430. }
  21431. }
  21432. if item.MedChrgitmType == "14" { //其他费
  21433. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21434. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21435. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21436. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21437. if item.ChrgitmLv == "1" {
  21438. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21439. }
  21440. if item.ChrgitmLv == "2" {
  21441. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21442. }
  21443. if item.ChrgitmLv == "3" {
  21444. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21445. }
  21446. }
  21447. }
  21448. var iteminfoStructs []service.IteminfoStruct
  21449. if bedCostTotal != 0 {
  21450. iteminfo.MedChrgitm = "01"
  21451. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21452. iteminfo.Amt = bedCostTotal
  21453. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21454. iteminfo.ClabAmt = bed_clab_amt
  21455. iteminfo.OthAmt = bed_other_amt
  21456. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21457. }
  21458. if checkCostTotal != 0 {
  21459. iteminfo.MedChrgitm = "03"
  21460. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21461. iteminfo.Amt = checkCostTotal
  21462. iteminfo.ClaaSumfee = check_claa_sunmfee
  21463. iteminfo.ClabAmt = check_clab_amt
  21464. iteminfo.OthAmt = check_other_amt
  21465. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21466. }
  21467. if laboratoryCostTotal != 0 {
  21468. iteminfo.MedChrgitm = "04"
  21469. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21470. iteminfo.Amt = laboratoryCostTotal
  21471. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21472. iteminfo.ClabAmt = laboratory_clab_amt
  21473. iteminfo.OthAmt = laboratory_other_amt
  21474. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21475. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21476. }
  21477. if treatCostTotal != 0 {
  21478. iteminfo.MedChrgitm = "05"
  21479. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21480. iteminfo.Amt = treatCostTotal
  21481. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21482. iteminfo.ClabAmt = treat_clab_amt
  21483. iteminfo.OthAmt = treat_other_amt
  21484. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21485. //(struct4101.IteminfoStruct, iteminfo)
  21486. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21487. }
  21488. if operationCostTotal != 0 {
  21489. iteminfo.MedChrgitm = "06"
  21490. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21491. iteminfo.Amt = operationCostTotal
  21492. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21493. iteminfo.ClabAmt = operation_clab_amt
  21494. iteminfo.OthAmt = operation_other_amt
  21495. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21496. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21497. }
  21498. if materialCostTotal != 0 {
  21499. iteminfo.MedChrgitm = "08"
  21500. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21501. iteminfo.Amt = materialCostTotal
  21502. iteminfo.ClaaSumfee = material_claa_sunmfee
  21503. iteminfo.ClabAmt = material_clab_amt
  21504. iteminfo.OthAmt = material_other_amt
  21505. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21506. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21507. }
  21508. if westernMedicineCostTotal != 0 {
  21509. iteminfo.MedChrgitm = "09"
  21510. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21511. iteminfo.Amt = westernMedicineCostTotal
  21512. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21513. iteminfo.ClabAmt = westernMedicine_clab_amt
  21514. iteminfo.OthAmt = westernMedicine_other_amt
  21515. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21516. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21517. }
  21518. if chineseTraditionalMedicineCostTotal != 0 {
  21519. iteminfo.MedChrgitm = "11"
  21520. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21521. iteminfo.Amt = westernMedicineCostTotal
  21522. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21523. iteminfo.ClabAmt = westernMedicine_clab_amt
  21524. iteminfo.OthAmt = westernMedicine_other_amt
  21525. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21526. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21527. }
  21528. if otherCostTotal != 0 {
  21529. iteminfo.MedChrgitm = "14"
  21530. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21531. iteminfo.Amt = otherCostTotal
  21532. iteminfo.ClaaSumfee = other_claa_sunmfee
  21533. iteminfo.ClabAmt = other_clab_amt
  21534. iteminfo.OthAmt = other_other_amt
  21535. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21536. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21537. }
  21538. struct4101.IteminfoStruct = iteminfoStructs
  21539. struct4101.Ntly = "中国"
  21540. struct4101.AdmCaty = "A03.06"
  21541. var resOther ResultSeventeenOther
  21542. var res ResultSeventeen
  21543. if miConfig.MdtrtareaAdmvs == "150404" {
  21544. var pp models.PublicParams
  21545. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21546. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21547. pp.FixmedinsName = miConfig.OrgName
  21548. pp.FixmedinsCode = miConfig.Code
  21549. pp.RequestUrl = miConfig.Url
  21550. pp.Cainfo = miConfig.Cainfo
  21551. pp.SecretKey = miConfig.SecretKey
  21552. pp.AccessKey = miConfig.AccessKey
  21553. pp.OpterName = curRoles.UserName
  21554. client := &http.Client{}
  21555. var req *http.Request
  21556. data := make(map[string]interface{})
  21557. data["struct4101"] = struct4101
  21558. data["pp"] = pp
  21559. bytesData, _ := json.Marshal(data)
  21560. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21561. resp, _ := client.Do(req)
  21562. defer resp.Body.Close()
  21563. body, ioErr := ioutil.ReadAll(resp.Body)
  21564. if ioErr != nil {
  21565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21567. return
  21568. }
  21569. var respJSON map[string]interface{}
  21570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21573. return
  21574. }
  21575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21576. userJSONBytes, _ := json.Marshal(respJSON)
  21577. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21578. utils.ErrorLog("解析失败:%v", err)
  21579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21580. return
  21581. }
  21582. res.InfRefmsgid = resOther.InfRefmsgid
  21583. res.Output = resOther.Output
  21584. res.ErrMsg = resOther.ErrMsg
  21585. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21586. res.Infcode = infocode
  21587. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21588. var pp models.PublicParams
  21589. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21590. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21591. pp.FixmedinsName = miConfig.OrgName
  21592. pp.FixmedinsCode = miConfig.Code
  21593. pp.RequestUrl = miConfig.Url
  21594. pp.Cainfo = miConfig.Cainfo
  21595. pp.SecretKey = miConfig.SecretKey
  21596. pp.AccessKey = miConfig.AccessKey
  21597. pp.OpterName = curRoles.UserName
  21598. result, _ := service.Jxyb4101(struct4101, pp)
  21599. var dat map[string]interface{}
  21600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21601. fmt.Println(dat)
  21602. } else {
  21603. fmt.Println(err)
  21604. }
  21605. userJSONBytes, _ := json.Marshal(dat)
  21606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21607. utils.ErrorLog("解析失败:%v", err)
  21608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21609. return
  21610. }
  21611. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21612. var pp models.PublicParams
  21613. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21614. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21615. pp.FixmedinsName = miConfig.OrgName
  21616. pp.FixmedinsCode = miConfig.Code
  21617. pp.RequestUrl = miConfig.Url
  21618. pp.Cainfo = miConfig.Cainfo
  21619. pp.SecretKey = miConfig.SecretKey
  21620. pp.AccessKey = miConfig.AccessKey
  21621. pp.OpterName = curRoles.UserName
  21622. result, _ := service.Jxyb4101(struct4101, pp)
  21623. var dat map[string]interface{}
  21624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21625. fmt.Println(dat)
  21626. } else {
  21627. fmt.Println(err)
  21628. }
  21629. userJSONBytes, _ := json.Marshal(dat)
  21630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21631. utils.ErrorLog("解析失败:%v", err)
  21632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21633. return
  21634. }
  21635. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21636. var pp models.PublicParams
  21637. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21638. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21639. pp.FixmedinsName = miConfig.OrgName
  21640. pp.FixmedinsCode = miConfig.Code
  21641. pp.RequestUrl = miConfig.Url
  21642. pp.Cainfo = miConfig.Cainfo
  21643. pp.SecretKey = miConfig.SecretKey
  21644. pp.AccessKey = miConfig.AccessKey
  21645. pp.OpterName = curRoles.UserName
  21646. result, _ := service.Jxyb4101(struct4101, pp)
  21647. var dat map[string]interface{}
  21648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21649. fmt.Println(dat)
  21650. } else {
  21651. fmt.Println(err)
  21652. }
  21653. userJSONBytes, _ := json.Marshal(dat)
  21654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21655. utils.ErrorLog("解析失败:%v", err)
  21656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21657. return
  21658. }
  21659. } else {
  21660. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21661. var dat map[string]interface{}
  21662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21663. fmt.Println(dat)
  21664. } else {
  21665. fmt.Println(err)
  21666. }
  21667. userJSONBytes, _ := json.Marshal(dat)
  21668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21669. utils.ErrorLog("解析失败:%v", err)
  21670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21671. return
  21672. }
  21673. }
  21674. if res.Infcode != 0 {
  21675. c.ServeSuccessJSON(map[string]interface{}{
  21676. "failed_code": -10,
  21677. "msg": res.ErrMsg,
  21678. })
  21679. return
  21680. } else {
  21681. if miConfig.MdtrtareaAdmvs != "150404" {
  21682. order.FaPiaoNumber = zero
  21683. order.FaPiaoCode = last_order.FaPiaoCode
  21684. service.UpdateOrder(order)
  21685. }
  21686. hisFundSettleListResult := &models.HisFundSettleListResult{
  21687. Number: res.Output.SetlListId,
  21688. Status: 1,
  21689. Ctime: time.Now().Unix(),
  21690. Mtime: time.Now().Unix(),
  21691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21692. IsUpload: 1,
  21693. OrderId: order_id,
  21694. }
  21695. service.CreateUploadRecord(hisFundSettleListResult)
  21696. c.ServeSuccessJSON(map[string]interface{}{
  21697. "msg": "上传成功",
  21698. "result": hisFundSettleListResult,
  21699. })
  21700. return
  21701. }
  21702. }
  21703. //func (c *HisApiController) GetBatchSettleList() {
  21704. // orders, _ := service.GetAllHisOrder(10106)
  21705. // for _, item := range orders {
  21706. // order_id := item.ID
  21707. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21708. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21709. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21710. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21711. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21712. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21713. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21714. //
  21715. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21716. //
  21717. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21718. //
  21719. // if order.ID == 0 {
  21720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21721. // return
  21722. // }
  21723. // if his.BalanceAccountsType == 2 {
  21724. // continue
  21725. // }
  21726. // struct4101 := service.Struct4101{
  21727. // PsnNo: order.PsnNo,
  21728. // MdtrtId: order.MdtrtId,
  21729. // SetlId: order.SetlId,
  21730. // PsnName: order.PsnName,
  21731. // Gend: order.Gend,
  21732. // Brdy: his.Brdy,
  21733. // Age: his.Age,
  21734. // Naty: order.Naty,
  21735. // PatnCertType: "01",
  21736. // Certno: order.Certno,
  21737. // Prfs: "90",
  21738. // ConerName: roles[0].UserName,
  21739. // PatnRlts: "99",
  21740. // ConerAddr: miConfig.OrgName,
  21741. // ConerTel: admin.Mobile,
  21742. // HiType: order.Insutype,
  21743. // Insuplc: his.InsuplcAdmdvs,
  21744. // MaindiagFlag: "1",
  21745. // BillCode: order.SetlId,
  21746. // BillNo: order.SetlId,
  21747. // BizSn: order.Number,
  21748. // PsnSelfPay: order.PsnPartAmt,
  21749. // PsnOwnPay: order.PsnPartAmt,
  21750. // AcctPay: order.AcctPay,
  21751. // PsnCashpay: order.PsnCashPay,
  21752. // HiPaymtd: "1",
  21753. // Hsorg: his.InsuplcAdmdvs,
  21754. // HsorgOpter: his.InsuplcAdmdvs,
  21755. // MedinsFillPsn: curRoles.UserName,
  21756. // MedinsFillDept: depart.Name,
  21757. // IptMedType: "2",
  21758. // }
  21759. // struct4101.SetlBegnDate = order.SetlTime
  21760. // struct4101.SetlEndDate = order.SetlTime
  21761. // //if order.SettleType == 1 {
  21762. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21763. // // dateStr := t.Format("2006-01-02")
  21764. // // struct4101.SetlBegnDate = dateStr
  21765. // // struct4101.SetlEndDate = dateStr
  21766. // //} else {
  21767. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21768. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21769. // // dateStartStr := t.Format("2006-01-02")
  21770. // // dateEndStr := t2.Format("2006-01-02")
  21771. // // struct4101.SetlBegnDate = dateStartStr
  21772. // // struct4101.SetlEndDate = dateEndStr
  21773. // //}
  21774. //
  21775. // var rf []CustomFundPay
  21776. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21777. //
  21778. // var tempFunPays []service.CustomStruct
  21779. // var tempFunPay610100 service.CustomStruct
  21780. //
  21781. // for _, item := range rf {
  21782. // if item.FundPayType == "610100" {
  21783. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21784. // tempFunPay610100.FundPayType = item.FundPayType
  21785. // } else {
  21786. // var tempFunPay service.CustomStruct
  21787. // tempFunPay.FundPayamt = item.FundPayamt
  21788. // tempFunPay.FundPayType = item.FundPayType
  21789. // tempFunPays = append(tempFunPays, tempFunPay)
  21790. // }
  21791. // }
  21792. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21793. // struct4101.CustomStruct = tempFunPays
  21794. //
  21795. // var tempDiaginfos []service.DiaginfoStructTwo
  21796. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21797. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21798. //
  21799. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21800. // var config []*models.HisXtDiagnoseConfig
  21801. // for _, item := range diagnosis_ids {
  21802. // id, _ := strconv.ParseInt(item, 10, 64)
  21803. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21804. // config = append(config, &diagnosisConfig)
  21805. // }
  21806. //
  21807. // for index, item := range config {
  21808. // if index == 0 {
  21809. // var tempDiaginfo service.DiaginfoStructTwo
  21810. // tempDiaginfo.DiagCode = item.CountryCode
  21811. // tempDiaginfo.DiagName = item.CountryContentName
  21812. // tempDiaginfo.DiagType = "1"
  21813. // tempDiaginfo.MaindiagFlag = "1"
  21814. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21815. // } else {
  21816. //
  21817. // var tempDiaginfo service.DiaginfoStructTwo
  21818. // tempDiaginfo.DiagCode = item.CountryCode
  21819. // tempDiaginfo.DiagName = item.CountryContentName
  21820. // tempDiaginfo.DiagType = "2"
  21821. // tempDiaginfo.MaindiagFlag = "0"
  21822. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21823. // }
  21824. // }
  21825. // struct4101.Diseinfo = tempDiaginfos
  21826. //
  21827. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21828. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21829. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21830. // tempOpspdiseinfo2.OprnOprtCode = ""
  21831. // tempOpspdiseinfo2.OprnOprtName = ""
  21832. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21833. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21834. //
  21835. // var iteminfo service.IteminfoStruct
  21836. //
  21837. // var bedCostTotal float64 = 0 //床位总费
  21838. // var bedCostSelfTotal float64 = 0 //床位自费
  21839. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21840. //
  21841. // var examineCostTotal float64 = 0 //诊查总费
  21842. // var examineCostSelfTotal float64 = 0 //诊查自费
  21843. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21844. //
  21845. // var nursingCostTotal float64 = 0 //护理总费
  21846. // var nursingCostSelfTotal float64 = 0 //护理自费
  21847. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21848. //
  21849. // var chineseMedicineCostTotal float64 = 0 //中成药
  21850. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21851. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21852. //
  21853. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21854. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21855. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21856. //
  21857. // var registerCostTotal float64 = 0 //一般诊疗费
  21858. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21859. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21860. //
  21861. // var operationCostTotal float64 = 0 //手术费
  21862. // var operationCostSelfTotal float64 = 0 //手术费
  21863. // var operationCostPartSelfTotal float64 = 0 //手术费
  21864. //
  21865. // var otherCostTotal float64 = 0 //其他费用
  21866. // var otherCostSelfTotal float64 = 0 //其他费用
  21867. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21868. //
  21869. // var materialCostTotal float64 = 0 //材料费
  21870. // var materialCostSelfTotal float64 = 0 //材料费
  21871. // var materialCostPartSelfTotal float64 = 0 //材料费
  21872. //
  21873. // var westernMedicineCostTotal float64 = 0 //西药费
  21874. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21875. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21876. //
  21877. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21878. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21879. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21880. //
  21881. // var checkCostTotal float64 = 0 //检查费
  21882. // var checkCostSelfTotal float64 = 0 //检查费
  21883. // var checkCostPartSelfTotal float64 = 0 //检查费
  21884. //
  21885. // var laboratoryCostTotal float64 = 0 //化验费
  21886. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21887. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21888. //
  21889. // var treatCostTotal float64 = 0 //治疗费用
  21890. // var treatCostSelfTotal float64 = 0 //治疗费用
  21891. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21892. //
  21893. // decimal.DivisionPrecision = 2
  21894. //
  21895. // var bed_fulamt_ownpay_amt float64 = 0
  21896. //
  21897. // var examine_fulamt_ownpay_amt float64 = 0
  21898. //
  21899. // var nursing_fulamt_ownpay_amt float64 = 0
  21900. //
  21901. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21902. //
  21903. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21904. //
  21905. // var register_fulamt_ownpay_amt float64 = 0
  21906. //
  21907. // var operation_fulamt_ownpay_amt float64 = 0
  21908. // var other_fulamt_ownpay_amt float64 = 0
  21909. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21910. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21911. // var check_fulamt_ownpay_amt float64 = 0
  21912. // var material_fulamt_ownpay_amt float64 = 0
  21913. // var laboratory_fulamt_ownpay_amt float64 = 0
  21914. // var treat_fulamt_ownpay_amt float64 = 0
  21915. //
  21916. // var bed_claa_sunmfee float64 = 0
  21917. // var bed_clab_amt float64 = 0
  21918. // var bed_other_amt float64 = 0
  21919. //
  21920. // var examine_claa_sunmfee float64 = 0
  21921. // var examine_clab_amt float64 = 0
  21922. // var examine_other_amt float64 = 0
  21923. //
  21924. // var nursing_claa_sunmfee float64 = 0
  21925. // var nursing_clab_amt float64 = 0
  21926. // var nursing_other_amt float64 = 0
  21927. //
  21928. // var chinese_medicine_claa_sunmfee float64 = 0
  21929. // var chinese_medicine_clab_amt float64 = 0
  21930. // var chinese_medicine_other_amt float64 = 0
  21931. //
  21932. // var commonly_treatment_claa_sunmfee float64 = 0
  21933. // var commonly_treatment_clab_amt float64 = 0
  21934. // var commonly_treatment_other_amt float64 = 0
  21935. //
  21936. // var operation_claa_sunmfee float64 = 0
  21937. // var operation_clab_amt float64 = 0
  21938. // var operation_other_amt float64 = 0
  21939. //
  21940. // var other_claa_sunmfee float64 = 0
  21941. // var other_clab_amt float64 = 0
  21942. // var other_other_amt float64 = 0
  21943. //
  21944. // var westernMedicine_claa_sunmfee float64 = 0
  21945. // var westernMedicine_clab_amt float64 = 0
  21946. // var westernMedicine_other_amt float64 = 0
  21947. //
  21948. // var chineseTraditional_claa_sunmfee float64 = 0
  21949. // var chineseTraditional_clab_amt float64 = 0
  21950. // var chineseTraditional_other_amt float64 = 0
  21951. //
  21952. // var check_claa_sunmfee float64 = 0
  21953. // var check_clab_amt float64 = 0
  21954. // var check_other_amt float64 = 0
  21955. //
  21956. // var material_claa_sunmfee float64 = 0
  21957. // var material_clab_amt float64 = 0
  21958. // var material_other_amt float64 = 0
  21959. //
  21960. // var laboratory_claa_sunmfee float64 = 0
  21961. // var laboratory_clab_amt float64 = 0
  21962. // var laboratory_other_amt float64 = 0
  21963. //
  21964. // var treat_claa_sunmfee float64 = 0
  21965. // var treat_clab_amt float64 = 0
  21966. // var treat_other_amt float64 = 0
  21967. //
  21968. // var register_claa_sunmfee float64 = 0
  21969. // var register_clab_amt float64 = 0
  21970. // var register_other_amt float64 = 0
  21971. //
  21972. // for _, item := range order.HisOrderInfo {
  21973. // if item.MedChrgitmType == "01" { //床位费
  21974. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21975. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21976. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21977. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21978. // if item.ChrgitmLv == "1" {
  21979. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21980. // }
  21981. // if item.ChrgitmLv == "2" {
  21982. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21983. //
  21984. // }
  21985. // if item.ChrgitmLv == "3" {
  21986. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21987. // }
  21988. //
  21989. // }
  21990. //
  21991. // if item.MedChrgitmType == "02" { //诊查
  21992. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21993. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21994. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21995. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21996. // if item.ChrgitmLv == "1" {
  21997. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21998. // }
  21999. // if item.ChrgitmLv == "2" {
  22000. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22001. //
  22002. // }
  22003. // if item.ChrgitmLv == "3" {
  22004. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22005. // }
  22006. //
  22007. // }
  22008. //
  22009. // if item.MedChrgitmType == "03" { //检查费
  22010. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22011. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22012. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22013. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22014. // if item.ChrgitmLv == "1" {
  22015. //
  22016. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22017. //
  22018. // }
  22019. // if item.ChrgitmLv == "2" {
  22020. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22021. //
  22022. // }
  22023. // if item.ChrgitmLv == "3" {
  22024. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22025. // }
  22026. // }
  22027. //
  22028. // if item.MedChrgitmType == "04" { //化验费
  22029. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22030. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22031. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22032. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22033. // if item.ChrgitmLv == "1" {
  22034. //
  22035. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22036. //
  22037. // }
  22038. // if item.ChrgitmLv == "2" {
  22039. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22040. //
  22041. // }
  22042. // if item.ChrgitmLv == "3" {
  22043. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22044. // }
  22045. // }
  22046. //
  22047. // if item.MedChrgitmType == "05" { //治疗费
  22048. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22049. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22050. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22051. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22052. // if item.ChrgitmLv == "1" {
  22053. //
  22054. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22055. //
  22056. // }
  22057. // if item.ChrgitmLv == "2" {
  22058. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22059. //
  22060. // }
  22061. // if item.ChrgitmLv == "3" {
  22062. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22063. // }
  22064. // }
  22065. //
  22066. // if item.MedChrgitmType == "06" { //手术费
  22067. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22068. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22069. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22070. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22071. //
  22072. // if item.ChrgitmLv == "1" {
  22073. //
  22074. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22075. //
  22076. // }
  22077. // if item.ChrgitmLv == "2" {
  22078. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22079. //
  22080. // }
  22081. // if item.ChrgitmLv == "3" {
  22082. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22083. // }
  22084. // }
  22085. //
  22086. // if item.MedChrgitmType == "07" { //手术费
  22087. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22088. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22089. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22090. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22091. //
  22092. // if item.ChrgitmLv == "1" {
  22093. //
  22094. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22095. //
  22096. // }
  22097. // if item.ChrgitmLv == "2" {
  22098. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22099. //
  22100. // }
  22101. // if item.ChrgitmLv == "3" {
  22102. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22103. // }
  22104. // }
  22105. //
  22106. // if item.MedChrgitmType == "08" { //材料费
  22107. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22108. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22109. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22110. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22111. // if item.ChrgitmLv == "1" {
  22112. //
  22113. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22114. //
  22115. // }
  22116. // if item.ChrgitmLv == "2" {
  22117. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22118. //
  22119. // }
  22120. // if item.ChrgitmLv == "3" {
  22121. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22122. // }
  22123. // }
  22124. // if item.MedChrgitmType == "09" { //西药费
  22125. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22126. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22127. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22128. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22129. // if item.ChrgitmLv == "1" {
  22130. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22131. // }
  22132. // if item.ChrgitmLv == "2" {
  22133. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22134. // }
  22135. // if item.ChrgitmLv == "3" {
  22136. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22137. // }
  22138. // }
  22139. // if item.MedChrgitmType == "10" { //中药饮片
  22140. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22141. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22142. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22143. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22144. // if item.ChrgitmLv == "1" {
  22145. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22146. // }
  22147. // if item.ChrgitmLv == "2" {
  22148. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22149. // }
  22150. // if item.ChrgitmLv == "3" {
  22151. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22152. // }
  22153. // }
  22154. //
  22155. // if item.MedChrgitmType == "11" { //中成费
  22156. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22157. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22158. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22159. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22160. // if item.ChrgitmLv == "1" {
  22161. //
  22162. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22163. //
  22164. // }
  22165. // if item.ChrgitmLv == "2" {
  22166. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22167. //
  22168. // }
  22169. // if item.ChrgitmLv == "3" {
  22170. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22171. // }
  22172. // }
  22173. //
  22174. // if item.MedChrgitmType == "12" { //中成费
  22175. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22176. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22177. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22178. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22179. // if item.ChrgitmLv == "1" {
  22180. //
  22181. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22182. //
  22183. // }
  22184. // if item.ChrgitmLv == "2" {
  22185. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22186. //
  22187. // }
  22188. // if item.ChrgitmLv == "3" {
  22189. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22190. // }
  22191. // }
  22192. //
  22193. // if item.MedChrgitmType == "13" { //中成费
  22194. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22195. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22196. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22197. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22198. // if item.ChrgitmLv == "1" {
  22199. //
  22200. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22201. //
  22202. // }
  22203. // if item.ChrgitmLv == "2" {
  22204. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22205. //
  22206. // }
  22207. // if item.ChrgitmLv == "3" {
  22208. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22209. // }
  22210. // }
  22211. //
  22212. // if item.MedChrgitmType == "14" { //其他费
  22213. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22214. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22215. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22216. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22217. // if item.ChrgitmLv == "1" {
  22218. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22219. //
  22220. // }
  22221. // if item.ChrgitmLv == "2" {
  22222. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22223. //
  22224. // }
  22225. // if item.ChrgitmLv == "3" {
  22226. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22227. // }
  22228. // }
  22229. //
  22230. // }
  22231. //
  22232. // var iteminfoStructs []service.IteminfoStruct
  22233. //
  22234. // if bedCostTotal != 0 {
  22235. // iteminfo.MedChrgitm = "01"
  22236. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22237. // iteminfo.Amt = bedCostTotal
  22238. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22239. // iteminfo.ClabAmt = bed_clab_amt
  22240. // iteminfo.OthAmt = bed_other_amt
  22241. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22242. // }
  22243. //
  22244. // if examineCostTotal != 0 {
  22245. // iteminfo.MedChrgitm = "02"
  22246. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22247. // iteminfo.Amt = examineCostTotal
  22248. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22249. // iteminfo.ClabAmt = examine_clab_amt
  22250. // iteminfo.OthAmt = examine_other_amt
  22251. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22252. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22253. // }
  22254. //
  22255. // if checkCostTotal != 0 {
  22256. // iteminfo.MedChrgitm = "03"
  22257. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22258. // iteminfo.Amt = checkCostTotal
  22259. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22260. // iteminfo.ClabAmt = check_clab_amt
  22261. // iteminfo.OthAmt = check_other_amt
  22262. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22263. //
  22264. // }
  22265. //
  22266. // if laboratoryCostTotal != 0 {
  22267. // iteminfo.MedChrgitm = "04"
  22268. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22269. // iteminfo.Amt = laboratoryCostTotal
  22270. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22271. // iteminfo.ClabAmt = laboratory_clab_amt
  22272. // iteminfo.OthAmt = laboratory_other_amt
  22273. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22274. //
  22275. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22276. //
  22277. // }
  22278. //
  22279. // if treatCostTotal != 0 {
  22280. // iteminfo.MedChrgitm = "05"
  22281. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22282. // iteminfo.Amt = treatCostTotal
  22283. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22284. // iteminfo.ClabAmt = treat_clab_amt
  22285. // iteminfo.OthAmt = treat_other_amt
  22286. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22287. // //(struct4101.IteminfoStruct, iteminfo)
  22288. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22289. // }
  22290. //
  22291. // if operationCostTotal != 0 {
  22292. // iteminfo.MedChrgitm = "06"
  22293. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22294. // iteminfo.Amt = operationCostTotal
  22295. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22296. // iteminfo.ClabAmt = operation_clab_amt
  22297. // iteminfo.OthAmt = operation_other_amt
  22298. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22299. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22300. // }
  22301. //
  22302. // if nursingCostTotal != 0 {
  22303. // iteminfo.MedChrgitm = "07"
  22304. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22305. // iteminfo.Amt = nursingCostTotal
  22306. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22307. // iteminfo.ClabAmt = nursing_clab_amt
  22308. // iteminfo.OthAmt = nursing_other_amt
  22309. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22310. // }
  22311. //
  22312. // if materialCostTotal != 0 {
  22313. // iteminfo.MedChrgitm = "08"
  22314. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22315. // iteminfo.Amt = materialCostTotal
  22316. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22317. // iteminfo.ClabAmt = material_clab_amt
  22318. // iteminfo.OthAmt = material_other_amt
  22319. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22320. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22321. // }
  22322. //
  22323. // if westernMedicineCostTotal != 0 {
  22324. // iteminfo.MedChrgitm = "09"
  22325. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22326. // iteminfo.Amt = westernMedicineCostTotal
  22327. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22328. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22329. // iteminfo.OthAmt = westernMedicine_other_amt
  22330. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22331. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22332. //
  22333. // }
  22334. //
  22335. // if chineseMedicineCostTotal != 0 {
  22336. // iteminfo.MedChrgitm = "10"
  22337. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22338. // iteminfo.Amt = chineseMedicineCostTotal
  22339. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22340. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22341. // iteminfo.OthAmt = chinese_medicine_other_amt
  22342. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22343. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22344. //
  22345. // }
  22346. //
  22347. // if chineseTraditionalMedicineCostTotal != 0 {
  22348. // iteminfo.MedChrgitm = "11"
  22349. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22350. // iteminfo.Amt = westernMedicineCostTotal
  22351. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22352. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22353. // iteminfo.OthAmt = westernMedicine_other_amt
  22354. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22355. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22356. //
  22357. // }
  22358. //
  22359. // if commonlyTreatmentCostTotal != 0 {
  22360. // iteminfo.MedChrgitm = "12"
  22361. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22362. // iteminfo.Amt = commonlyTreatmentCostTotal
  22363. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22364. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22365. // iteminfo.OthAmt = commonly_treatment_other_amt
  22366. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22367. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22368. //
  22369. // }
  22370. //
  22371. // if registerCostTotal != 0 {
  22372. // iteminfo.MedChrgitm = "13"
  22373. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22374. // iteminfo.Amt = registerCostTotal
  22375. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22376. // iteminfo.ClabAmt = register_clab_amt
  22377. // iteminfo.OthAmt = register_other_amt
  22378. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22379. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22380. //
  22381. // }
  22382. //
  22383. // if otherCostTotal != 0 {
  22384. // iteminfo.MedChrgitm = "14"
  22385. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22386. // iteminfo.Amt = otherCostTotal
  22387. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22388. // iteminfo.ClabAmt = other_clab_amt
  22389. // iteminfo.OthAmt = other_other_amt
  22390. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22391. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22392. //
  22393. // }
  22394. // struct4101.IteminfoStruct = iteminfoStructs
  22395. // time_arr := strings.Split(order.SetlTime, " ")
  22396. // struct4101.AdmTime = time_arr[0]
  22397. // struct4101.AdmEndTime = time_arr[0]
  22398. //
  22399. // struct4101.DoctorName = doctor.UserName
  22400. // struct4101.DoctorCode = doctor.DoctorNumber
  22401. //
  22402. // struct4101.Ntly = "中国"
  22403. // struct4101.AdmCaty = "A03.06"
  22404. // var res ResultSeventeen
  22405. // if miConfig.MdtrtareaAdmvs == "421300" {
  22406. // data := make(map[string]interface{})
  22407. // data["struct4101"] = struct4101
  22408. // data["secret_key"] = miConfig.SecretKey
  22409. // data["org_name"] = miConfig.OrgName
  22410. // data["opera"] = curRoles.UserName
  22411. // data["code"] = miConfig.Code
  22412. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22413. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22414. //
  22415. // client := &http.Client{}
  22416. // bytesData, _ := json.Marshal(data)
  22417. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22418. // resp, _ := client.Do(req)
  22419. // defer resp.Body.Close()
  22420. // body, ioErr := ioutil.ReadAll(resp.Body)
  22421. // if ioErr != nil {
  22422. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22424. // return
  22425. // }
  22426. // var respJSON map[string]interface{}
  22427. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22428. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22430. // return
  22431. // }
  22432. //
  22433. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22434. // userJSONBytes, _ := json.Marshal(respJSON)
  22435. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22436. // utils.ErrorLog("解析失败:%v", err)
  22437. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22438. // adminUser := c.GetAdminUserInfo()
  22439. // errlog := &models.HisOrderError{
  22440. // UserOrgId: adminUser.CurrentOrgId,
  22441. // Ctime: time.Now().Unix(),
  22442. // Mtime: time.Now().Unix(),
  22443. // ErrMsg: res.ErrMsg + "解析失败",
  22444. // Status: 1,
  22445. // PatientId: order_id,
  22446. // Stage: 10088,
  22447. // }
  22448. // service.CreateErrMsgLog(errlog)
  22449. // continue
  22450. // }
  22451. //
  22452. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22453. // data := make(map[string]interface{})
  22454. // data["struct4101"] = struct4101
  22455. // data["secret_key"] = miConfig.SecretKey
  22456. // data["org_name"] = miConfig.OrgName
  22457. // data["opera"] = curRoles.UserName
  22458. // data["code"] = miConfig.Code
  22459. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22460. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22461. //
  22462. // client := &http.Client{}
  22463. // bytesData, _ := json.Marshal(data)
  22464. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22465. // resp, _ := client.Do(req)
  22466. // defer resp.Body.Close()
  22467. // body, ioErr := ioutil.ReadAll(resp.Body)
  22468. // if ioErr != nil {
  22469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22471. // return
  22472. // }
  22473. // var respJSON map[string]interface{}
  22474. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22477. // return
  22478. // }
  22479. //
  22480. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22481. // userJSONBytes, _ := json.Marshal(respJSON)
  22482. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22483. // utils.ErrorLog("解析失败:%v", err)
  22484. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22485. // adminUser := c.GetAdminUserInfo()
  22486. // errlog := &models.HisOrderError{
  22487. // UserOrgId: adminUser.CurrentOrgId,
  22488. // Ctime: time.Now().Unix(),
  22489. // Mtime: time.Now().Unix(),
  22490. // ErrMsg: res.ErrMsg + "解析失败",
  22491. // Status: 1,
  22492. // PatientId: order_id,
  22493. // Stage: 10088,
  22494. // }
  22495. // service.CreateErrMsgLog(errlog)
  22496. // continue
  22497. // }
  22498. //
  22499. // } else {
  22500. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22501. // fmt.Println(result)
  22502. //
  22503. // var dat map[string]interface{}
  22504. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22505. // fmt.Println(dat)
  22506. // } else {
  22507. // fmt.Println(err)
  22508. // }
  22509. // userJSONBytes, _ := json.Marshal(dat)
  22510. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22511. // utils.ErrorLog("解析失败:%v", err)
  22512. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22513. // adminUser := c.GetAdminUserInfo()
  22514. // errlog := &models.HisOrderError{
  22515. // UserOrgId: adminUser.CurrentOrgId,
  22516. // Ctime: time.Now().Unix(),
  22517. // Mtime: time.Now().Unix(),
  22518. // ErrMsg: res.ErrMsg + "解析失败",
  22519. // Status: 1,
  22520. // PatientId: order_id,
  22521. // Stage: 10106,
  22522. // }
  22523. // service.CreateErrMsgLog(errlog)
  22524. // continue
  22525. // }
  22526. // }
  22527. //
  22528. // if res.Infcode != 0 {
  22529. // adminUser := c.GetAdminUserInfo()
  22530. // errlog := &models.HisOrderError{
  22531. // UserOrgId: adminUser.CurrentOrgId,
  22532. // Ctime: time.Now().Unix(),
  22533. // Mtime: time.Now().Unix(),
  22534. // ErrMsg: res.ErrMsg,
  22535. // Status: 1,
  22536. // PatientId: order_id,
  22537. // Stage: 10106,
  22538. // }
  22539. // service.CreateErrMsgLog(errlog)
  22540. // continue
  22541. // } else {
  22542. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22543. // Number: res.Output.SetlListId,
  22544. // Status: 1,
  22545. // Ctime: time.Now().Unix(),
  22546. // Mtime: time.Now().Unix(),
  22547. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22548. // IsUpload: 1,
  22549. // OrderId: order_id,
  22550. // }
  22551. // service.CreateUploadRecord(hisFundSettleListResult)
  22552. // continue
  22553. // }
  22554. // }
  22555. //}
  22556. func (c *HisApiController) GetOrgInfo() {
  22557. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22558. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22559. }
  22560. func (c *HisApiController) GetHisPatientInfo() {
  22561. medical_insurance_card := c.GetString("medical_insurance_card")
  22562. id_card_type, _ := c.GetInt64("id_card_type")
  22563. id_card := c.GetString("id_card")
  22564. adminInfo := c.GetAdminUserInfo()
  22565. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22566. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22567. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22568. IdCardNo := ""
  22569. if id_card_type == 1 {
  22570. IdCardNo = medical_insurance_card
  22571. } else if id_card_type == 2 {
  22572. IdCardNo = id_card
  22573. }
  22574. if config.IsOpen == 1 {
  22575. 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
  22576. resp, requestErr := http.Get(api)
  22577. if requestErr != nil {
  22578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22579. return
  22580. }
  22581. defer resp.Body.Close()
  22582. body, ioErr := ioutil.ReadAll(resp.Body)
  22583. if ioErr != nil {
  22584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22586. return
  22587. }
  22588. var respJSON map[string]interface{}
  22589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22592. return
  22593. }
  22594. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22595. userJSONBytes, _ := json.Marshal(userJSON)
  22596. var res ResultTwo
  22597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22598. utils.ErrorLog("解析失败:%v", err)
  22599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22600. return
  22601. }
  22602. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22603. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22604. infoStr := string(Iinfos)
  22605. idetinfoStr := string(Idetinfos)
  22606. if res.Infcode == 0 {
  22607. his := models.VMHisPatient{
  22608. Status: 1,
  22609. Ctime: time.Now().Unix(),
  22610. Mtime: time.Now().Unix(),
  22611. PsnNo: res.Output.Baseinfo.PsnNo,
  22612. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22613. Certno: res.Output.Baseinfo.Certno,
  22614. PsnName: res.Output.Baseinfo.PsnName,
  22615. Gend: res.Output.Baseinfo.Gend,
  22616. Naty: res.Output.Baseinfo.Naty,
  22617. Iinfo: infoStr,
  22618. Idetinfo: idetinfoStr,
  22619. UserOrgId: adminInfo.CurrentOrgId,
  22620. IsReturn: 1,
  22621. IdCardType: id_card_type,
  22622. }
  22623. c.ServeSuccessJSON(map[string]interface{}{
  22624. "info": his,
  22625. })
  22626. } else {
  22627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22628. return
  22629. }
  22630. }
  22631. }
  22632. //func GetBasBaseInfo() (jsonStr string, err error) {
  22633. //
  22634. // handle := syscall.NewLazyDLL("SSCard.dll")
  22635. // add := handle.NewProc("ReadCardBas")
  22636. // str := make([]byte, 1024)
  22637. // str1 := make([]byte, 1024)
  22638. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22639. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22640. //
  22641. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22642. //
  22643. // fmt.Println("> Add(4,5)的结果为:", ret)
  22644. // handle.Release()
  22645. //
  22646. // return "", nil
  22647. //
  22648. //}
  22649. //func GetQRBaseInfo() (jsonStr string, err error) {
  22650. // handle := syscall.LoadDLL("SSCard.dll")
  22651. // ReadCardBas := handle.FindProc("GetQRBase")
  22652. //
  22653. // str := make([]byte, 256)
  22654. // str1 := make([]byte, 256)
  22655. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22656. //
  22657. // fmt.Println(string(str))
  22658. // fmt.Println(r)
  22659. // return string(str), nil
  22660. //}
  22661. //func CardInit() int {
  22662. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22663. // add := DllTestDef.MustFindProc("Init")
  22664. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22665. // if err != nil {
  22666. // fmt.Println("SSCard的运算结果为:", ret)
  22667. // }
  22668. // result := int(ret)
  22669. // return result
  22670. //}
  22671. //func CardInit() int {
  22672. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22673. // if err != nil {
  22674. // fmt.Println("SSCard的运算结果为:", ret)
  22675. // }
  22676. // fmt.Println(err)
  22677. // result := int(ret)
  22678. // return result
  22679. //}
  22680. func IntPtr(n int) uintptr {
  22681. return uintptr(n)
  22682. }
  22683. func StrPtr(s string) uintptr {
  22684. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22685. }
  22686. type Result2001 struct {
  22687. Cainfo interface{} `json:"cainfo"`
  22688. ErrMsg string `json:"err_msg"`
  22689. InfRefmsgid string `json:"inf_refmsgid"`
  22690. Infcode int64 `json:"infcode"`
  22691. Output struct {
  22692. Trtinfo struct {
  22693. PsnNo string `json:"psn_no"`
  22694. TrtChkType string `json:"trt_chk_type"`
  22695. FundPayType string `json:"fund_pay_type"`
  22696. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22697. Begndate string `json:"begndate"`
  22698. Enddate string `json:"enddate"`
  22699. TrtChkRslt string `json:"trt_chk_rslt"`
  22700. } `json:"trtinfo"`
  22701. } `json:"output"`
  22702. RefmsgTime string `json:"refmsg_time"`
  22703. RespondTime string `json:"respond_time"`
  22704. Signtype interface{} `json:"signtype"`
  22705. WarnMsg interface{} `json:"warn_msg"`
  22706. }
  22707. type Result2001Org10265 struct {
  22708. Cainfo interface{} `json:"cainfo"`
  22709. ErrMsg string `json:"err_msg"`
  22710. InfRefmsgid string `json:"inf_refmsgid"`
  22711. Infcode string `json:"infcode"`
  22712. Output struct {
  22713. Trtinfo struct {
  22714. PsnNo string `json:"psn_no"`
  22715. TrtChkType string `json:"trt_chk_type"`
  22716. FundPayType string `json:"fund_pay_type"`
  22717. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22718. Begndate string `json:"begndate"`
  22719. Enddate string `json:"enddate"`
  22720. TrtChkRslt string `json:"trt_chk_rslt"`
  22721. } `json:"trtinfo"`
  22722. } `json:"output"`
  22723. RefmsgTime string `json:"refmsg_time"`
  22724. RespondTime string `json:"respond_time"`
  22725. Signtype interface{} `json:"signtype"`
  22726. WarnMsg interface{} `json:"warn_msg"`
  22727. }
  22728. type ResultTwo struct {
  22729. ErrMsg string `json:"err_msg"`
  22730. InfRefmsgid string `json:"inf_refmsgid"`
  22731. Infcode int64 `json:"infcode"`
  22732. Output struct {
  22733. Baseinfo struct {
  22734. //Brdy string `json:"brdy"`
  22735. Certno string `json:"certno"`
  22736. Gend string `json:"gend"`
  22737. Naty string `json:"naty"`
  22738. PsnCertType string `json:"psn_cert_type"`
  22739. PsnName string `json:"psn_name"`
  22740. PsnNo string `json:"psn_no"`
  22741. } `json:"baseinfo"`
  22742. Idetinfo []interface{} `json:"idetinfo"`
  22743. Iinfo []struct {
  22744. Balc float64 `json:"balc"`
  22745. CvlservFlag string `json:"cvlserv_flag"`
  22746. EmpName string `json:"emp_name"`
  22747. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22748. Insutype string `json:"insutype"`
  22749. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22750. //PausInsuDate string `json:"paus_insu_date"`
  22751. //PsnInsuDate string `json:"psn_insu_date"`
  22752. PsnInsuStas string `json:"psn_insu_stas"`
  22753. PsnType string `json:"psn_type"`
  22754. } `json:"insuinfo"`
  22755. } `json:"output"`
  22756. RefmsgTime string `json:"refmsg_time"`
  22757. RespondTime string `json:"respond_time"`
  22758. Signtype interface{} `json:"signtype"`
  22759. WarnInfo interface{} `json:"warn_info"`
  22760. }
  22761. type ResultTwo10265 struct {
  22762. ErrMsg string `json:"err_msg"`
  22763. InfRefmsgid string `json:"inf_refmsgid"`
  22764. Infcode string `json:"infcode"`
  22765. Output struct {
  22766. Baseinfo struct {
  22767. //Brdy string `json:"brdy"`
  22768. Certno string `json:"certno"`
  22769. Gend string `json:"gend"`
  22770. Naty string `json:"naty"`
  22771. PsnCertType string `json:"psn_cert_type"`
  22772. PsnName string `json:"psn_name"`
  22773. PsnNo string `json:"psn_no"`
  22774. } `json:"baseinfo"`
  22775. Idetinfo []interface{} `json:"idetinfo"`
  22776. Iinfo []struct {
  22777. Balc float64 `json:"balc"`
  22778. CvlservFlag string `json:"cvlserv_flag"`
  22779. EmpName string `json:"emp_name"`
  22780. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22781. Insutype string `json:"insutype"`
  22782. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22783. PsnInsuStas string `json:"psn_insu_stas"`
  22784. PsnType string `json:"psn_type"`
  22785. } `json:"insuinfo"`
  22786. } `json:"output"`
  22787. RefmsgTime string `json:"refmsg_time"`
  22788. RespondTime string `json:"respond_time"`
  22789. Signtype interface{} `json:"signtype"`
  22790. WarnInfo interface{} `json:"warn_info"`
  22791. }
  22792. type ResultThree struct {
  22793. Cainfo interface{} `json:"cainfo"`
  22794. ErrMsg string `json:"err_msg"`
  22795. InfRefmsgid string `json:"inf_refmsgid"`
  22796. Infcode int64 `json:"infcode"`
  22797. Output struct {
  22798. Data struct {
  22799. IptOtpNo string `json:"ipt_otp_no"`
  22800. MdtrtID string `json:"mdtrt_id"`
  22801. PsnNo string `json:"psn_no"`
  22802. } `json:"data"`
  22803. } `json:"output"`
  22804. RefmsgTime string `json:"refmsg_time"`
  22805. RespondTime string `json:"respond_time"`
  22806. Signtype interface{} `json:"signtype"`
  22807. WarnMsg interface{} `json:"warn_msg"`
  22808. }
  22809. type ResultThree10265 struct {
  22810. Cainfo interface{} `json:"cainfo"`
  22811. ErrMsg string `json:"err_msg"`
  22812. InfRefmsgid string `json:"inf_refmsgid"`
  22813. Infcode string `json:"infcode"`
  22814. Output struct {
  22815. Data struct {
  22816. IptOtpNo string `json:"ipt_otp_no"`
  22817. MdtrtID string `json:"mdtrt_id"`
  22818. PsnNo string `json:"psn_no"`
  22819. } `json:"data"`
  22820. } `json:"output"`
  22821. RefmsgTime string `json:"refmsg_time"`
  22822. RespondTime string `json:"respond_time"`
  22823. Signtype interface{} `json:"signtype"`
  22824. WarnMsg interface{} `json:"warn_msg"`
  22825. }
  22826. type ResultFour struct {
  22827. Cainfo string `json:"cainfo"`
  22828. ErrMsg string `json:"err_msg"`
  22829. InfRefmsgid string `json:"inf_refmsgid"`
  22830. Infcode int64 `json:"infcode"`
  22831. Output struct {
  22832. Result []struct {
  22833. BasMednFlag string `json:"bas_medn_flag"`
  22834. ChldMedcFlag string `json:"chld_medc_flag"`
  22835. ChrgitmLv string `json:"chrgitm_lv"`
  22836. Cnt float64 `json:"cnt"`
  22837. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22838. DrtReimFlag string `json:"drt_reim_flag"`
  22839. FeedetlSn string `json:"feedetl_sn"`
  22840. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22841. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22842. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22843. ListSpItemFlag string `json:"list_sp_item_flag"`
  22844. LmtUsedFlag string `json:"lmt_used_flag"`
  22845. MedChrgitmType string `json:"med_chrgitm_type"`
  22846. Memo string `json:"memo"`
  22847. OverlmtAmt float64 `json:"overlmt_amt"`
  22848. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22849. Pric float64 `json:"pric"`
  22850. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22851. SelfpayProp float64 `json:"selfpay_prop"`
  22852. } `json:"result"`
  22853. } `json:"output"`
  22854. RefmsgTime string `json:"refmsg_time"`
  22855. RespondTime string `json:"respond_time"`
  22856. Signtype string `json:"signtype"`
  22857. WarnMsg string `json:"warn_msg"`
  22858. }
  22859. type ResultFour10265 struct {
  22860. Cainfo string `json:"cainfo"`
  22861. ErrMsg string `json:"err_msg"`
  22862. InfRefmsgid string `json:"inf_refmsgid"`
  22863. Infcode string `json:"infcode"`
  22864. Output struct {
  22865. Result []struct {
  22866. BasMednFlag string `json:"bas_medn_flag"`
  22867. ChldMedcFlag string `json:"chld_medc_flag"`
  22868. ChrgitmLv string `json:"chrgitm_lv"`
  22869. Cnt float64 `json:"cnt"`
  22870. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22871. DrtReimFlag string `json:"drt_reim_flag"`
  22872. FeedetlSn string `json:"feedetl_sn"`
  22873. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22874. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22875. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22876. ListSpItemFlag string `json:"list_sp_item_flag"`
  22877. LmtUsedFlag string `json:"lmt_used_flag"`
  22878. MedChrgitmType string `json:"med_chrgitm_type"`
  22879. Memo string `json:"memo"`
  22880. OverlmtAmt float64 `json:"overlmt_amt"`
  22881. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22882. Pric float64 `json:"pric"`
  22883. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22884. SelfpayProp float64 `json:"selfpay_prop"`
  22885. } `json:"result"`
  22886. } `json:"output"`
  22887. RefmsgTime string `json:"refmsg_time"`
  22888. RespondTime string `json:"respond_time"`
  22889. Signtype string `json:"signtype"`
  22890. WarnMsg string `json:"warn_msg"`
  22891. }
  22892. type ResultMemo struct {
  22893. InsuAdmdvs string `json:"insuAdmdvs"`
  22894. }
  22895. // [{"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}]
  22896. type ResultIDInfo struct {
  22897. Begntime string `json:"begntime"`
  22898. Endtime string `json:"endtime"`
  22899. Memo string `json:"memo"`
  22900. }
  22901. type ResultFive struct {
  22902. Balc float64 `json:"balc"`
  22903. CvlservFlag string `json:"cvlserv_flag"`
  22904. EmpName string `json:"emp_name"`
  22905. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22906. Insutype string `json:"insutype"`
  22907. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22908. PausInsuDate string `json:"paus_insu_date"`
  22909. PsnInsuDate string `json:"psn_insu_date"`
  22910. PsnInsuStas string `json:"psn_insu_stas"`
  22911. PsnType string `json:"psn_type"`
  22912. }
  22913. type ResultSix struct {
  22914. Cainfo interface{} `json:"cainfo"`
  22915. ErrMsg string `json:"err_msg"`
  22916. InfRefmsgid string `json:"inf_refmsgid"`
  22917. Infcode int64 `json:"infcode"`
  22918. Output struct {
  22919. } `json:"output"`
  22920. RefmsgTime string `json:"refmsg_time"`
  22921. RespondTime string `json:"respond_time"`
  22922. Signtype interface{} `json:"signtype"`
  22923. WarnMsg interface{} `json:"warn_msg"`
  22924. }
  22925. type ResultSix3103 struct {
  22926. Cainfo interface{} `json:"cainfo"`
  22927. ErrMsg string `json:"err_msg"`
  22928. InfRefmsgid string `json:"inf_refmsgid"`
  22929. Infcode int64 `json:"infcode"`
  22930. RefmsgTime string `json:"refmsg_time"`
  22931. RespondTime string `json:"respond_time"`
  22932. Signtype interface{} `json:"signtype"`
  22933. WarnMsg interface{} `json:"warn_msg"`
  22934. }
  22935. type FJ3507Result struct {
  22936. Cainfo interface{} `json:"cainfo"`
  22937. ErrMsg string `json:"err_msg"`
  22938. InfRefmsgid string `json:"inf_refmsgid"`
  22939. Infcode int64 `json:"infcode"`
  22940. Output struct {
  22941. retRslt string `json:"retRslt"`
  22942. msgRslt string `json:"msgRslt"`
  22943. } `json:"output"`
  22944. RefmsgTime string `json:"refmsg_time"`
  22945. RespondTime string `json:"respond_time"`
  22946. Signtype interface{} `json:"signtype"`
  22947. WarnMsg interface{} `json:"warn_msg"`
  22948. }
  22949. type FJ3507ResultFor10188 struct {
  22950. Cainfo interface{} `json:"cainfo"`
  22951. ErrMsg string `json:"err_msg"`
  22952. InfRefmsgid string `json:"inf_refmsgid"`
  22953. Infcode string `json:"infcode"`
  22954. RefmsgTime string `json:"refmsg_time"`
  22955. RespondTime string `json:"respond_time"`
  22956. Signtype interface{} `json:"signtype"`
  22957. WarnMsg interface{} `json:"warn_msg"`
  22958. }
  22959. type Result2406 struct {
  22960. Cainfo interface{} `json:"cainfo"`
  22961. ErrMsg string `json:"err_msg"`
  22962. InfRefmsgid string `json:"inf_refmsgid"`
  22963. Infcode int64 `json:"infcode"`
  22964. Output struct {
  22965. Result struct {
  22966. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22967. } `json:"result"`
  22968. } `json:"output"`
  22969. RefmsgTime string `json:"refmsg_time"`
  22970. RespondTime string `json:"respond_time"`
  22971. Signtype interface{} `json:"signtype"`
  22972. WarnMsg interface{} `json:"warn_msg"`
  22973. }
  22974. type GZResultSix struct {
  22975. Cainfo interface{} `json:"cainfo"`
  22976. ErrMsg string `json:"err_msg"`
  22977. InfRefmsgid string `json:"inf_refmsgid"`
  22978. Infcode int64 `json:"infcode"`
  22979. Output string `json:"output"`
  22980. RefmsgTime string `json:"refmsg_time"`
  22981. RespondTime string `json:"respond_time"`
  22982. Signtype interface{} `json:"signtype"`
  22983. WarnMsg interface{} `json:"warn_msg"`
  22984. }
  22985. type ResultSix10265 struct {
  22986. Cainfo interface{} `json:"cainfo"`
  22987. ErrMsg string `json:"err_msg"`
  22988. InfRefmsgid string `json:"inf_refmsgid"`
  22989. Infcode string `json:"infcode"`
  22990. Output struct {
  22991. } `json:"output"`
  22992. RefmsgTime string `json:"refmsg_time"`
  22993. RespondTime string `json:"respond_time"`
  22994. Signtype interface{} `json:"signtype"`
  22995. WarnMsg interface{} `json:"warn_msg"`
  22996. }
  22997. type ResultSeven struct {
  22998. Cainfo string `json:"cainfo"`
  22999. ErrMsg string `json:"err_msg"`
  23000. InfRefmsgid string `json:"inf_refmsgid"`
  23001. Infcode int64 `json:"infcode"`
  23002. Output struct {
  23003. Setlinfo struct {
  23004. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23005. AcctPay float64 `json:"acct_pay"`
  23006. ActPayDedc float64 `json:"act_pay_dedc"`
  23007. Age float64 `json:"age"`
  23008. Balc float64 `json:"balc"`
  23009. Certno string `json:"certno"`
  23010. ClrOptins string `json:"clr_optins"`
  23011. ClrType string `json:"clr_type"`
  23012. ClrWay string `json:"clr_way"`
  23013. CvlservFlag string `json:"cvlserv_flag"`
  23014. CvlservPay float64 `json:"cvlserv_pay"`
  23015. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23016. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23017. Gend string `json:"gend"`
  23018. HifesPay float64 `json:"hifes_pay"`
  23019. HifmiPay float64 `json:"hifmi_pay"`
  23020. HifpPay float64 `json:"hifp_pay"`
  23021. HospPartAmt float64 `json:"hosp_part_amt"`
  23022. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23023. Insutype string `json:"insutype"`
  23024. MafPay float64 `json:"maf_pay"`
  23025. MdtrtCertType string `json:"mdtrt_cert_type"`
  23026. HifobPay float64 `json:"hifob_pay"`
  23027. MdtrtID string `json:"mdtrt_id"`
  23028. MedType string `json:"med_type"`
  23029. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23030. MedinsSetlID string `json:"medins_setl_id"`
  23031. Naty string `json:"naty"`
  23032. OthPay float64 `json:"oth_pay"`
  23033. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23034. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23035. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23036. PsnCashPay float64 `json:"psn_cash_pay"`
  23037. PsnCertType string `json:"psn_cert_type"`
  23038. PsnName string `json:"psn_name"`
  23039. PsnNo string `json:"psn_no"`
  23040. PsnPartAmt float64 `json:"psn_part_amt"`
  23041. PsnType string `json:"psn_type"`
  23042. SetlID string `json:"setl_id"`
  23043. SetlTime string `json:"setl_time"`
  23044. } `json:"setlinfo"`
  23045. Setldetail interface{} `json:"setldetail"`
  23046. } `json:"output"`
  23047. RefmsgTime string `json:"refmsg_time"`
  23048. RespondTime string `json:"respond_time"`
  23049. Signtype interface{} `json:"signtype"`
  23050. WarnMsg interface{} `json:"warn_msg"`
  23051. }
  23052. type ResultSeven10633 struct {
  23053. Cainfo string `json:"cainfo"`
  23054. ErrMsg string `json:"err_msg"`
  23055. InfRefmsgid string `json:"inf_refmsgid"`
  23056. Infcode int64 `json:"infcode"`
  23057. Output struct {
  23058. Setlinfo struct {
  23059. AcctPay float64 `json:"acct_pay"`
  23060. ActPayDedc float64 `json:"act_pay_dedc"`
  23061. Age float64 `json:"age"`
  23062. Balc float64 `json:"balc"`
  23063. Certno string `json:"certno"`
  23064. ClrOptins string `json:"clr_optins"`
  23065. ClrType string `json:"clr_type"`
  23066. ClrWay string `json:"clr_way"`
  23067. CvlservFlag string `json:"cvlserv_flag"`
  23068. CvlservPay float64 `json:"cvlserv_pay"`
  23069. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23070. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23071. Gend string `json:"gend"`
  23072. HifesPay float64 `json:"hifes_pay"`
  23073. HifmiPay float64 `json:"hifmi_pay"`
  23074. HifpPay float64 `json:"hifp_pay"`
  23075. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23076. Insutype string `json:"insutype"`
  23077. MafPay float64 `json:"maf_pay"`
  23078. MdtrtCertType string `json:"mdtrt_cert_type"`
  23079. HifobPay float64 `json:"hifob_pay"`
  23080. MdtrtID string `json:"mdtrt_id"`
  23081. MedType string `json:"med_type"`
  23082. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23083. MedinsSetlID string `json:"medins_setl_id"`
  23084. Naty string `json:"naty"`
  23085. OthPay float64 `json:"oth_pay"`
  23086. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23087. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23088. PsnCashPay float64 `json:"psn_cash_pay"`
  23089. PsnCertType string `json:"psn_cert_type"`
  23090. PsnName string `json:"psn_name"`
  23091. PsnNo string `json:"psn_no"`
  23092. PsnPartAmt float64 `json:"psn_part_amt"`
  23093. PsnType string `json:"psn_type"`
  23094. SetlID string `json:"setl_id"`
  23095. SetlTime string `json:"setl_time"`
  23096. } `json:"setlinfo"`
  23097. Setldetail interface{} `json:"setldetail"`
  23098. } `json:"output"`
  23099. RefmsgTime string `json:"refmsg_time"`
  23100. RespondTime string `json:"respond_time"`
  23101. Signtype interface{} `json:"signtype"`
  23102. WarnMsg interface{} `json:"warn_msg"`
  23103. }
  23104. type ResultSevenAH struct {
  23105. Cainfo string `json:"cainfo"`
  23106. ErrMsg string `json:"err_msg"`
  23107. InfRefmsgid string `json:"inf_refmsgid"`
  23108. Infcode int64 `json:"infcode"`
  23109. Output struct {
  23110. Setlinfo struct {
  23111. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23112. AcctPay float64 `json:"acct_pay"`
  23113. ActPayDedc float64 `json:"act_pay_dedc"`
  23114. Age float64 `json:"age"`
  23115. Balc float64 `json:"balc"`
  23116. Certno string `json:"certno"`
  23117. ClrOptins string `json:"clr_optins"`
  23118. ClrType string `json:"clr_type"`
  23119. ClrWay string `json:"clr_way"`
  23120. CvlservFlag string `json:"cvlserv_flag"`
  23121. CvlservPay float64 `json:"cvlserv_pay"`
  23122. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23123. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23124. Gend string `json:"gend"`
  23125. HifesPay float64 `json:"hifes_pay"`
  23126. HifmiPay float64 `json:"hifmi_pay"`
  23127. HifpPay float64 `json:"hifp_pay"`
  23128. HospPartAmt float64 `json:"hosp_part_amt"`
  23129. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23130. Insutype string `json:"insutype"`
  23131. MafPay float64 `json:"maf_pay"`
  23132. MdtrtCertType string `json:"mdtrt_cert_type"`
  23133. HifobPay float64 `json:"hifob_pay"`
  23134. MdtrtID string `json:"mdtrt_id"`
  23135. MedType string `json:"med_type"`
  23136. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23137. MedinsSetlID string `json:"medins_setl_id"`
  23138. Naty string `json:"naty"`
  23139. OthPay float64 `json:"oth_pay"`
  23140. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23141. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23142. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23143. PsnCashPay float64 `json:"psn_cash_pay"`
  23144. PsnCertType string `json:"psn_cert_type"`
  23145. PsnName string `json:"psn_name"`
  23146. PsnNo string `json:"psn_no"`
  23147. PsnPartAmt float64 `json:"psn_part_amt"`
  23148. PsnType string `json:"psn_type"`
  23149. SetlID string `json:"setl_id"`
  23150. SetlTime int64 `json:"setl_time"`
  23151. } `json:"setlinfo"`
  23152. Setldetail interface{} `json:"setldetail"`
  23153. } `json:"output"`
  23154. RefmsgTime string `json:"refmsg_time"`
  23155. RespondTime string `json:"respond_time"`
  23156. Signtype interface{} `json:"signtype"`
  23157. WarnMsg interface{} `json:"warn_msg"`
  23158. }
  23159. type ResultSeven10265 struct {
  23160. Cainfo string `json:"cainfo"`
  23161. ErrMsg string `json:"err_msg"`
  23162. InfRefmsgid string `json:"inf_refmsgid"`
  23163. Infcode string `json:"infcode"`
  23164. Output struct {
  23165. Setlinfo struct {
  23166. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23167. AcctPay float64 `json:"acct_pay"`
  23168. ActPayDedc float64 `json:"act_pay_dedc"`
  23169. Age float64 `json:"age"`
  23170. Balc float64 `json:"balc"`
  23171. Certno string `json:"certno"`
  23172. ClrOptins string `json:"clr_optins"`
  23173. ClrType string `json:"clr_type"`
  23174. ClrWay string `json:"clr_way"`
  23175. CvlservFlag string `json:"cvlserv_flag"`
  23176. CvlservPay float64 `json:"cvlserv_pay"`
  23177. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23178. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23179. Gend string `json:"gend"`
  23180. HifesPay float64 `json:"hifes_pay"`
  23181. HifmiPay float64 `json:"hifmi_pay"`
  23182. HifpPay float64 `json:"hifp_pay"`
  23183. HospPartAmt float64 `json:"hosp_part_amt"`
  23184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23185. Insutype string `json:"insutype"`
  23186. MafPay float64 `json:"maf_pay"`
  23187. MdtrtCertType string `json:"mdtrt_cert_type"`
  23188. HifobPay float64 `json:"hifob_pay"`
  23189. MdtrtID string `json:"mdtrt_id"`
  23190. MedType string `json:"med_type"`
  23191. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23192. MedinsSetlID string `json:"medins_setl_id"`
  23193. Naty string `json:"naty"`
  23194. OthPay float64 `json:"oth_pay"`
  23195. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23196. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23197. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23198. PsnCashPay float64 `json:"psn_cash_pay"`
  23199. PsnCertType string `json:"psn_cert_type"`
  23200. PsnName string `json:"psn_name"`
  23201. PsnNo string `json:"psn_no"`
  23202. PsnPartAmt float64 `json:"psn_part_amt"`
  23203. PsnType string `json:"psn_type"`
  23204. SetlID string `json:"setl_id"`
  23205. SetlTime string `json:"setl_time"`
  23206. } `json:"setlinfo"`
  23207. Setldetail interface{} `json:"setldetail"`
  23208. } `json:"output"`
  23209. RefmsgTime string `json:"refmsg_time"`
  23210. RespondTime string `json:"respond_time"`
  23211. Signtype interface{} `json:"signtype"`
  23212. WarnMsg interface{} `json:"warn_msg"`
  23213. }
  23214. type ResultSeven10265Two struct {
  23215. Cainfo string `json:"cainfo"`
  23216. ErrMsg string `json:"err_msg"`
  23217. InfRefmsgid string `json:"inf_refmsgid"`
  23218. Infcode string `json:"infcode"`
  23219. Output struct {
  23220. Setlinfo struct {
  23221. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23222. AcctPay float64 `json:"acct_pay"`
  23223. ActPayDedc float64 `json:"act_pay_dedc"`
  23224. Age float64 `json:"age"`
  23225. Balc float64 `json:"balc"`
  23226. Certno string `json:"certno"`
  23227. ClrOptins string `json:"clr_optins"`
  23228. ClrType string `json:"clr_type"`
  23229. ClrWay string `json:"clr_way"`
  23230. CvlservFlag string `json:"cvlserv_flag"`
  23231. CvlservPay float64 `json:"cvlserv_pay"`
  23232. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23233. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23234. Gend string `json:"gend"`
  23235. HifesPay float64 `json:"hifes_pay"`
  23236. HifmiPay float64 `json:"hifmi_pay"`
  23237. HifpPay float64 `json:"hifp_pay"`
  23238. HospPartAmt string `json:"hosp_part_amt"`
  23239. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23240. Insutype string `json:"insutype"`
  23241. MafPay float64 `json:"maf_pay"`
  23242. MdtrtCertType string `json:"mdtrt_cert_type"`
  23243. HifobPay float64 `json:"hifob_pay"`
  23244. MdtrtID string `json:"mdtrt_id"`
  23245. MedType string `json:"med_type"`
  23246. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23247. MedinsSetlID string `json:"medins_setl_id"`
  23248. Naty string `json:"naty"`
  23249. OthPay float64 `json:"oth_pay"`
  23250. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23251. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23252. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23253. PsnCashPay float64 `json:"psn_cash_pay"`
  23254. PsnCertType string `json:"psn_cert_type"`
  23255. PsnName string `json:"psn_name"`
  23256. PsnNo string `json:"psn_no"`
  23257. PsnPartAmt float64 `json:"psn_part_amt"`
  23258. PsnType string `json:"psn_type"`
  23259. SetlID string `json:"setl_id"`
  23260. SetlTime string `json:"setl_time"`
  23261. } `json:"setlinfo"`
  23262. Setldetail interface{} `json:"setldetail"`
  23263. } `json:"output"`
  23264. RefmsgTime string `json:"refmsg_time"`
  23265. RespondTime string `json:"respond_time"`
  23266. Signtype interface{} `json:"signtype"`
  23267. WarnMsg interface{} `json:"warn_msg"`
  23268. }
  23269. type ResultSeven10633Two struct {
  23270. Cainfo string `json:"cainfo"`
  23271. ErrMsg string `json:"err_msg"`
  23272. InfRefmsgid string `json:"inf_refmsgid"`
  23273. Infcode string `json:"infcode"`
  23274. Output struct {
  23275. Setlinfo struct {
  23276. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23277. AcctPay float64 `json:"acct_pay"`
  23278. ActPayDedc float64 `json:"act_pay_dedc"`
  23279. Age float64 `json:"age"`
  23280. Balc float64 `json:"balc"`
  23281. Certno string `json:"certno"`
  23282. ClrOptins string `json:"clr_optins"`
  23283. ClrType string `json:"clr_type"`
  23284. ClrWay string `json:"clr_way"`
  23285. CvlservFlag string `json:"cvlserv_flag"`
  23286. CvlservPay float64 `json:"cvlserv_pay"`
  23287. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23288. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23289. Gend string `json:"gend"`
  23290. HifesPay float64 `json:"hifes_pay"`
  23291. HifmiPay float64 `json:"hifmi_pay"`
  23292. HifpPay float64 `json:"hifp_pay"`
  23293. HospPartAmt float64 `json:"hosp_part_amt"`
  23294. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23295. Insutype string `json:"insutype"`
  23296. MafPay float64 `json:"maf_pay"`
  23297. MdtrtCertType string `json:"mdtrt_cert_type"`
  23298. HifobPay float64 `json:"hifob_pay"`
  23299. MdtrtID string `json:"mdtrt_id"`
  23300. MedType string `json:"med_type"`
  23301. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23302. MedinsSetlID string `json:"medins_setl_id"`
  23303. Naty string `json:"naty"`
  23304. OthPay float64 `json:"oth_pay"`
  23305. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23306. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23307. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23308. PsnCashPay float64 `json:"psn_cash_pay"`
  23309. PsnCertType string `json:"psn_cert_type"`
  23310. PsnName string `json:"psn_name"`
  23311. PsnNo string `json:"psn_no"`
  23312. PsnPartAmt float64 `json:"psn_part_amt"`
  23313. PsnType string `json:"psn_type"`
  23314. SetlID string `json:"setl_id"`
  23315. SetlTime string `json:"setl_time"`
  23316. } `json:"setlinfo"`
  23317. Setldetail interface{} `json:"setldetail"`
  23318. } `json:"output"`
  23319. RefmsgTime string `json:"refmsg_time"`
  23320. RespondTime string `json:"respond_time"`
  23321. Signtype interface{} `json:"signtype"`
  23322. WarnMsg interface{} `json:"warn_msg"`
  23323. }
  23324. type FlexibleFloat float64
  23325. func (f *FlexibleFloat) UnmarshalJSON(data []byte) error {
  23326. var v interface{}
  23327. if err := json.Unmarshal(data, &v); err != nil {
  23328. return err
  23329. }
  23330. switch value := v.(type) {
  23331. case float64:
  23332. *f = FlexibleFloat(value)
  23333. case string:
  23334. if value == "" {
  23335. *f = 0 // 空字符串默认0
  23336. } else {
  23337. num, err := strconv.ParseFloat(value, 64)
  23338. if err != nil {
  23339. return fmt.Errorf("无法解析字符串为浮点数: %v", err)
  23340. }
  23341. *f = FlexibleFloat(num)
  23342. }
  23343. default:
  23344. return fmt.Errorf("不支持的字段类型: %T", value)
  23345. }
  23346. return nil
  23347. }
  23348. type ResultSeven10633Three struct {
  23349. Cainfo string `json:"cainfo"`
  23350. ErrMsg string `json:"err_msg"`
  23351. InfRefmsgid string `json:"inf_refmsgid"`
  23352. Infcode string `json:"infcode"`
  23353. Output struct {
  23354. Setlinfo struct {
  23355. AcctPay float64 `json:"acct_pay"`
  23356. ActPayDedc float64 `json:"act_pay_dedc"`
  23357. Age float64 `json:"age"`
  23358. Balc float64 `json:"balc"`
  23359. Certno string `json:"certno"`
  23360. ClrOptins string `json:"clr_optins"`
  23361. ClrType string `json:"clr_type"`
  23362. ClrWay string `json:"clr_way"`
  23363. CvlservFlag string `json:"cvlserv_flag"`
  23364. CvlservPay float64 `json:"cvlserv_pay"`
  23365. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23366. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23367. Gend string `json:"gend"`
  23368. HifesPay float64 `json:"hifes_pay"`
  23369. HifmiPay float64 `json:"hifmi_pay"`
  23370. HifpPay float64 `json:"hifp_pay"`
  23371. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23372. Insutype string `json:"insutype"`
  23373. MafPay float64 `json:"maf_pay"`
  23374. MdtrtCertType string `json:"mdtrt_cert_type"`
  23375. HifobPay float64 `json:"hifob_pay"`
  23376. MdtrtID string `json:"mdtrt_id"`
  23377. MedType string `json:"med_type"`
  23378. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23379. MedinsSetlID string `json:"medins_setl_id"`
  23380. Naty string `json:"naty"`
  23381. OthPay float64 `json:"oth_pay"`
  23382. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23383. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23384. PsnCashPay float64 `json:"psn_cash_pay"`
  23385. PsnCertType string `json:"psn_cert_type"`
  23386. PsnName string `json:"psn_name"`
  23387. PsnNo string `json:"psn_no"`
  23388. PsnPartAmt float64 `json:"psn_part_amt"`
  23389. PsnType string `json:"psn_type"`
  23390. SetlID string `json:"setl_id"`
  23391. SetlTime string `json:"setl_time"`
  23392. } `json:"setlinfo"`
  23393. Setldetail interface{} `json:"setldetail"`
  23394. } `json:"output"`
  23395. RefmsgTime string `json:"refmsg_time"`
  23396. RespondTime string `json:"respond_time"`
  23397. Signtype interface{} `json:"signtype"`
  23398. WarnMsg interface{} `json:"warn_msg"`
  23399. }
  23400. type GZResultSeven10265Two struct {
  23401. Cainfo string `json:"cainfo"`
  23402. ErrMsg string `json:"err_msg"`
  23403. InfRefmsgid string `json:"inf_refmsgid"`
  23404. Infcode int64 `json:"infcode"`
  23405. Output struct {
  23406. Setlinfo struct {
  23407. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23408. AcctPay float64 `json:"acct_pay"`
  23409. ActPayDedc float64 `json:"act_pay_dedc"`
  23410. Age float64 `json:"age"`
  23411. Balc float64 `json:"balc"`
  23412. Certno string `json:"certno"`
  23413. ClrOptins string `json:"clr_optins"`
  23414. ClrType string `json:"clr_type"`
  23415. ClrWay string `json:"clr_way"`
  23416. CvlservFlag string `json:"cvlserv_flag"`
  23417. CvlservPay float64 `json:"cvlserv_pay"`
  23418. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23419. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23420. Gend string `json:"gend"`
  23421. HifesPay float64 `json:"hifes_pay"`
  23422. HifmiPay float64 `json:"hifmi_pay"`
  23423. HifpPay float64 `json:"hifp_pay"`
  23424. HospPartAmt float64 `json:"hosp_part_amt"`
  23425. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23426. Insutype string `json:"insutype"`
  23427. MafPay float64 `json:"maf_pay"`
  23428. MdtrtCertType string `json:"mdtrt_cert_type"`
  23429. HifobPay float64 `json:"hifob_pay"`
  23430. MdtrtID string `json:"mdtrt_id"`
  23431. MedType string `json:"med_type"`
  23432. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23433. MedinsSetlID string `json:"medins_setl_id"`
  23434. Naty string `json:"naty"`
  23435. OthPay float64 `json:"oth_pay"`
  23436. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23437. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23438. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23439. PsnCashPay float64 `json:"psn_cash_pay"`
  23440. PsnCertType string `json:"psn_cert_type"`
  23441. PsnName string `json:"psn_name"`
  23442. PsnNo string `json:"psn_no"`
  23443. PsnPartAmt float64 `json:"psn_part_amt"`
  23444. PsnType string `json:"psn_type"`
  23445. SetlID string `json:"setl_id"`
  23446. SetlTime string `json:"setl_time"`
  23447. } `json:"setlinfo"`
  23448. Setldetail interface{} `json:"setldetail"`
  23449. } `json:"output"`
  23450. RefmsgTime string `json:"refmsg_time"`
  23451. RespondTime string `json:"respond_time"`
  23452. Signtype interface{} `json:"signtype"`
  23453. WarnMsg interface{} `json:"warn_msg"`
  23454. }
  23455. type ResultEight struct {
  23456. Cainfo string `json:"cainfo"`
  23457. ErrMsg string `json:"err_msg"`
  23458. InfRefmsgid string `json:"inf_refmsgid"`
  23459. Infcode int64 `json:"infcode"`
  23460. Output struct {
  23461. Stmtinfo struct {
  23462. SetlOptins string `json:"setl_optins"`
  23463. StmtRslt string `json:"stmt_rslt"`
  23464. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23465. } `json:"stmtinfo"`
  23466. } `json:"output"`
  23467. RefmsgTime string `json:"refmsg_time"`
  23468. RespondTime string `json:"respond_time"`
  23469. Signtype interface{} `json:"signtype"`
  23470. WarnMsg interface{} `json:"warn_msg"`
  23471. }
  23472. type ResultEightFor10188 struct {
  23473. Cainfo string `json:"cainfo"`
  23474. ErrMsg string `json:"err_msg"`
  23475. InfRefmsgid string `json:"inf_refmsgid"`
  23476. Infcode string `json:"infcode"`
  23477. Output struct {
  23478. Stmtinfo struct {
  23479. SetlOptins string `json:"setl_optins"`
  23480. StmtRslt string `json:"stmt_rslt"`
  23481. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23482. } `json:"stmtinfo"`
  23483. } `json:"output"`
  23484. RefmsgTime string `json:"refmsg_time"`
  23485. RespondTime string `json:"respond_time"`
  23486. Signtype interface{} `json:"signtype"`
  23487. WarnMsg interface{} `json:"warn_msg"`
  23488. }
  23489. type ResultNine struct {
  23490. Cainfo string `json:"cainfo"`
  23491. ErrMsg string `json:"err_msg"`
  23492. InfRefmsgid string `json:"inf_refmsgid"`
  23493. Infcode int64 `json:"infcode"`
  23494. Output struct {
  23495. FileQuryNo string `json:"file_qury_no"`
  23496. } `json:"output"`
  23497. RefmsgTime string `json:"refmsg_time"`
  23498. RespondTime string `json:"respond_time"`
  23499. Signtype interface{} `json:"signtype"`
  23500. WarnMsg interface{} `json:"warn_msg"`
  23501. }
  23502. type ResultTen struct {
  23503. Cainfo string `json:"cainfo"`
  23504. ErrMsg string `json:"err_msg"`
  23505. InfRefmsgid string `json:"inf_refmsgid"`
  23506. Infcode int64 `json:"infcode"`
  23507. Output struct {
  23508. Fileinfo struct {
  23509. DldEndtime string `json:"dld_endtime"`
  23510. FileQuryNo string `json:"file_qury_no"`
  23511. Filename string `json:"filename"`
  23512. } `json:"fileinfo"`
  23513. } `json:"output"`
  23514. RefmsgTime string `json:"refmsg_time"`
  23515. RespondTime string `json:"respond_time"`
  23516. Signtype interface{} `json:"signtype"`
  23517. WarnMsg interface{} `json:"warn_msg"`
  23518. }
  23519. type Result5262 struct {
  23520. ErrMsg string `json:"err_msg"`
  23521. InfRefmsgid string `json:"inf_refmsgid"`
  23522. Infcode int64 `json:"infcode"`
  23523. Output struct {
  23524. PageInfo struct {
  23525. Size int `json:"size"`
  23526. RecordCounts int `json:"record_counts"`
  23527. } `json:"page_info"`
  23528. Idetinfo []interface{} `json:"idetinfo"`
  23529. Result []struct {
  23530. SetlID string `json:"setl_id"`
  23531. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23532. MdtrtID string `json:"mdtrt_id"`
  23533. InitSetlID string `json:"init_setl_id,omitempty"`
  23534. PsnNo string `json:"psn_no"`
  23535. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23536. PsnName string `json:"psn_name"`
  23537. PsnCertType string `json:"psn_cert_type"`
  23538. Certno string `json:"certno"`
  23539. Gend string `json:"gend,omitempty"`
  23540. Naty string `json:"naty,omitempty"`
  23541. Brdy string `json:"brdy,omitempty"`
  23542. Age float64 `json:"age,omitempty"`
  23543. Insutype string `json:"insutype,omitempty"`
  23544. PsnType string `json:"psn_type"`
  23545. CvlservFlag string `json:"cvlserv_flag"`
  23546. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23547. SpPsnType string `json:"sp_psn_type,omitempty"`
  23548. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23549. ClctGrde string `json:"clct_grde,omitempty"`
  23550. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23551. NwbFlag string `json:"nwb_flag,omitempty"`
  23552. InsuAdmdvs string `json:"insu_admdvs"`
  23553. EmpNo string `json:"emp_no,omitempty"`
  23554. EmpName string `json:"emp_name,omitempty"`
  23555. EmpType string `json:"emp_type,omitempty"`
  23556. EconType string `json:"econ_type,omitempty"`
  23557. AfilIndu string `json:"afil_indu,omitempty"`
  23558. AfilRlts string `json:"afil_rlts,omitempty"`
  23559. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23560. PayLoc string `json:"pay_loc,omitempty"`
  23561. FixmedinsCode string `json:"fixmedins_code"`
  23562. FixmedinsName string `json:"fixmedins_name"`
  23563. HospLv string `json:"hosp_lv,omitempty"`
  23564. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23565. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23566. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23567. Begndate string `json:"begndate"`
  23568. Enddate string `json:"enddate"`
  23569. SetlTime string `json:"setl_time"`
  23570. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23571. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23572. MedType string `json:"med_type"`
  23573. SetlType string `json:"setl_type,omitempty"`
  23574. ClrType string `json:"clr_type,omitempty"`
  23575. ClrWay string `json:"clr_way,omitempty"`
  23576. PsnSetlway string `json:"psn_setlway,omitempty"`
  23577. ClrOptins string `json:"clr_optins,omitempty"`
  23578. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23579. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23580. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23581. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23582. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23583. DedcStd float64 `json:"dedc_std,omitempty"`
  23584. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23585. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23586. HifpPay float64 `json:"hifp_pay,omitempty"`
  23587. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23588. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23589. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23590. HifesPay float64 `json:"hifes_pay,omitempty"`
  23591. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23592. HifobPay float64 `json:"hifob_pay,omitempty"`
  23593. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23594. MafPay float64 `json:"maf_pay,omitempty"`
  23595. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23596. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23597. PsnPay float64 `json:"psn_pay,omitempty"`
  23598. AcctPay float64 `json:"acct_pay,omitempty"`
  23599. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23600. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23601. Balc float64 `json:"balc,omitempty"`
  23602. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23603. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23604. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23605. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23606. Year string `json:"year,omitempty"`
  23607. DiseNo string `json:"dise_no,omitempty"`
  23608. DiseName string `json:"dise_name,omitempty"`
  23609. Invono string `json:"invono,omitempty"`
  23610. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23611. ValiFlag string `json:"vali_flag,omitempty"`
  23612. Memo string `json:"memo,omitempty"`
  23613. Rid string `json:"rid"`
  23614. UpdtTime string `json:"updt_time,omitempty"`
  23615. CrterID string `json:"crter_id,omitempty"`
  23616. CrterName string `json:"crter_name,omitempty"`
  23617. CrteTime string `json:"crte_time,omitempty"`
  23618. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23619. OpterID string `json:"opter_id,omitempty"`
  23620. OpterName string `json:"opter_name,omitempty"`
  23621. OptTime string `json:"opt_time,omitempty"`
  23622. OptinsNo string `json:"optins_no,omitempty"`
  23623. PoolareaNo string `json:"poolarea_no,omitempty"`
  23624. } `json:"result"`
  23625. } `json:"output"`
  23626. RefmsgTime string `json:"refmsg_time"`
  23627. RespondTime string `json:"respond_time"`
  23628. Signtype interface{} `json:"signtype"`
  23629. WarnInfo interface{} `json:"warn_info"`
  23630. }
  23631. type Result5267 struct {
  23632. ErrMsg string `json:"err_msg"`
  23633. InfRefmsgid string `json:"inf_refmsgid"`
  23634. Infcode int64 `json:"infcode"`
  23635. Output struct {
  23636. PageInfo struct {
  23637. Size int `json:"size"`
  23638. RecordCounts int `json:"record_counts"`
  23639. } `json:"pageinfo"`
  23640. Result []struct {
  23641. SetlID string `json:"setl_id"`
  23642. ClrOptins string `json:"clr_optins"`
  23643. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23644. MdtrtID string `json:"mdtrt_id"`
  23645. InitSetlID string `json:"init_setl_id,omitempty"`
  23646. PsnNo string `json:"psn_no"`
  23647. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23648. PsnName string `json:"psn_name"`
  23649. PsnCertType string `json:"psn_cert_type"`
  23650. Certno string `json:"certno"`
  23651. Gend string `json:"gend,omitempty"`
  23652. Naty string `json:"naty,omitempty"`
  23653. Brdy string `json:"brdy,omitempty"`
  23654. Age float64 `json:"age,omitempty"`
  23655. Insutype string `json:"insutype,omitempty"`
  23656. PsnType string `json:"psn_type"`
  23657. CvlservFlag string `json:"cvlserv_flag"`
  23658. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23659. SpPsnType string `json:"sp_psn_type,omitempty"`
  23660. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23661. ClctGrde string `json:"clct_grde,omitempty"`
  23662. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23663. NwbFlag string `json:"nwb_flag,omitempty"`
  23664. InsuAdmdvs string `json:"insu_admdvs"`
  23665. EmpNo string `json:"emp_no,omitempty"`
  23666. EmpName string `json:"emp_name,omitempty"`
  23667. EmpType string `json:"emp_type,omitempty"`
  23668. EconType string `json:"econ_type,omitempty"`
  23669. AfilIndu string `json:"afil_indu,omitempty"`
  23670. AfilRlts string `json:"afil_rlts,omitempty"`
  23671. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23672. PayLoc string `json:"pay_loc,omitempty"`
  23673. FixmedinsCode string `json:"fixmedins_code"`
  23674. FixmedinsName string `json:"fixmedins_name"`
  23675. HospLv string `json:"hosp_lv,omitempty"`
  23676. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23677. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23678. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23679. Begndate string `json:"begndate,omitempty"`
  23680. Enddate string `json:"enddate,omitempty"`
  23681. SetlTime string `json:"setl_time,omitempty"`
  23682. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23683. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23684. MedType string `json:"med_type"`
  23685. SetlType string `json:"setl_type,omitempty"`
  23686. ClrType string `json:"clr_type,omitempty"`
  23687. ClrWay string `json:"clr_way,omitempty"`
  23688. PsnSetlway string `json:"psn_setlway,omitempty"`
  23689. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23690. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23691. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23692. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23693. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23694. DedcStd float64 `json:"dedc_std,omitempty"`
  23695. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23696. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23697. HifpPay float64 `json:"hifp_pay,omitempty"`
  23698. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23699. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23700. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23701. HifesPay float64 `json:"hifes_pay,omitempty"`
  23702. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23703. HifobPay float64 `json:"hifob_pay,omitempty"`
  23704. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23705. MafPay float64 `json:"maf_pay,omitempty"`
  23706. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23707. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23708. PsnPay float64 `json:"psn_pay,omitempty"`
  23709. AcctPay float64 `json:"acct_pay,omitempty"`
  23710. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23711. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23712. Balc float64 `json:"balc,omitempty"`
  23713. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23714. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23715. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23716. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23717. Year string `json:"year,omitempty"`
  23718. DiseNo string `json:"dise_no,omitempty"`
  23719. DiseName string `json:"dise_name,omitempty"`
  23720. Invono string `json:"invono,omitempty"`
  23721. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23722. Memo string `json:"memo,omitempty"`
  23723. UpdtTime string `json:"updt_time,omitempty"`
  23724. OpterID string `json:"opter_id,omitempty"`
  23725. OpterName string `json:"opter_name,omitempty"`
  23726. OptTime string `json:"opt_time,omitempty"`
  23727. OptinsNo string `json:"optins_no,omitempty"`
  23728. PoolareaNo string `json:"poolarea_no,omitempty"`
  23729. } `json:"result"`
  23730. } `json:"output"`
  23731. RefmsgTime string `json:"refmsg_time"`
  23732. RespondTime string `json:"respond_time"`
  23733. Signtype interface{} `json:"signtype"`
  23734. WarnInfo interface{} `json:"warn_info"`
  23735. }
  23736. // type Autogenerated struct {
  23737. // Output struct {
  23738. // Setlinfo struct {
  23739. // SetlTime string `json:"setl_time"`
  23740. // CvlservPay float64 `json:"cvlserv_pay"`
  23741. // Year string `json:"year"`
  23742. // MedType string `json:"med_type"`
  23743. // PsnPay float64 `json:"psn_pay"`
  23744. // OpterID string `json:"opter_id"`
  23745. // Begndate string `json:"begndate"`
  23746. // FlxempeFlag string `json:"flxempe_flag"`
  23747. // HifmiPay float64 `json:"hifmi_pay"`
  23748. // PsnNo string `json:"psn_no"`
  23749. // ActPayDedc float64 `json:"act_pay_dedc"`
  23750. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23751. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23752. // ClrWay string `json:"clr_way"`
  23753. // OthPay float64 `json:"oth_pay"`
  23754. // Gend string `json:"gend"`
  23755. // MdtrtID string `json:"mdtrt_id"`
  23756. // AcctPay float64 `json:"acct_pay"`
  23757. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23758. // Insutype string `json:"insutype"`
  23759. // Invono interface{} `json:"invono"`
  23760. // Enddate string `json:"enddate"`
  23761. // CashPayamt float64 `json:"cash_payamt"`
  23762. // PsnType string `json:"psn_type"`
  23763. // FixmedinsName string `json:"fixmedins_name"`
  23764. // HifpPay float64 `json:"hifp_pay"`
  23765. // NewFlag interface{} `json:"new_flag"`
  23766. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23767. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23768. // PayLoc string `json:"pay_loc"`
  23769. // ClrType string `json:"clr_type"`
  23770. // RefdSetlFlag string `json:"refd_setl_flag"`
  23771. // CvlservFlag string `json:"cvlserv_flag"`
  23772. // EmpName string `json:"emp_name"`
  23773. // Brdy string `json:"brdy"`
  23774. // Naty string `json:"naty"`
  23775. // Certno string `json:"certno"`
  23776. // DiseCode string `json:"dise_code"`
  23777. // FixmedinsCode string `json:"fixmedins_code"`
  23778. // DedcHospLv string `json:"dedc_hosp_lv"`
  23779. // OpterName string `json:"opter_name"`
  23780. // Balc float64 `json:"balc"`
  23781. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23782. // PsnCertType string `json:"psn_cert_type"`
  23783. // HifobPay float64 `json:"hifob_pay"`
  23784. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23785. // HifesPay float64 `json:"hifes_pay"`
  23786. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23787. // OptTime string `json:"opt_time"`
  23788. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23789. // SetlID string `json:"setl_id"`
  23790. // MafPay float64 `json:"maf_pay"`
  23791. // PsnName string `json:"psn_name"`
  23792. // InsuOptins interface{} `json:"insu_optins"`
  23793. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23794. // ClrOptins string `json:"clr_optins"`
  23795. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23796. // DiseName string `json:"dise_name"`
  23797. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23798. // Age float64 `json:"age"`
  23799. // DtrtCertType string `json:"dtrt_cert_type"`
  23800. // HospLv string `json:"hosp_lv"`
  23801. // } `json:"setlinfo"`
  23802. // Setldetail []struct {
  23803. // FundPayType string `json:"fund_pay_type"`
  23804. // FundPayamt float64 `json:"fund_payamt"`
  23805. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23806. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23807. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23808. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23809. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23810. // } `json:"setldetail"`
  23811. // } `json:"output"`
  23812. // Infcode int `json:"infcode"`
  23813. // WarnMsg interface{} `json:"warn_msg"`
  23814. // Cainfo interface{} `json:"cainfo"`
  23815. // ErrMsg interface{} `json:"err_msg"`
  23816. // RefmsgTime string `json:"refmsg_time"`
  23817. // Signtype interface{} `json:"signtype"`
  23818. // RespondTime string `json:"respond_time"`
  23819. // InfRefmsgid string `json:"inf_refmsgid"`
  23820. // }
  23821. type Result002 struct {
  23822. Cainfo interface{} `json:"cainfo"`
  23823. ErrMsg string `json:"err_msg"`
  23824. InfRefmsgid string `json:"inf_refmsgid"`
  23825. Infcode int64 `json:"infcode"`
  23826. Output struct {
  23827. RxFile string `json:"rx_file"`
  23828. SignDigest string `json:"sign_digest"`
  23829. SignCertSn string `json:"sign_cert_sn"`
  23830. SignCertDn string `json:"sign_cert_dn"`
  23831. } `json:"output"`
  23832. RefmsgTime string `json:"refmsg_time"`
  23833. RespondTime string `json:"respond_time"`
  23834. Signtype interface{} `json:"signtype"`
  23835. WarnMsg interface{} `json:"warn_msg"`
  23836. }
  23837. type AhResult002 struct {
  23838. RxFile string `json:"rxFile"`
  23839. SignDigest string `json:"signDigest"`
  23840. SignCertSn string `json:"signCertSn"`
  23841. SignCertDn string `json:"signCertDn"`
  23842. }
  23843. type Result003 struct {
  23844. Cainfo interface{} `json:"cainfo"`
  23845. ErrMsg string `json:"err_msg"`
  23846. InfRefmsgid string `json:"inf_refmsgid"`
  23847. Infcode int64 `json:"infcode"`
  23848. Output struct {
  23849. HiRxno string `json:"hi_rxno"`
  23850. RxStasCodg string `json:"rx_stas_codg"`
  23851. RxStasName string `json:"rx_stas_name"`
  23852. } `json:"output"`
  23853. RefmsgTime string `json:"refmsg_time"`
  23854. RespondTime string `json:"respond_time"`
  23855. Signtype interface{} `json:"signtype"`
  23856. WarnMsg interface{} `json:"warn_msg"`
  23857. }
  23858. type AHResult003 struct {
  23859. HiRxno string `json:"hiRxno"`
  23860. RxStasCodg string `json:"rxStasCodg"`
  23861. RxStasName string `json:"rxStasName"`
  23862. }
  23863. type ResultEleven struct {
  23864. Cainfo string `json:"cainfo"`
  23865. ErrMsg string `json:"err_msg"`
  23866. InfRefmsgid string `json:"inf_refmsgid"`
  23867. Infcode int64 `json:"infcode"`
  23868. Output struct {
  23869. Setlinfo struct {
  23870. SetlTime string `json:"setl_time"`
  23871. CvlservPay float64 `json:"cvlserv_pay"`
  23872. Year string `json:"year"`
  23873. MedType string `json:"med_type"`
  23874. PsnPay float64 `json:"psn_pay"`
  23875. OpterID string `json:"opter_id"`
  23876. Begndate string `json:"begndate"`
  23877. FlxempeFlag string `json:"flxempe_flag"`
  23878. HifmiPay float64 `json:"hifmi_pay"`
  23879. PsnNo string `json:"psn_no"`
  23880. ActPayDedc float64 `json:"act_pay_dedc"`
  23881. MedinsSetlID interface{} `json:"medins_setl_id"`
  23882. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23883. ClrWay string `json:"clr_way"`
  23884. OthPay float64 `json:"oth_pay"`
  23885. Gend string `json:"gend"`
  23886. MdtrtID string `json:"mdtrt_id"`
  23887. AcctPay float64 `json:"acct_pay"`
  23888. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23889. Insutype string `json:"insutype"`
  23890. Invono interface{} `json:"invono"`
  23891. Enddate string `json:"enddate"`
  23892. CashPayamt float64 `json:"cash_payamt"`
  23893. PsnType string `json:"psn_type"`
  23894. FixmedinsName string `json:"fixmedins_name"`
  23895. HifpPay float64 `json:"hifp_pay"`
  23896. NewFlag interface{} `json:"new_flag"`
  23897. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23898. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23899. PayLoc string `json:"pay_loc"`
  23900. ClrType string `json:"clr_type"`
  23901. RefdSetlFlag string `json:"refd_setl_flag"`
  23902. CvlservFlag string `json:"cvlserv_flag"`
  23903. EmpName string `json:"emp_name"`
  23904. Brdy string `json:"brdy"`
  23905. Naty string `json:"naty"`
  23906. Certno string `json:"certno"`
  23907. DiseCode string `json:"dise_code"`
  23908. FixmedinsCode string `json:"fixmedins_code"`
  23909. DedcHospLv string `json:"dedc_hosp_lv"`
  23910. OpterName string `json:"opter_name"`
  23911. Balc float64 `json:"balc"`
  23912. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23913. PsnCertType string `json:"psn_cert_type"`
  23914. HifobPay float64 `json:"hifob_pay"`
  23915. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23916. HifesPay float64 `json:"hifes_pay"`
  23917. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23918. OptTime string `json:"opt_time"`
  23919. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23920. SetlID string `json:"setl_id"`
  23921. MafPay float64 `json:"maf_pay"`
  23922. PsnName string `json:"psn_name"`
  23923. InsuOptins interface{} `json:"insu_optins"`
  23924. PrefFundPay interface{} `json:"pref_fund_pay"`
  23925. ClrOptins string `json:"clr_optins"`
  23926. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23927. DiseName string `json:"dise_name"`
  23928. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23929. Age float64 `json:"age"`
  23930. DtrtCertType string `json:"dtrt_cert_type"`
  23931. HospLv string `json:"hosp_lv"`
  23932. PsnCashPay float64 `json:"psn_cash_pay"`
  23933. } `json:"setlinfo"`
  23934. } `json:"output"`
  23935. RefmsgTime string `json:"refmsg_time"`
  23936. RespondTime string `json:"respond_time"`
  23937. Signtype interface{} `json:"signtype"`
  23938. WarnMsg interface{} `json:"warn_msg"`
  23939. }
  23940. type ResultElevenah struct {
  23941. Cainfo string `json:"cainfo"`
  23942. ErrMsg string `json:"err_msg"`
  23943. InfRefmsgid string `json:"inf_refmsgid"`
  23944. Infcode int64 `json:"infcode"`
  23945. Output struct {
  23946. Setlinfo struct {
  23947. SetlTime int64 `json:"setl_time"`
  23948. CvlservPay float64 `json:"cvlserv_pay"`
  23949. Year string `json:"year"`
  23950. MedType string `json:"med_type"`
  23951. PsnPay float64 `json:"psn_pay"`
  23952. OpterID string `json:"opter_id"`
  23953. Begndate int64 `json:"begndate"`
  23954. FlxempeFlag string `json:"flxempe_flag"`
  23955. HifmiPay float64 `json:"hifmi_pay"`
  23956. PsnNo string `json:"psn_no"`
  23957. ActPayDedc float64 `json:"act_pay_dedc"`
  23958. MedinsSetlID interface{} `json:"medins_setl_id"`
  23959. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23960. ClrWay string `json:"clr_way"`
  23961. OthPay float64 `json:"oth_pay"`
  23962. Gend string `json:"gend"`
  23963. MdtrtID string `json:"mdtrt_id"`
  23964. AcctPay float64 `json:"acct_pay"`
  23965. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23966. Insutype string `json:"insutype"`
  23967. Invono interface{} `json:"invono"`
  23968. Enddate int64 `json:"enddate"`
  23969. CashPayamt float64 `json:"cash_payamt"`
  23970. PsnType string `json:"psn_type"`
  23971. FixmedinsName string `json:"fixmedins_name"`
  23972. HifpPay float64 `json:"hifp_pay"`
  23973. NewFlag interface{} `json:"new_flag"`
  23974. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23975. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23976. PayLoc string `json:"pay_loc"`
  23977. ClrType string `json:"clr_type"`
  23978. RefdSetlFlag string `json:"refd_setl_flag"`
  23979. CvlservFlag string `json:"cvlserv_flag"`
  23980. EmpName string `json:"emp_name"`
  23981. Brdy int64 `json:"brdy"`
  23982. Naty string `json:"naty"`
  23983. Certno string `json:"certno"`
  23984. DiseCode string `json:"dise_code"`
  23985. FixmedinsCode string `json:"fixmedins_code"`
  23986. DedcHospLv string `json:"dedc_hosp_lv"`
  23987. OpterName string `json:"opter_name"`
  23988. Balc float64 `json:"balc"`
  23989. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23990. PsnCertType string `json:"psn_cert_type"`
  23991. HifobPay float64 `json:"hifob_pay"`
  23992. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23993. HifesPay float64 `json:"hifes_pay"`
  23994. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23995. OptTime int64 `json:"opt_time"`
  23996. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23997. SetlID string `json:"setl_id"`
  23998. MafPay float64 `json:"maf_pay"`
  23999. PsnName string `json:"psn_name"`
  24000. InsuOptins interface{} `json:"insu_optins"`
  24001. PrefFundPay interface{} `json:"pref_fund_pay"`
  24002. ClrOptins string `json:"clr_optins"`
  24003. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24004. DiseName string `json:"dise_name"`
  24005. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24006. Age float64 `json:"age"`
  24007. DtrtCertType string `json:"dtrt_cert_type"`
  24008. HospLv string `json:"hosp_lv"`
  24009. PsnCashPay float64 `json:"psn_cash_pay"`
  24010. } `json:"setlinfo"`
  24011. } `json:"output"`
  24012. RefmsgTime string `json:"refmsg_time"`
  24013. RespondTime string `json:"respond_time"`
  24014. Signtype interface{} `json:"signtype"`
  24015. WarnMsg interface{} `json:"warn_msg"`
  24016. }
  24017. type ResultEleven10265 struct {
  24018. Cainfo string `json:"cainfo"`
  24019. ErrMsg string `json:"err_msg"`
  24020. InfRefmsgid string `json:"inf_refmsgid"`
  24021. Infcode string `json:"infcode"`
  24022. Output struct {
  24023. Setlinfo struct {
  24024. SetlTime string `json:"setl_time"`
  24025. CvlservPay float64 `json:"cvlserv_pay"`
  24026. Year string `json:"year"`
  24027. MedType string `json:"med_type"`
  24028. PsnPay float64 `json:"psn_pay"`
  24029. OpterID string `json:"opter_id"`
  24030. Begndate string `json:"begndate"`
  24031. FlxempeFlag string `json:"flxempe_flag"`
  24032. HifmiPay float64 `json:"hifmi_pay"`
  24033. PsnNo string `json:"psn_no"`
  24034. ActPayDedc float64 `json:"act_pay_dedc"`
  24035. MedinsSetlID interface{} `json:"medins_setl_id"`
  24036. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  24037. ClrWay string `json:"clr_way"`
  24038. OthPay float64 `json:"oth_pay"`
  24039. Gend string `json:"gend"`
  24040. MdtrtID string `json:"mdtrt_id"`
  24041. AcctPay float64 `json:"acct_pay"`
  24042. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24043. Insutype string `json:"insutype"`
  24044. Invono interface{} `json:"invono"`
  24045. Enddate string `json:"enddate"`
  24046. CashPayamt float64 `json:"cash_payamt"`
  24047. PsnType string `json:"psn_type"`
  24048. FixmedinsName string `json:"fixmedins_name"`
  24049. HifpPay float64 `json:"hifp_pay"`
  24050. NewFlag interface{} `json:"new_flag"`
  24051. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24052. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24053. PayLoc string `json:"pay_loc"`
  24054. ClrType string `json:"clr_type"`
  24055. RefdSetlFlag string `json:"refd_setl_flag"`
  24056. CvlservFlag string `json:"cvlserv_flag"`
  24057. EmpName string `json:"emp_name"`
  24058. Brdy string `json:"brdy"`
  24059. Naty string `json:"naty"`
  24060. Certno string `json:"certno"`
  24061. DiseCode string `json:"dise_code"`
  24062. FixmedinsCode string `json:"fixmedins_code"`
  24063. DedcHospLv string `json:"dedc_hosp_lv"`
  24064. OpterName string `json:"opter_name"`
  24065. Balc float64 `json:"balc"`
  24066. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  24067. PsnCertType string `json:"psn_cert_type"`
  24068. HifobPay float64 `json:"hifob_pay"`
  24069. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24070. HifesPay float64 `json:"hifes_pay"`
  24071. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24072. OptTime string `json:"opt_time"`
  24073. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24074. SetlID string `json:"setl_id"`
  24075. MafPay float64 `json:"maf_pay"`
  24076. PsnName string `json:"psn_name"`
  24077. InsuOptins interface{} `json:"insu_optins"`
  24078. PrefFundPay interface{} `json:"pref_fund_pay"`
  24079. ClrOptins string `json:"clr_optins"`
  24080. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24081. DiseName string `json:"dise_name"`
  24082. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24083. Age float64 `json:"age"`
  24084. DtrtCertType string `json:"dtrt_cert_type"`
  24085. HospLv string `json:"hosp_lv"`
  24086. PsnCashPay float64 `json:"psn_cash_pay"`
  24087. } `json:"setlinfo"`
  24088. } `json:"output"`
  24089. RefmsgTime string `json:"refmsg_time"`
  24090. RespondTime string `json:"respond_time"`
  24091. Signtype interface{} `json:"signtype"`
  24092. WarnMsg interface{} `json:"warn_msg"`
  24093. }
  24094. type ResultTwelve struct {
  24095. Cainfo string `json:"cainfo"`
  24096. ErrMsg string `json:"err_msg"`
  24097. InfRefmsgid string `json:"inf_refmsgid"`
  24098. Infcode int64 `json:"infcode"`
  24099. Output struct {
  24100. MdtrtId string `json:"mdtrt_id"`
  24101. ChrgBchno string `json:"chrg_bchno"`
  24102. PsnNo string `json:"psn_no"`
  24103. } `json:"output"`
  24104. RefmsgTime string `json:"refmsg_time"`
  24105. RespondTime string `json:"respond_time"`
  24106. Signtype interface{} `json:"signtype"`
  24107. WarnMsg interface{} `json:"warn_msg"`
  24108. }
  24109. type ResultThirteen struct {
  24110. ErrMsg string `json:"err_msg"`
  24111. InfRefmsgid string `json:"inf_refmsgid"`
  24112. Infcode int64 `json:"infcode"`
  24113. Output struct {
  24114. Result struct {
  24115. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24116. } `json:"result"`
  24117. } `json:"output"`
  24118. RefmsgTime string `json:"refmsg_time"`
  24119. RespondTime string `json:"respond_time"`
  24120. Signtype interface{} `json:"signtype"`
  24121. WarnInfo interface{} `json:"warn_info"`
  24122. }
  24123. type ResultThirteen10265 struct {
  24124. ErrMsg string `json:"err_msg"`
  24125. InfRefmsgid string `json:"inf_refmsgid"`
  24126. Infcode string `json:"infcode"`
  24127. Output struct {
  24128. Result struct {
  24129. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24130. } `json:"result"`
  24131. } `json:"output"`
  24132. RefmsgTime string `json:"refmsg_time"`
  24133. RespondTime string `json:"respond_time"`
  24134. Signtype interface{} `json:"signtype"`
  24135. WarnInfo interface{} `json:"warn_info"`
  24136. }
  24137. type ResultFourteen struct {
  24138. ErrMsg string `json:"err_msg"`
  24139. InfRefmsgid string `json:"inf_refmsgid"`
  24140. Infcode int64 `json:"infcode"`
  24141. Output struct {
  24142. } `json:"output"`
  24143. RefmsgTime string `json:"refmsg_time"`
  24144. RespondTime string `json:"respond_time"`
  24145. Signtype interface{} `json:"signtype"`
  24146. WarnInfo interface{} `json:"warn_info"`
  24147. }
  24148. type ResultCFYLJG001 struct {
  24149. ErrMsg string `json:"err_msg"`
  24150. InfRefmsgid string `json:"inf_refmsgid"`
  24151. Infcode int64 `json:"infcode"`
  24152. Output struct {
  24153. RxTraceCode string `json:"rx_trace_code"`
  24154. HiRxno string `json:"hi_rxno"`
  24155. } `json:"output"`
  24156. RefmsgTime string `json:"refmsg_time"`
  24157. RespondTime string `json:"respond_time"`
  24158. Signtype interface{} `json:"signtype"`
  24159. WarnInfo interface{} `json:"warn_info"`
  24160. }
  24161. type ResultCFYLJG001AH struct {
  24162. RxTraceCode string `json:"rxTraceCode"`
  24163. HiRxno string `json:"hiRxno"`
  24164. }
  24165. type ResultCFYLJG007 struct {
  24166. ErrMsg string `json:"err_msg"`
  24167. InfRefmsgid string `json:"inf_refmsgid"`
  24168. Infcode int64 `json:"infcode"`
  24169. Output struct {
  24170. HiRxno string `json:"hi_rxno"`
  24171. RxStasName string `json:"rx_stas_name"`
  24172. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  24173. Seltdelts []interface{} `json:"seltdelts"`
  24174. RxUsedStasName string `json:"rx_used_stas_name"`
  24175. RxStasCodg string `json:"rx_stas_codg"`
  24176. } `json:"output"`
  24177. RefmsgTime string `json:"refmsg_time"`
  24178. RespondTime string `json:"respond_time"`
  24179. Signtype interface{} `json:"signtype"`
  24180. WarnInfo interface{} `json:"warn_info"`
  24181. }
  24182. type ResultCFYLJG002 struct {
  24183. ErrMsg string `json:"err_msg"`
  24184. InfRefmsgid string `json:"inf_refmsgid"`
  24185. Infcode int64 `json:"infcode"`
  24186. Output struct {
  24187. RxFile string `json:"rx_file"`
  24188. SignDigest string `json:"sign_digest"`
  24189. SignCertSn string `json:"sign_cert_sn"`
  24190. SignCertDn string `json:"sign_cert_dn"`
  24191. } `json:"output"`
  24192. RefmsgTime string `json:"refmsg_time"`
  24193. RespondTime string `json:"respond_time"`
  24194. Signtype interface{} `json:"signtype"`
  24195. WarnInfo interface{} `json:"warn_info"`
  24196. }
  24197. type ResultCFYLJG003 struct {
  24198. ErrMsg string `json:"err_msg"`
  24199. InfRefmsgid string `json:"inf_refmsgid"`
  24200. Infcode int64 `json:"infcode"`
  24201. Output struct {
  24202. HiRxno string `json:"hi_rxno"`
  24203. RxStasCodg string `json:"rx_stas_codg"`
  24204. RxStasName string `json:"rx_stas_name"`
  24205. } `json:"output"`
  24206. RefmsgTime string `json:"refmsg_time"`
  24207. RespondTime string `json:"respond_time"`
  24208. Signtype interface{} `json:"signtype"`
  24209. WarnInfo interface{} `json:"warn_info"`
  24210. }
  24211. type ResultCFYLJG004 struct {
  24212. ErrMsg string `json:"err_msg"`
  24213. InfRefmsgid string `json:"inf_refmsgid"`
  24214. Infcode int64 `json:"infcode"`
  24215. Output struct {
  24216. HiRxno string `json:"hi_rxno"`
  24217. RxStasCodg string `json:"rx_stas_codg"`
  24218. RxStasName string `json:"rx_stas_name"`
  24219. } `json:"output"`
  24220. RefmsgTime string `json:"refmsg_time"`
  24221. RespondTime string `json:"respond_time"`
  24222. Signtype interface{} `json:"signtype"`
  24223. WarnInfo interface{} `json:"warn_info"`
  24224. }
  24225. type ResultCFYLJG008 struct {
  24226. ErrMsg string `json:"err_msg"`
  24227. InfRefmsgid string `json:"inf_refmsgid"`
  24228. Infcode int64 `json:"infcode"`
  24229. Output struct {
  24230. PoolareaNo string `json:"poolareaNo"`
  24231. AdmdvsName string `json:"admdvsName"`
  24232. Count string `json:"count"`
  24233. } `json:"output"`
  24234. RefmsgTime string `json:"refmsg_time"`
  24235. RespondTime string `json:"respond_time"`
  24236. Signtype interface{} `json:"signtype"`
  24237. WarnInfo interface{} `json:"warn_info"`
  24238. }
  24239. type ResultCFYLJG005 struct {
  24240. ErrMsg string `json:"err_msg"`
  24241. InfRefmsgid string `json:"inf_refmsgid"`
  24242. Infcode int64 `json:"infcode"`
  24243. Output struct {
  24244. HiRxNo string `json:"hi_rxno"`
  24245. FixMedinsCode string `json:"fixmedins_code"`
  24246. FixMedinsName string `json:"fixmedins_name"`
  24247. RxStasCodg string `json:"rx_stas_codg"`
  24248. RxStasName string `json:"rx_stas_name"`
  24249. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24250. RxUserdStasName string `json:"rx_userd_stas_name"`
  24251. PrscTime string `json:"prsc_time"`
  24252. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24253. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24254. RxUsedWayName string `json:"rx_used_way_name"`
  24255. RxFrquCodg string `json:"rx_frqu_codg"`
  24256. RxFrquName string `json:"rx_frqu_name"`
  24257. RxDosunt string `json:"rx_dosunt"`
  24258. RxDoscnt float64 `json:"rx_doscnt"`
  24259. RxDrordDscr string `json:"rx_drord_dscr"`
  24260. ValiDays int64 `json:"vali_days"`
  24261. ValiEndTime string `json:"vali_end_time"`
  24262. ReptFlag string `json:"rept_flag"`
  24263. MaxReptCnt int64 `json:"max_rept_cnt"`
  24264. ReptdCnt int64 `json:"reptd_cnt"`
  24265. MinInrvDays int64 `json:"min_inrv_days"`
  24266. RxTypeCode string `json:"rx_type_code"`
  24267. RxTypeName string `json:"rx_type_name"`
  24268. LongRxFlag string `json:"long_rx_flag"`
  24269. RxDetlList []struct {
  24270. MedListCodg string `json:"med_list_codg"`
  24271. MedinsListCodg string `json:"medins_list_codg"`
  24272. HospPrepFlag string `json:"hosp_prep_flag"`
  24273. RxItemTypeCode string `json:"rx_item_type_code"`
  24274. RxItemTypeName string `json:"rx_item_type_name"`
  24275. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24276. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24277. TcmHerbFoote string `json:"tcmherb_foote"`
  24278. MednTypeCode string `json:"medn_type_code"`
  24279. MednTypeName string `json:"medn_type_name"`
  24280. MainMedcFlag string `json:"main_medc_flag"`
  24281. UrgtFlag string `json:"urgt_flag"`
  24282. BasMednFlag string `json:"bas_medn_flag"`
  24283. ImpDrugFlag string `json:"imp_drug_flag"`
  24284. ProdBarc string `json:"prod_barc"`
  24285. DrugProdname string `json:"drug_prodname"`
  24286. GennameCodg string `json:"genname_codg"`
  24287. DrugGenname string `json:"drug_genname"`
  24288. DrugDosform string `json:"drug_dosform"`
  24289. DrugSpec string `json:"drug_spec"`
  24290. PrdrName string `json:"prdr_name"`
  24291. MedcWayCodg string `json:"medc_way_codg"`
  24292. MedcWayDscr string `json:"medc_way_dscr"`
  24293. MedcBegntime string `json:"medc_begntime"`
  24294. MedcEndtime string `json:"medc_endtime"`
  24295. MedcDays float64 `json:"medc_days"`
  24296. DrugPric float64 `json:"drug_pric"`
  24297. DrugSumamt float64 `json:"drug_sumamt"`
  24298. DrugCnt float64 `json:"drug_cnt"`
  24299. DrugDosunt string `json:"drug_dosunt"`
  24300. SinDoscnt float64 `json:"sin_doscnt"`
  24301. SinDosunt string `json:"sin_dosunt"`
  24302. UsedFrquCodg string `json:"used_frqu_codg"`
  24303. UsedFrquName string `json:"used_frqu_name"`
  24304. DrugTotlcnt string `json:"drug_totlcnt"`
  24305. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24306. DiseCodg string `json:"dise_codg"`
  24307. HospApprFlag string `json:"hosp_appr_flag"`
  24308. } `json:"rx_detl_list"`
  24309. RxOtpinfo struct {
  24310. MedType string `json:"med_type"`
  24311. IptOtpNo string `json:"ipt_otp_no"`
  24312. OtpIptFlag string `json:"otp_ipt_flag"`
  24313. PatnName string `json:"patn_name"`
  24314. PatnAge float64 `json:"patn_age"`
  24315. PatnHgt float64 `json:"patn_hgt"`
  24316. PatnWt float64 `json:"patn_wt"`
  24317. Gend string `json:"gend"`
  24318. GesoVal float64 `json:"geso_val"`
  24319. NwbFlag string `json:"nwb_flag"`
  24320. NwbAge string `json:"nwb_age"`
  24321. SuckPrdFlag string `json:"suck_prd_flag"`
  24322. AlgsHis string `json:"algs_his"`
  24323. Insutype string `json:"insutype"`
  24324. PrscDeptName string `json:"prsc_dept_name"`
  24325. PrscDrName string `json:"prsc_dr_name"`
  24326. PharName string `json:"phar_name"`
  24327. PharChkTime string `json:"phar_chk_time"`
  24328. MdtrtTime string `json:"mdtrt_time"`
  24329. DiseCodg string `json:"dise_codg"`
  24330. DiseName string `json:"dise_name"`
  24331. SpDiseFlag string `json:"sp_dise_flag"`
  24332. MaindiagCode string `json:"maindiag_code"`
  24333. MaindiagName string `json:"maindiag_name"`
  24334. DiseCondDscr string `json:"dise_cond_dscr"`
  24335. FstdiagFlag string `json:"fstdiag_flag"`
  24336. } `json:"rx_otpinfo"`
  24337. RxDiseList []struct {
  24338. DiagType string `json:"diag_type"`
  24339. MaindiagFlag string `json:"maindiag_flag"`
  24340. DiagSrtNo string `json:"diag_srt_no"`
  24341. DiagCode string `json:"diag_code"`
  24342. DiagName string `json:"diag_name"`
  24343. DiagDept string `json:"diag_dept"`
  24344. DiagDrNo string `json:"diag_dr_no"`
  24345. DiagDrName string `json:"diag_dr_name"`
  24346. DiagTime string `json:"diag_time"`
  24347. TcmDiseCode string `json:"tcm_dise_code"`
  24348. TcmDiseName string `json:"tcm_dise_name"`
  24349. TcmSympCode string `json:"tcmsymp_code"`
  24350. TcmSymp string `json:"tcmsymp"`
  24351. } `json:"rx_dise_list"`
  24352. } `json:"output"`
  24353. RefmsgTime string `json:"refmsg_time"`
  24354. RespondTime string `json:"respond_time"`
  24355. Signtype interface{} `json:"signtype"`
  24356. WarnInfo interface{} `json:"warn_info"`
  24357. }
  24358. type ResultCFYLJG006 struct {
  24359. ErrMsg string `json:"err_msg"`
  24360. InfRefmsgid string `json:"inf_refmsgid"`
  24361. Infcode int64 `json:"infcode"`
  24362. Output struct {
  24363. HiRxNo string `json:"hi_rxno"`
  24364. PharCode string `json:"phar_code"`
  24365. PharName string `json:"phar_name"`
  24366. RxChkOpnn string `json:"rx_chk_opnn"`
  24367. RxChkTime string `json:"rx_chk_time"`
  24368. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24369. RxChkStasName string `json:"rx_chk_stas_name"`
  24370. RxStasCodg string `json:"rx_stas_codg"`
  24371. RxStasName string `json:"rx_stas_name"`
  24372. } `json:"output"`
  24373. RefmsgTime string `json:"refmsg_time"`
  24374. RespondTime string `json:"respond_time"`
  24375. Signtype interface{} `json:"signtype"`
  24376. WarnInfo interface{} `json:"warn_info"`
  24377. }
  24378. type ResultFourteen10265 struct {
  24379. ErrMsg string `json:"err_msg"`
  24380. InfRefmsgid string `json:"inf_refmsgid"`
  24381. Infcode string `json:"infcode"`
  24382. Output struct {
  24383. } `json:"output"`
  24384. RefmsgTime string `json:"refmsg_time"`
  24385. RespondTime string `json:"respond_time"`
  24386. Signtype interface{} `json:"signtype"`
  24387. WarnInfo interface{} `json:"warn_info"`
  24388. }
  24389. type ResultSixteen struct {
  24390. Cainfo string `json:"cainfo"`
  24391. ErrMsg string `json:"err_msg"`
  24392. InfRefmsgid string `json:"inf_refmsgid"`
  24393. Infcode int64 `json:"infcode"`
  24394. Output struct {
  24395. Setlinfo struct {
  24396. MdtrtID string `json:"mdtrt_id"`
  24397. SetlID string `json:"setl_id"`
  24398. ClrOptins string `json:"clr_optins"`
  24399. SetlTime string `json:"setl_time"`
  24400. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24401. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24402. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24403. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24404. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24405. ActPayDedc float64 `json:"act_pay_dedc"`
  24406. HifpPay float64 `json:"hifp_pay"`
  24407. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24408. Lfpay float64 `json:"selfpay"`
  24409. CvlservPay float64 `json:"cvlserv_pay"`
  24410. HifesPay float64 `json:"hifes_pay"`
  24411. HifmiPay float64 `json:"hifmi_pay"`
  24412. HifobPay float64 `json:"hifob_pay"`
  24413. MafPay float64 `json:"maf_pay"`
  24414. OthPay float64 `json:"oth_pay"`
  24415. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24416. PsnPartAmt float64 `json:"psn_part_amt"`
  24417. AcctPay float64 `json:"acct_pay"`
  24418. Balc float64 `json:"balc"`
  24419. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24420. HospPartAmt float64 `json:"hosp_part_amt"`
  24421. MedinsSetlID string `json:"medins_setl_id"`
  24422. PdnCashPay string `json:"pdn_cash_pay"`
  24423. } `json:"setlinfo"`
  24424. } `json:"output"`
  24425. RefmsgTime string `json:"refmsg_time"`
  24426. RespondTime string `json:"respond_time"`
  24427. Signtype interface{} `json:"signtype"`
  24428. WarnMsg interface{} `json:"warn_msg"`
  24429. }
  24430. type ResultSixteen10265 struct {
  24431. Cainfo string `json:"cainfo"`
  24432. ErrMsg string `json:"err_msg"`
  24433. InfRefmsgid string `json:"inf_refmsgid"`
  24434. Infcode string `json:"infcode"`
  24435. Output struct {
  24436. Setlinfo struct {
  24437. MdtrtID string `json:"mdtrt_id"`
  24438. SetlID string `json:"setl_id"`
  24439. ClrOptins string `json:"clr_optins"`
  24440. SetlTime string `json:"setl_time"`
  24441. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24442. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24443. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24444. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24445. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24446. ActPayDedc float64 `json:"act_pay_dedc"`
  24447. HifpPay float64 `json:"hifp_pay"`
  24448. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24449. Lfpay float64 `json:"selfpay"`
  24450. CvlservPay float64 `json:"cvlserv_pay"`
  24451. HifesPay float64 `json:"hifes_pay"`
  24452. HifmiPay float64 `json:"hifmi_pay"`
  24453. HifobPay float64 `json:"hifob_pay"`
  24454. MafPay float64 `json:"maf_pay"`
  24455. OthPay float64 `json:"oth_pay"`
  24456. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24457. PsnPartAmt float64 `json:"psn_part_amt"`
  24458. AcctPay float64 `json:"acct_pay"`
  24459. Balc float64 `json:"balc"`
  24460. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24461. HospPartAmt float64 `json:"hosp_part_amt"`
  24462. MedinsSetlID string `json:"medins_setl_id"`
  24463. PdnCashPay string `json:"pdn_cash_pay"`
  24464. } `json:"setlinfo"`
  24465. } `json:"output"`
  24466. RefmsgTime string `json:"refmsg_time"`
  24467. RespondTime string `json:"respond_time"`
  24468. Signtype interface{} `json:"signtype"`
  24469. WarnMsg interface{} `json:"warn_msg"`
  24470. }
  24471. type ResultSixteen10265Two struct {
  24472. Cainfo string `json:"cainfo"`
  24473. ErrMsg string `json:"err_msg"`
  24474. InfRefmsgid string `json:"inf_refmsgid"`
  24475. Infcode string `json:"infcode"`
  24476. Output struct {
  24477. Setlinfo interface{} `json:"setlinfo"`
  24478. } `json:"output"`
  24479. RefmsgTime string `json:"refmsg_time"`
  24480. RespondTime string `json:"respond_time"`
  24481. Signtype interface{} `json:"signtype"`
  24482. WarnMsg interface{} `json:"warn_msg"`
  24483. }
  24484. type ResultgzSixteen10265Two struct {
  24485. Cainfo string `json:"cainfo"`
  24486. ErrMsg string `json:"err_msg"`
  24487. InfRefmsgid string `json:"inf_refmsgid"`
  24488. Infcode int64 `json:"infcode"`
  24489. Output struct {
  24490. Setlinfo interface{} `json:"setlinfo"`
  24491. } `json:"output"`
  24492. RefmsgTime string `json:"refmsg_time"`
  24493. RespondTime string `json:"respond_time"`
  24494. Signtype interface{} `json:"signtype"`
  24495. WarnMsg interface{} `json:"warn_msg"`
  24496. }
  24497. type ResultSeventeen struct {
  24498. ErrMsg string `json:"err_msg"`
  24499. InfRefmsgid string `json:"inf_refmsgid"`
  24500. Infcode int64 `json:"infcode"`
  24501. Output struct {
  24502. SetlListId string `json:"setl_list_id"`
  24503. } `json:"output"`
  24504. RefmsgTime string `json:"refmsg_time"`
  24505. RespondTime string `json:"respond_time"`
  24506. Signtype string `json:"signtype"`
  24507. WarnInfo string `json:"warn_info"`
  24508. }
  24509. type ResultSeventeenOther struct {
  24510. ErrMsg string `json:"err_msg"`
  24511. InfRefmsgid string `json:"inf_refmsgid"`
  24512. Infcode string `json:"infcode"`
  24513. Output struct {
  24514. SetlListId string `json:"setl_list_id"`
  24515. } `json:"output"`
  24516. RefmsgTime string `json:"refmsg_time"`
  24517. RespondTime string `json:"respond_time"`
  24518. Signtype string `json:"signtype"`
  24519. WarnInfo string `json:"warn_info"`
  24520. }
  24521. type Result90991 struct {
  24522. ErrMsg string `json:"err_msg"`
  24523. InfRefmsgid string `json:"inf_refmsgid"`
  24524. Infcode int64 `json:"infcode"`
  24525. Output struct {
  24526. Result struct {
  24527. PsnNo string `json:"psn_no"`
  24528. CardStat string `json:"card_stat"`
  24529. Certno string `json:"certno"`
  24530. PsnName string `json:"psn_name"`
  24531. CheckStat string `json:"check_stat"`
  24532. SscnoCheckStat string `json:"sscno_check_stat"`
  24533. } `json:"result"`
  24534. } `json:"output"`
  24535. RefmsgTime string `json:"refmsg_time"`
  24536. RespondTime string `json:"respond_time"`
  24537. Signtype interface{} `json:"signtype"`
  24538. WarnInfo interface{} `json:"warn_info"`
  24539. }
  24540. type Result90100 struct {
  24541. ErrMsg string `json:"err_msg"`
  24542. InfRefmsgid string `json:"inf_refmsgid"`
  24543. Infcode int64 `json:"infcode"`
  24544. Output struct {
  24545. PoolareaNo string `json:"poolarea_no"`
  24546. PoolareaNoName string `json:"poolarea_no_name"`
  24547. Insutype string `json:"insutype"`
  24548. InsutypeName string `json:"insutype_name"`
  24549. ClctType string `json:"clct_type"`
  24550. ClctTypeName string `json:"clct_type_name"`
  24551. ClctFlag string `json:"clct_flag"`
  24552. ClctFlagName string `json:"clct_flag_name"`
  24553. AccrymBegn string `json:"accrym_begn"`
  24554. AccrymEnd string `json:"accrym_end"`
  24555. ClctTime string `json:"clct_time"`
  24556. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24557. } `json:"output"`
  24558. RefmsgTime string `json:"refmsg_time"`
  24559. RespondTime string `json:"respond_time"`
  24560. Signtype interface{} `json:"signtype"`
  24561. WarnInfo interface{} `json:"warn_info"`
  24562. }
  24563. type Custom struct {
  24564. DetItemFeeSumamt string
  24565. Cut string
  24566. FeedetlSn string
  24567. Price string
  24568. MedListCodg string
  24569. Type int64
  24570. AdviceId int64
  24571. ProjectId int64
  24572. ItemId int64
  24573. }
  24574. type Result5301 struct {
  24575. ErrMsg string `json:"err_msg"`
  24576. InfRefmsgid string `json:"inf_refmsgid"`
  24577. Infcode int64 `json:"infcode"`
  24578. Output struct {
  24579. Result []struct {
  24580. OpspDiseCode string `json:"opsp_dise_code"`
  24581. OpspDiseName string `json:"opsp_dise_name"`
  24582. Begndate string `json:"begndate"`
  24583. Enddate string `json:"enddate"`
  24584. } `json:"feedetail"`
  24585. } `json:"output"`
  24586. RefmsgTime string `json:"refmsg_time"`
  24587. RespondTime string `json:"respond_time"`
  24588. Signtype interface{} `json:"signtype"`
  24589. WarnInfo interface{} `json:"warn_info"`
  24590. }
  24591. type Result5301For10265 struct {
  24592. ErrMsg string `json:"err_msg"`
  24593. InfRefmsgid string `json:"inf_refmsgid"`
  24594. Infcode string `json:"infcode"`
  24595. Output struct {
  24596. Result []struct {
  24597. OpspDiseCode string `json:"opsp_dise_code"`
  24598. OpspDiseName string `json:"opsp_dise_name"`
  24599. Begndate string `json:"begndate"`
  24600. Enddate string `json:"enddate"`
  24601. } `json:"feedetail"`
  24602. } `json:"output"`
  24603. RefmsgTime string `json:"refmsg_time"`
  24604. RespondTime string `json:"respond_time"`
  24605. Signtype interface{} `json:"signtype"`
  24606. WarnInfo interface{} `json:"warn_info"`
  24607. }
  24608. //获取个人信息----挂号-----上传就诊信息
  24609. func (c *HisApiController) GetRegisterInfo() {
  24610. id, _ := c.GetInt64("id")
  24611. record_time := c.GetString("record_time")
  24612. settlementValue, _ := c.GetInt64("settlement_value")
  24613. medical_insurance_card := c.GetString("medical_insurance_card")
  24614. name := c.GetString("name")
  24615. id_card_type, _ := c.GetInt64("id_card_type")
  24616. certificates, _ := c.GetInt64("certificates")
  24617. medical_care, _ := c.GetInt64("medical_care")
  24618. birthday := c.GetString("birthday")
  24619. id_card := c.GetString("id_card")
  24620. register_type, _ := c.GetInt64("register")
  24621. doctor, _ := c.GetInt64("doctor")
  24622. department, _ := c.GetInt64("department")
  24623. gender, _ := c.GetInt64("sex")
  24624. registration_fee, _ := c.GetFloat("registration_fee")
  24625. medical_expenses, _ := c.GetFloat("medical_expenses")
  24626. social_type, _ := c.GetInt64("social_type")
  24627. admin_user_id, _ := c.GetInt64("admin_user_id")
  24628. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24629. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24630. mdtrt_type := c.GetString("mdtrt_type")
  24631. if id_card_type == 5 {
  24632. id_card_type = 4
  24633. }
  24634. timeLayout := "2006-01-02"
  24635. loc, _ := time.LoadLocation("Local")
  24636. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24637. birthUnix := birthdays.Unix()
  24638. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24639. if err != nil {
  24640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24641. return
  24642. }
  24643. recordDateTime := theTime.Unix()
  24644. adminInfo := c.GetAdminUserInfo()
  24645. var patient service.Patients
  24646. if id == 0 {
  24647. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24648. } else {
  24649. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24650. }
  24651. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24652. if patientPrescription.ID == 0 {
  24653. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24654. }
  24655. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24656. if patient.ID == 0 {
  24657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24658. return
  24659. }
  24660. if len(patient.IdCardNo) == 0 {
  24661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24662. return
  24663. }
  24664. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24665. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24666. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24667. //就诊结算未完成,不能进行二次挂号
  24668. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24669. if len(his) >= 1 {
  24670. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24671. if len(his) >= 1 && order.ID == 0 {
  24672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24673. return
  24674. }
  24675. }
  24676. var aaaa string
  24677. //var register_log string
  24678. if config.IsOpen == 1 {
  24679. var res ResultTwo
  24680. var res10265 ResultTwo10265
  24681. var PsnNo string
  24682. var PsnCertType string
  24683. var Certno string
  24684. var PsnName string
  24685. var Gend string
  24686. var Naty string
  24687. var Brdy string
  24688. var Age float64
  24689. var infoStr string
  24690. var idetinfoStr string
  24691. var infocode int64
  24692. var verify_number string
  24693. fmt.Println(verify_number)
  24694. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24695. psn_info, _ := service.GetPsnByPatientId(id)
  24696. PsnNo = psn_info.PsnNo
  24697. PsnCertType = psn_info.PsnCertType
  24698. Certno = psn_info.Certno
  24699. PsnName = psn_info.PsnName
  24700. Gend = psn_info.Gend
  24701. Naty = psn_info.Naty
  24702. Brdy = psn_info.Brdy
  24703. Age = psn_info.Age
  24704. infoStr = psn_info.Insuinfo
  24705. idetinfoStr = psn_info.Idetinfo
  24706. infocode = 0
  24707. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24708. psn_info, _ := service.GetPsnByPatientId(id)
  24709. PsnNo = psn_info.PsnNo
  24710. PsnCertType = psn_info.PsnCertType
  24711. Certno = psn_info.Certno
  24712. PsnName = psn_info.PsnName
  24713. Gend = psn_info.Gend
  24714. Naty = psn_info.Naty
  24715. Brdy = psn_info.Brdy
  24716. Age = psn_info.Age
  24717. infoStr = psn_info.Insuinfo
  24718. idetinfoStr = psn_info.Idetinfo
  24719. infocode = 0
  24720. verify_number = psn_info.VerifyNumber
  24721. } else if miConfig.MdtrtareaAdmvs == "150404" {
  24722. if id_card_type == 2 {
  24723. //请求内网数据
  24724. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24725. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24726. "&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
  24727. resp, requestErr := http.Get(api)
  24728. if requestErr != nil {
  24729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24730. return
  24731. }
  24732. body, ioErr := ioutil.ReadAll(resp.Body)
  24733. if ioErr != nil {
  24734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24736. return
  24737. }
  24738. var respJSON map[string]interface{}
  24739. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24742. return
  24743. }
  24744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24745. result_byte, _ := json.Marshal(respJSON)
  24746. result := string(result_byte)
  24747. var dat map[string]interface{}
  24748. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24749. fmt.Println(dat)
  24750. } else {
  24751. fmt.Println(err)
  24752. }
  24753. userJSONBytes, _ := json.Marshal(dat)
  24754. var res ResultTwo
  24755. var resTwo10265 ResultTwo10265
  24756. if miConfig.Code == "H15049901371" {
  24757. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24758. utils.ErrorLog("解析失败:%v", err)
  24759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24760. return
  24761. }
  24762. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24763. res.Infcode = Infcode
  24764. res.ErrMsg = resTwo10265.ErrMsg
  24765. res.Output = resTwo10265.Output
  24766. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24767. res.RespondTime = resTwo10265.RespondTime
  24768. res.WarnInfo = resTwo10265.WarnInfo
  24769. } else {
  24770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24771. utils.ErrorLog("解析失败:%v", err)
  24772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24773. return
  24774. }
  24775. }
  24776. //var insutypes []string
  24777. //var insutype string
  24778. //var is390 int = 0
  24779. //var is310 int = 0
  24780. //for _, item := range res.Output.Iinfo {
  24781. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24782. // insutypes = append(insutypes, item.Insutype)
  24783. // }
  24784. //}
  24785. //if len(insutypes) == 1 {
  24786. // insutype = insutypes[0]
  24787. //} else {
  24788. // for _, i := range insutypes {
  24789. // if i == "390" {
  24790. // is390 = 1
  24791. // }
  24792. //
  24793. // if i == "310" {
  24794. // is310 = 1
  24795. // }
  24796. // }
  24797. //}
  24798. //if is390 == 1 {
  24799. // insutype = "390"
  24800. //}
  24801. //if is310 == 1 {
  24802. // insutype = "310"
  24803. //}
  24804. //if len(insutypes) == 0 {
  24805. // insutype = "310"
  24806. //}
  24807. PsnNo = res.Output.Baseinfo.PsnNo
  24808. PsnCertType = res.Output.Baseinfo.PsnCertType
  24809. Certno = res.Output.Baseinfo.Certno
  24810. PsnName = res.Output.Baseinfo.PsnName
  24811. Gend = res.Output.Baseinfo.Gend
  24812. Naty = res.Output.Baseinfo.Naty
  24813. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24814. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24815. infoStr = string(Iinfos)
  24816. idetinfoStr = string(Idetinfos)
  24817. infocode = res.Infcode
  24818. //infocode = 0
  24819. //verify_number = psn_info.VerifyNumber
  24820. } else {
  24821. psn_info, _ := service.GetPsnByPatientId(id)
  24822. PsnNo = psn_info.PsnNo
  24823. PsnCertType = psn_info.PsnCertType
  24824. Certno = psn_info.Certno
  24825. PsnName = psn_info.PsnName
  24826. Gend = psn_info.Gend
  24827. Naty = psn_info.Naty
  24828. Brdy = psn_info.Brdy
  24829. Age = psn_info.Age
  24830. infoStr = psn_info.Insuinfo
  24831. idetinfoStr = psn_info.Idetinfo
  24832. infocode = 0
  24833. verify_number = psn_info.VerifyNumber
  24834. }
  24835. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24836. if id_card_type == 1 {
  24837. psn_info, _ := service.GetPsnByPatientId(id)
  24838. PsnNo = psn_info.PsnNo
  24839. PsnCertType = psn_info.PsnCertType
  24840. Certno = psn_info.Certno
  24841. PsnName = psn_info.PsnName
  24842. Gend = psn_info.Gend
  24843. Naty = psn_info.Naty
  24844. Brdy = psn_info.Brdy
  24845. Age = psn_info.Age
  24846. infoStr = psn_info.Insuinfo
  24847. idetinfoStr = psn_info.Idetinfo
  24848. infocode = 0
  24849. verify_number = psn_info.VerifyNumber
  24850. } else if id_card_type == 2 {
  24851. 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)
  24852. fmt.Println(errMsgLog)
  24853. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24854. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24855. utils.ErrorLog("解析失败:%v", err)
  24856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24857. return
  24858. }
  24859. PsnNo = res.Output.Baseinfo.PsnNo
  24860. PsnCertType = res.Output.Baseinfo.PsnCertType
  24861. Certno = res.Output.Baseinfo.Certno
  24862. PsnName = res.Output.Baseinfo.PsnName
  24863. Gend = res.Output.Baseinfo.Gend
  24864. Naty = res.Output.Baseinfo.Naty
  24865. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24866. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24867. infoStr = string(Iinfos)
  24868. idetinfoStr = string(Idetinfos)
  24869. infocode = res.Infcode
  24870. }
  24871. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24872. if id_card_type == 1 {
  24873. psn_info, _ := service.GetPsnByPatientId(id)
  24874. PsnNo = psn_info.PsnNo
  24875. PsnCertType = psn_info.PsnCertType
  24876. Certno = psn_info.Certno
  24877. PsnName = psn_info.PsnName
  24878. Gend = psn_info.Gend
  24879. Naty = psn_info.Naty
  24880. Brdy = psn_info.Brdy
  24881. Age = psn_info.Age
  24882. infoStr = psn_info.Insuinfo
  24883. idetinfoStr = psn_info.Idetinfo
  24884. infocode = 0
  24885. verify_number = psn_info.VerifyNumber
  24886. } else if id_card_type == 2 {
  24887. 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, "")
  24888. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24890. utils.ErrorLog("解析失败:%v", err)
  24891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24892. return
  24893. }
  24894. PsnNo = res.Output.Baseinfo.PsnNo
  24895. PsnCertType = res.Output.Baseinfo.PsnCertType
  24896. Certno = res.Output.Baseinfo.Certno
  24897. PsnName = res.Output.Baseinfo.PsnName
  24898. Gend = res.Output.Baseinfo.Gend
  24899. Naty = res.Output.Baseinfo.Naty
  24900. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24901. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24902. infoStr = string(Iinfos)
  24903. idetinfoStr = string(Idetinfos)
  24904. infocode = res.Infcode
  24905. } else {
  24906. psn_info, _ := service.GetPsnByPatientId(id)
  24907. PsnNo = psn_info.PsnNo
  24908. PsnCertType = psn_info.PsnCertType
  24909. Certno = psn_info.Certno
  24910. PsnName = psn_info.PsnName
  24911. Gend = psn_info.Gend
  24912. Naty = psn_info.Naty
  24913. Brdy = psn_info.Brdy
  24914. Age = psn_info.Age
  24915. infoStr = psn_info.Insuinfo
  24916. idetinfoStr = psn_info.Idetinfo
  24917. infocode = 0
  24918. verify_number = psn_info.VerifyNumber
  24919. }
  24920. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24921. if id_card_type == 1 {
  24922. psn_info, _ := service.GetPsnByPatientId(id)
  24923. PsnNo = psn_info.PsnNo
  24924. PsnCertType = psn_info.PsnCertType
  24925. Certno = psn_info.Certno
  24926. PsnName = psn_info.PsnName
  24927. Gend = psn_info.Gend
  24928. Naty = psn_info.Naty
  24929. Brdy = psn_info.Brdy
  24930. Age = psn_info.Age
  24931. infoStr = psn_info.Insuinfo
  24932. idetinfoStr = psn_info.Idetinfo
  24933. infocode = 0
  24934. verify_number = psn_info.VerifyNumber
  24935. } else if id_card_type == 2 {
  24936. psn_info, _ := service.GetPsnByPatientId(id)
  24937. PsnNo = psn_info.PsnNo
  24938. PsnCertType = psn_info.PsnCertType
  24939. Certno = psn_info.Certno
  24940. PsnName = psn_info.PsnName
  24941. Gend = psn_info.Gend
  24942. Naty = psn_info.Naty
  24943. Brdy = psn_info.Brdy
  24944. Age = psn_info.Age
  24945. infoStr = psn_info.Insuinfo
  24946. idetinfoStr = psn_info.Idetinfo
  24947. infocode = 0
  24948. verify_number = psn_info.VerifyNumber
  24949. } else {
  24950. psn_info, _ := service.GetPsnByPatientId(id)
  24951. PsnNo = psn_info.PsnNo
  24952. PsnCertType = psn_info.PsnCertType
  24953. Certno = psn_info.Certno
  24954. PsnName = psn_info.PsnName
  24955. Gend = psn_info.Gend
  24956. Naty = psn_info.Naty
  24957. Brdy = psn_info.Brdy
  24958. Age = psn_info.Age
  24959. infoStr = psn_info.Insuinfo
  24960. idetinfoStr = psn_info.Idetinfo
  24961. infocode = 0
  24962. verify_number = psn_info.VerifyNumber
  24963. }
  24964. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24965. if id_card_type == 1 {
  24966. psn_info, _ := service.GetPsnByPatientId(id)
  24967. PsnNo = psn_info.PsnNo
  24968. PsnCertType = psn_info.PsnCertType
  24969. Certno = psn_info.Certno
  24970. PsnName = psn_info.PsnName
  24971. Gend = psn_info.Gend
  24972. Naty = psn_info.Naty
  24973. Brdy = psn_info.Brdy
  24974. Age = psn_info.Age
  24975. infoStr = psn_info.Insuinfo
  24976. idetinfoStr = psn_info.Idetinfo
  24977. infocode = 0
  24978. verify_number = psn_info.VerifyNumber
  24979. } else if id_card_type == 2 {
  24980. psn_info, _ := service.GetPsnByPatientId(id)
  24981. PsnNo = psn_info.PsnNo
  24982. PsnCertType = psn_info.PsnCertType
  24983. Certno = psn_info.Certno
  24984. PsnName = psn_info.PsnName
  24985. Gend = psn_info.Gend
  24986. Naty = psn_info.Naty
  24987. Brdy = psn_info.Brdy
  24988. Age = psn_info.Age
  24989. infoStr = psn_info.Insuinfo
  24990. idetinfoStr = psn_info.Idetinfo
  24991. infocode = 0
  24992. verify_number = psn_info.VerifyNumber
  24993. } else {
  24994. psn_info, _ := service.GetPsnByPatientId(id)
  24995. PsnNo = psn_info.PsnNo
  24996. PsnCertType = psn_info.PsnCertType
  24997. Certno = psn_info.Certno
  24998. PsnName = psn_info.PsnName
  24999. Gend = psn_info.Gend
  25000. Naty = psn_info.Naty
  25001. Brdy = psn_info.Brdy
  25002. Age = psn_info.Age
  25003. infoStr = psn_info.Insuinfo
  25004. idetinfoStr = psn_info.Idetinfo
  25005. infocode = 0
  25006. verify_number = psn_info.VerifyNumber
  25007. }
  25008. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  25009. psn_info, _ := service.GetPsnByPatientId(id)
  25010. PsnNo = psn_info.PsnNo
  25011. PsnCertType = psn_info.PsnCertType
  25012. Certno = psn_info.Certno
  25013. PsnName = psn_info.PsnName
  25014. Gend = psn_info.Gend
  25015. Naty = psn_info.Naty
  25016. Brdy = psn_info.Brdy
  25017. Age = psn_info.Age
  25018. infoStr = psn_info.Insuinfo
  25019. idetinfoStr = psn_info.Idetinfo
  25020. infocode = 0
  25021. verify_number = psn_info.VerifyNumber
  25022. idetinfoStr = psn_info.Idetinfo
  25023. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25024. if id_card_type == 1 {
  25025. psn_info, _ := service.GetPsnByPatientId(id)
  25026. PsnNo = psn_info.PsnNo
  25027. PsnCertType = psn_info.PsnCertType
  25028. Certno = psn_info.Certno
  25029. PsnName = psn_info.PsnName
  25030. Gend = psn_info.Gend
  25031. Naty = psn_info.Naty
  25032. Brdy = psn_info.Brdy
  25033. Age = psn_info.Age
  25034. infoStr = psn_info.Insuinfo
  25035. idetinfoStr = psn_info.Idetinfo
  25036. infocode = 0
  25037. verify_number = psn_info.VerifyNumber
  25038. } else if id_card_type == 2 {
  25039. 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)
  25040. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25042. utils.ErrorLog("解析失败:%v", err)
  25043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25044. return
  25045. }
  25046. PsnNo = res.Output.Baseinfo.PsnNo
  25047. PsnCertType = res.Output.Baseinfo.PsnCertType
  25048. Certno = res.Output.Baseinfo.Certno
  25049. PsnName = res.Output.Baseinfo.PsnName
  25050. Gend = res.Output.Baseinfo.Gend
  25051. Naty = res.Output.Baseinfo.Naty
  25052. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25053. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25054. infoStr = string(Iinfos)
  25055. idetinfoStr = string(Idetinfos)
  25056. infocode = res.Infcode
  25057. } else if id_card_type == 4 {
  25058. psn_info, _ := service.GetPsnByPatientId(id)
  25059. PsnNo = psn_info.PsnNo
  25060. PsnCertType = psn_info.PsnCertType
  25061. Certno = psn_info.Certno
  25062. PsnName = psn_info.PsnName
  25063. Gend = psn_info.Gend
  25064. Naty = psn_info.Naty
  25065. Brdy = psn_info.Brdy
  25066. Age = psn_info.Age
  25067. infoStr = psn_info.Insuinfo
  25068. idetinfoStr = psn_info.Idetinfo
  25069. infocode = 0
  25070. verify_number = psn_info.VerifyNumber
  25071. }
  25072. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25073. var result string
  25074. var requestLog string
  25075. 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), "")
  25076. if id_card_type == 4 {
  25077. psn_info, _ := service.GetPsnByPatientId(id)
  25078. PsnNo = psn_info.PsnNo
  25079. PsnCertType = psn_info.PsnCertType
  25080. Certno = psn_info.Certno
  25081. PsnName = psn_info.PsnName
  25082. Gend = psn_info.Gend
  25083. Naty = psn_info.Naty
  25084. Brdy = psn_info.Brdy
  25085. Age = psn_info.Age
  25086. infoStr = psn_info.Insuinfo
  25087. idetinfoStr = psn_info.Idetinfo
  25088. infocode = 0
  25089. verify_number = psn_info.VerifyNumber
  25090. } else {
  25091. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25092. if miConfig.Code == "H15049901371" {
  25093. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25094. utils.ErrorLog("解析失败:%v", err)
  25095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25096. return
  25097. }
  25098. res.ErrMsg = res10265.ErrMsg
  25099. res.Output = res10265.Output
  25100. res.InfRefmsgid = res10265.InfRefmsgid
  25101. } else {
  25102. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25103. utils.ErrorLog("解析失败:%v", err)
  25104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25105. return
  25106. }
  25107. }
  25108. PsnNo = res.Output.Baseinfo.PsnNo
  25109. PsnCertType = res.Output.Baseinfo.PsnCertType
  25110. Certno = res.Output.Baseinfo.Certno
  25111. PsnName = res.Output.Baseinfo.PsnName
  25112. Gend = res.Output.Baseinfo.Gend
  25113. Naty = res.Output.Baseinfo.Naty
  25114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25116. infoStr = string(Iinfos)
  25117. idetinfoStr = string(Idetinfos)
  25118. if miConfig.Code == "H15049901371" {
  25119. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25120. } else {
  25121. infocode = res.Infcode
  25122. }
  25123. }
  25124. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25125. psn_info, _ := service.GetPsnByPatientId(id)
  25126. PsnNo = psn_info.PsnNo
  25127. PsnCertType = psn_info.PsnCertType
  25128. Certno = psn_info.Certno
  25129. PsnName = psn_info.PsnName
  25130. Gend = psn_info.Gend
  25131. Naty = psn_info.Naty
  25132. Brdy = psn_info.Brdy
  25133. Age = psn_info.Age
  25134. infoStr = psn_info.Insuinfo
  25135. idetinfoStr = psn_info.Idetinfo
  25136. infocode = 0
  25137. verify_number = psn_info.VerifyNumber
  25138. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25139. psn_info, _ := service.GetPsnByPatientId(id)
  25140. PsnNo = psn_info.PsnNo
  25141. PsnCertType = psn_info.PsnCertType
  25142. Certno = psn_info.Certno
  25143. PsnName = psn_info.PsnName
  25144. Gend = psn_info.Gend
  25145. Naty = psn_info.Naty
  25146. Brdy = psn_info.Brdy
  25147. Age = psn_info.Age
  25148. infoStr = psn_info.Insuinfo
  25149. idetinfoStr = psn_info.Idetinfo
  25150. infocode = 0
  25151. verify_number = psn_info.VerifyNumber
  25152. } else {
  25153. var result string
  25154. var requestLog string
  25155. //if miConfig.UserOrgId == 10138 {
  25156. if id_card_type != 4 || id_card_type != 1 {
  25157. var insa string
  25158. if len(patient.InsuplcAdmdvs) > 0 {
  25159. insa = patient.InsuplcAdmdvs
  25160. } else {
  25161. insa = miConfig.InsuplcAdmdvs
  25162. }
  25163. //psn_info, _ := service.GetPsnByPatientId(id)
  25164. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  25165. 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)
  25166. }
  25167. //}
  25168. //else {
  25169. // var insa string
  25170. // if len(patient.InsuplcAdmdvs) > 0 {
  25171. // insa = patient.InsuplcAdmdvs
  25172. // } else {
  25173. // insa = miConfig.InsuplcAdmdvs
  25174. // }
  25175. // 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)
  25176. //}
  25177. if id_card_type == 4 || id_card_type == 1 {
  25178. psn_info, _ := service.GetPsnByPatientId(id)
  25179. PsnNo = psn_info.PsnNo
  25180. PsnCertType = psn_info.PsnCertType
  25181. Certno = psn_info.Certno
  25182. PsnName = psn_info.PsnName
  25183. Gend = psn_info.Gend
  25184. Naty = psn_info.Naty
  25185. Brdy = psn_info.Brdy
  25186. Age = psn_info.Age
  25187. infoStr = psn_info.Insuinfo
  25188. idetinfoStr = psn_info.Idetinfo
  25189. infocode = 0
  25190. verify_number = psn_info.VerifyNumber
  25191. } else {
  25192. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25193. if miConfig.Code == "H15049901371" {
  25194. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25195. utils.ErrorLog("解析失败:%v", err)
  25196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25197. return
  25198. }
  25199. res.ErrMsg = res10265.ErrMsg
  25200. res.Output = res10265.Output
  25201. res.InfRefmsgid = res10265.InfRefmsgid
  25202. } else {
  25203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25204. utils.ErrorLog("解析失败:%v", err)
  25205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25206. return
  25207. }
  25208. }
  25209. PsnNo = res.Output.Baseinfo.PsnNo
  25210. PsnCertType = res.Output.Baseinfo.PsnCertType
  25211. Certno = res.Output.Baseinfo.Certno
  25212. PsnName = res.Output.Baseinfo.PsnName
  25213. Gend = res.Output.Baseinfo.Gend
  25214. Naty = res.Output.Baseinfo.Naty
  25215. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25216. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25217. infoStr = string(Iinfos)
  25218. idetinfoStr = string(Idetinfos)
  25219. if miConfig.Code == "H15049901371" {
  25220. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25221. } else {
  25222. infocode = res.Infcode
  25223. }
  25224. }
  25225. }
  25226. if infocode == 0 {
  25227. his := models.VMHisPatient{
  25228. Name: name,
  25229. Gender: gender,
  25230. Birthday: birthUnix,
  25231. MedicalTreatmentType: medical_care,
  25232. IdType: certificates,
  25233. IdCardNo: id_card,
  25234. BalanceAccountsType: settlementValue,
  25235. SocialType: social_type,
  25236. MedicalInsuranceNumber: medical_insurance_card,
  25237. RegisterType: register_type,
  25238. RegisterCost: registration_fee,
  25239. TreatmentCost: medical_expenses,
  25240. Status: 1,
  25241. Ctime: time.Now().Unix(),
  25242. Mtime: time.Now().Unix(),
  25243. PsnNo: PsnNo,
  25244. PsnCertType: PsnCertType,
  25245. Certno: Certno,
  25246. PsnName: PsnName,
  25247. Gend: Gend,
  25248. Naty: Naty,
  25249. Brdy: Brdy,
  25250. Age: Age,
  25251. Iinfo: infoStr,
  25252. Idetinfo: idetinfoStr,
  25253. PatientId: patient.ID,
  25254. RecordDate: theTime.Unix(),
  25255. UserOrgId: adminInfo.CurrentOrgId,
  25256. AdminUserId: admin_user_id,
  25257. IsReturn: 1,
  25258. IdCardType: id_card_type,
  25259. Doctor: doctor,
  25260. Departments: department,
  25261. MdtrtGrpType: mdtrt_type,
  25262. }
  25263. timestamp := time.Now().Unix()
  25264. tempTime := time.Unix(timestamp, 0)
  25265. timeFormat := tempTime.Format("20060102150405")
  25266. chrgBchno := rand.Intn(100000) + 10000
  25267. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25268. his.Number = ipt_otp_no
  25269. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25270. department, _ := service.GetDepartMentDetail(department)
  25271. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25272. IdCardNo := ""
  25273. if id_card_type == 1 {
  25274. // IdCardNo = medical_insurance_card
  25275. IdCardNo = patient.IdCardNo
  25276. } else {
  25277. IdCardNo = patient.IdCardNo
  25278. }
  25279. var rf []*ResultFive
  25280. json.Unmarshal([]byte(his.Iinfo), &rf)
  25281. var insutypes []*ResultFive
  25282. var insutype string
  25283. var insuplc_admdvs_temp string
  25284. var is390 int = 0
  25285. var is310 int = 0
  25286. for _, item := range rf {
  25287. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25288. insutypes = append(insutypes, item)
  25289. }
  25290. }
  25291. if len(insutypes) == 1 {
  25292. insutype = insutypes[0].Insutype
  25293. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25294. if insutype == "390" {
  25295. is390 = 1
  25296. }
  25297. if insutype == "310" {
  25298. is310 = 1
  25299. }
  25300. } else {
  25301. for _, i := range insutypes {
  25302. if i.Insutype == "390" {
  25303. is390 = 1
  25304. }
  25305. if i.Insutype == "310" {
  25306. is310 = 1
  25307. }
  25308. }
  25309. }
  25310. if is390 == 1 {
  25311. insutype = "390"
  25312. }
  25313. if is310 == 1 {
  25314. insutype = "310"
  25315. }
  25316. fmt.Println(social_type)
  25317. if social_type > 0 {
  25318. insutype = strconv.FormatInt(social_type, 10)
  25319. }
  25320. var infocode int64
  25321. var resThree ResultThree
  25322. var resThree10265 ResultThree10265
  25323. if len(insuplc_admdvs) == 0 {
  25324. psn_info, _ := service.GetPsnByPatientId(id)
  25325. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25326. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25327. //}
  25328. } else {
  25329. insuplc_admdvs_temp = insuplc_admdvs
  25330. }
  25331. if miConfig.MdtrtareaAdmvs == "421300" {
  25332. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25333. psn_info, _ := service.GetPsnByPatientId(id)
  25334. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25335. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25336. "&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
  25337. resp, requestErr := http.Get(api)
  25338. if requestErr != nil {
  25339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25340. return
  25341. }
  25342. body, ioErr := ioutil.ReadAll(resp.Body)
  25343. if ioErr != nil {
  25344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25346. return
  25347. }
  25348. var respJSON map[string]interface{}
  25349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25352. return
  25353. }
  25354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25355. result, _ := json.Marshal(respJSON)
  25356. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25357. utils.ErrorLog("解析失败:%v", err)
  25358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25359. return
  25360. }
  25361. infocode = resThree.Infcode
  25362. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25363. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25364. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25365. // insuplc_admdvs_temp =
  25366. //}
  25367. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25368. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25369. //}
  25370. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25371. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25372. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  25373. resp, requestErr := http.Get(api)
  25374. if requestErr != nil {
  25375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25376. return
  25377. }
  25378. body, ioErr := ioutil.ReadAll(resp.Body)
  25379. if ioErr != nil {
  25380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25382. return
  25383. }
  25384. var respJSON map[string]interface{}
  25385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25388. return
  25389. }
  25390. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25391. result, _ := json.Marshal(respJSON)
  25392. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25393. utils.ErrorLog("解析失败:%v", err)
  25394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25395. return
  25396. }
  25397. infocode = resThree.Infcode
  25398. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25399. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25400. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25401. // insuplc_admdvs_temp =
  25402. //}
  25403. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25404. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25405. //}
  25406. utils.ErrorLog("解析失败:%v", insutype)
  25407. utils.ErrorLog("解析失败:%v", PsnNo)
  25408. utils.ErrorLog("解析失败:%v", Certno)
  25409. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25410. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25411. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25412. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25413. utils.ErrorLog("解析失败:%v", PsnNo)
  25414. utils.ErrorLog("解析失败:%v", department.Number)
  25415. utils.ErrorLog("解析失败:%v", department.Name)
  25416. utils.ErrorLog("解析失败:%v", roles.UserName)
  25417. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25418. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25419. "&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
  25420. resp, requestErr := http.Get(api)
  25421. if requestErr != nil {
  25422. utils.ErrorLog("解析失败:%v", requestErr)
  25423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25424. return
  25425. }
  25426. body, ioErr := ioutil.ReadAll(resp.Body)
  25427. if ioErr != nil {
  25428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25430. return
  25431. }
  25432. var respJSON map[string]interface{}
  25433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25436. return
  25437. }
  25438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25439. result, _ := json.Marshal(respJSON)
  25440. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25441. utils.ErrorLog("解析失败:%v", err)
  25442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25443. return
  25444. }
  25445. infocode = resThree.Infcode
  25446. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25447. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25448. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25449. // insuplc_admdvs_temp =
  25450. //}
  25451. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25452. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25453. //}
  25454. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25455. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25456. "&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
  25457. resp, requestErr := http.Get(api)
  25458. if requestErr != nil {
  25459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25460. return
  25461. }
  25462. body, ioErr := ioutil.ReadAll(resp.Body)
  25463. if ioErr != nil {
  25464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25466. return
  25467. }
  25468. var respJSON map[string]interface{}
  25469. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25472. return
  25473. }
  25474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25475. result, _ := json.Marshal(respJSON)
  25476. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25477. utils.ErrorLog("解析失败:%v", err)
  25478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25479. return
  25480. }
  25481. infocode = resThree.Infcode
  25482. } else if miConfig.MdtrtareaAdmvs == "150404" {
  25483. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25484. psn_info, _ := service.GetPsnByPatientId(id)
  25485. var verify_number string
  25486. if id_card_type == 4 {
  25487. verify_number = psn_info.VerifyNumber
  25488. } else if id_card_type == 1 {
  25489. bas := strings.Split(psn_info.CardInfo, "|")
  25490. cardNumber := bas[2]
  25491. verify_number = cardNumber
  25492. }
  25493. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25494. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25495. "&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
  25496. resp, requestErr := http.Get(api)
  25497. if requestErr != nil {
  25498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25499. return
  25500. }
  25501. body, ioErr := ioutil.ReadAll(resp.Body)
  25502. if ioErr != nil {
  25503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25505. return
  25506. }
  25507. var respJSON map[string]interface{}
  25508. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25511. return
  25512. }
  25513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25514. result, _ := json.Marshal(respJSON)
  25515. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25516. // utils.ErrorLog("解析失败:%v", err)
  25517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25518. // return
  25519. //}
  25520. //infocode = resThree.Infcode
  25521. //result, _ := json.Marshal(respJSON)
  25522. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25523. utils.ErrorLog("解析失败:%v", err)
  25524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25525. return
  25526. }
  25527. resThree.ErrMsg = resThree10265.ErrMsg
  25528. resThree.Output = resThree10265.Output
  25529. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25530. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25531. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25532. psn_info, _ := service.GetPsnByPatientId(id)
  25533. his.PsnNo = psn_info.PsnNo
  25534. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25535. var cert_no string
  25536. if id_card_type == 3 {
  25537. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25538. cert_no = IdCardNo
  25539. } else if id_card_type == 4 {
  25540. cert_no = IdCardNo
  25541. psn_info.VerifyNumber = psn_info.VerifyNumber
  25542. } else {
  25543. bas := strings.Split(psn_info.CardInfo, "|")
  25544. cert_no = bas[2]
  25545. }
  25546. var hisPrescription []*models.HisPrescription
  25547. fmt.Println(hisPrescription)
  25548. for _, item := range rf {
  25549. if item.Insutype == insutype {
  25550. //insuplc_admdvs = item.InsuplcAdmdvs
  25551. his.InsuplcAdmdvs = insuplc_admdvs
  25552. }
  25553. }
  25554. his.Insutype = insutype
  25555. var res3101 Result3101
  25556. res3101.Infcode = "0"
  25557. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25558. if res3101.Infcode == "0" {
  25559. fmt.Println("33333333")
  25560. if len(res3101.Output.Result) > 0 {
  25561. fmt.Println("222222")
  25562. for _, item := range res3101.Output.Result {
  25563. if len(res3101.ErrMsg) == 0 {
  25564. res3101.ErrMsg = item.VolaCont
  25565. } else {
  25566. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25567. }
  25568. }
  25569. c.ServeSuccessJSON(map[string]interface{}{
  25570. "failed_code": -10,
  25571. "msg": res3101.ErrMsg,
  25572. })
  25573. return
  25574. } else {
  25575. fmt.Println("11111")
  25576. var api string
  25577. if miConfig.MdtrtareaAdmvs == "320830" {
  25578. ipt_otp_no = timeFormat
  25579. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25580. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25581. "&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
  25582. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25583. ipt_otp_no = timeFormat
  25584. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25585. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25586. "&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
  25587. } else {
  25588. ipt_otp_no = timeFormat
  25589. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25590. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25591. "&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
  25592. }
  25593. resp, requestErr := http.Get(api)
  25594. if requestErr != nil {
  25595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25596. return
  25597. }
  25598. body, ioErr := ioutil.ReadAll(resp.Body)
  25599. if ioErr != nil {
  25600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25602. return
  25603. }
  25604. var respJSON map[string]interface{}
  25605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25608. return
  25609. }
  25610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25611. result, _ := json.Marshal(respJSON)
  25612. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25613. utils.ErrorLog("解析失败:%v", err)
  25614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25615. return
  25616. }
  25617. resThree.ErrMsg = resThree10265.ErrMsg
  25618. resThree.Output = resThree10265.Output
  25619. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25620. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25621. }
  25622. } else if res3101.Infcode != "0" {
  25623. c.ServeSuccessJSON(map[string]interface{}{
  25624. "failed_code": -10,
  25625. "msg": res3101.ErrMsg,
  25626. })
  25627. return
  25628. }
  25629. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25630. psn_info, _ := service.GetPsnByPatientId(id)
  25631. var cert_no string
  25632. if id_card_type == 1 {
  25633. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25634. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25635. } else if id_card_type == 4 {
  25636. cert_no = psn_info.VerifyNumber
  25637. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25638. } else {
  25639. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25640. cert_no = psn_info.VerifyNumber
  25641. }
  25642. 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)
  25643. saveLog(result, requestLog, "2201", "挂号")
  25644. if miConfig.Code == "H15049901371" {
  25645. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25646. utils.ErrorLog("解析失败:%v", err)
  25647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25648. return
  25649. }
  25650. resThree.ErrMsg = resThree10265.ErrMsg
  25651. resThree.Output = resThree10265.Output
  25652. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25653. } else {
  25654. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25655. utils.ErrorLog("解析失败:%v", err)
  25656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25657. return
  25658. }
  25659. }
  25660. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25661. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25662. psn_info, _ := service.GetPsnByPatientId(id)
  25663. var result string
  25664. var requestLog string
  25665. if id_card_type == 1 {
  25666. bas := strings.Split(psn_info.CardInfo, "|")
  25667. basNumber := bas[2]
  25668. card_sn := bas[3]
  25669. 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)
  25670. saveLog(result, requestLog, "2201A", "挂号")
  25671. } else if id_card_type == 2 {
  25672. 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, "", "", "", "", "", "")
  25673. saveLog(result, requestLog, "2201A", "挂号")
  25674. } else {
  25675. 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)
  25676. saveLog(result, requestLog, "2201A", "挂号")
  25677. }
  25678. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25679. utils.ErrorLog("解析失败:%v", err)
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. infocode = resThree.Infcode
  25684. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25685. psn_info, _ := service.GetPsnByPatientId(id)
  25686. var result string
  25687. var requestLog string
  25688. if id_card_type == 1 {
  25689. bas := strings.Split(psn_info.CardInfo, "|")
  25690. basNumber := bas[2]
  25691. card_sn := ""
  25692. 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)
  25693. saveLog(result, requestLog, "2201A", "挂号")
  25694. } else if id_card_type == 2 {
  25695. 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, "", "", "", "", "", "")
  25696. saveLog(result, requestLog, "2201A", "挂号")
  25697. } else {
  25698. 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)
  25699. saveLog(result, requestLog, "2201A", "挂号")
  25700. }
  25701. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25702. utils.ErrorLog("解析失败:%v", err)
  25703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25704. return
  25705. }
  25706. infocode = resThree.Infcode
  25707. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25708. psn_info, _ := service.GetPsnByPatientId(id)
  25709. var result string
  25710. var requestLog string
  25711. if id_card_type == 1 {
  25712. bas := strings.Split(psn_info.CardInfo, "|")
  25713. basNumber := bas[2]
  25714. card_sn := ""
  25715. 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)
  25716. saveLog(result, requestLog, "2201A", "挂号")
  25717. } else if id_card_type == 2 {
  25718. 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, "", "", "", "", "", "")
  25719. saveLog(result, requestLog, "2201A", "挂号")
  25720. } else {
  25721. 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)
  25722. saveLog(result, requestLog, "2201A", "挂号")
  25723. }
  25724. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25725. utils.ErrorLog("解析失败:%v", err)
  25726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25727. return
  25728. }
  25729. infocode = resThree.Infcode
  25730. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25731. psn_info, _ := service.GetPsnByPatientId(id)
  25732. his.PsnNo = psn_info.PsnNo
  25733. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25734. var cert_no string
  25735. if id_card_type == 1 {
  25736. bas := strings.Split(psn_info.CardInfo, "|")
  25737. cert_no = bas[2]
  25738. } else if id_card_type == 4 {
  25739. cert_no = psn_info.VerifyNumber
  25740. psn_info.VerifyNumber = psn_info.VerifyNumber
  25741. IdCardNo = psn_info.VerifyNumber
  25742. } else {
  25743. cert_no = IdCardNo
  25744. psn_info.VerifyNumber = cert_no
  25745. }
  25746. for _, item := range rf {
  25747. if item.Insutype == insutype {
  25748. his.InsuplcAdmdvs = insuplc_admdvs
  25749. }
  25750. }
  25751. his.Insutype = insutype
  25752. var api string
  25753. ipt_otp_no = timeFormat
  25754. 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 +
  25755. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25756. "&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
  25757. resp, requestErr := http.Get(api)
  25758. if requestErr != nil {
  25759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25760. return
  25761. }
  25762. body, ioErr := ioutil.ReadAll(resp.Body)
  25763. if ioErr != nil {
  25764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25766. return
  25767. }
  25768. var respJSON map[string]interface{}
  25769. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25772. return
  25773. }
  25774. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25775. if status == "0" {
  25776. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25777. c.ServeSuccessJSON(map[string]interface{}{
  25778. "failed_code": -10,
  25779. "msg": err_msg,
  25780. })
  25781. return
  25782. }
  25783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25784. result, _ := json.Marshal(respJSON)
  25785. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25786. utils.ErrorLog("解析失败:%v", err)
  25787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25788. return
  25789. }
  25790. infocode = resThree.Infcode
  25791. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25792. psn_info, _ := service.GetPsnByPatientId(id)
  25793. his.PsnNo = psn_info.PsnNo
  25794. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25795. var cert_no string
  25796. if id_card_type == 1 {
  25797. bas := strings.Split(psn_info.CardInfo, "|")
  25798. cert_no = bas[2]
  25799. } else if id_card_type == 4 {
  25800. cert_no = psn_info.VerifyNumber
  25801. psn_info.VerifyNumber = psn_info.VerifyNumber
  25802. IdCardNo = psn_info.VerifyNumber
  25803. } else {
  25804. cert_no = IdCardNo
  25805. psn_info.VerifyNumber = cert_no
  25806. }
  25807. for _, item := range rf {
  25808. if item.Insutype == insutype {
  25809. his.InsuplcAdmdvs = insuplc_admdvs
  25810. patient.InsuplcAdmdvs = insuplc_admdvs
  25811. }
  25812. }
  25813. his.Insutype = insutype
  25814. var api string
  25815. ipt_otp_no = timeFormat
  25816. 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 +
  25817. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25818. "&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
  25819. resp, requestErr := http.Get(api)
  25820. if requestErr != nil {
  25821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25822. return
  25823. }
  25824. body, ioErr := ioutil.ReadAll(resp.Body)
  25825. if ioErr != nil {
  25826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25828. return
  25829. }
  25830. var respJSON map[string]interface{}
  25831. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25834. return
  25835. }
  25836. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25837. if status == "0" {
  25838. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25839. c.ServeSuccessJSON(map[string]interface{}{
  25840. "failed_code": -10,
  25841. "msg": err_msg,
  25842. })
  25843. return
  25844. }
  25845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25846. result, _ := json.Marshal(respJSON)
  25847. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25848. utils.ErrorLog("解析失败:%v", err)
  25849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25850. return
  25851. }
  25852. infocode = resThree.Infcode
  25853. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25854. hour := time.Now().Format("15")
  25855. min := time.Now().Format("04")
  25856. sec := time.Now().Format("05")
  25857. begin := record_time + " " + hour + ":" + min + ":" + sec
  25858. psn_info, _ := service.GetPsnByPatientId(id)
  25859. var result string
  25860. var requestLog string
  25861. if id_card_type == 1 {
  25862. bas := strings.Split(psn_info.CardInfo, "|")
  25863. basNumber := bas[2]
  25864. card_sn := bas[3]
  25865. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, begin)
  25866. saveLog(result, requestLog, "2201A", "挂号")
  25867. } else if id_card_type == 2 {
  25868. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, psn_info.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "", begin)
  25869. saveLog(result, requestLog, "2201A", "挂号")
  25870. } else {
  25871. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "", begin)
  25872. saveLog(result, requestLog, "2201A", "挂号")
  25873. }
  25874. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25875. utils.ErrorLog("解析失败:%v", err)
  25876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25877. return
  25878. }
  25879. infocode = resThree.Infcode
  25880. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25881. psn_info, _ := service.GetPsnByPatientId(id)
  25882. 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)
  25883. saveLog(result, requestLog, "2201A", "挂号")
  25884. if miConfig.Code == "H15049901371" {
  25885. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25886. utils.ErrorLog("解析失败:%v", err)
  25887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25888. return
  25889. }
  25890. resThree.ErrMsg = resThree10265.ErrMsg
  25891. resThree.Output = resThree10265.Output
  25892. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25893. } else {
  25894. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25895. utils.ErrorLog("解析失败:%v", err)
  25896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25897. return
  25898. }
  25899. }
  25900. if miConfig.Code == "H15049901371" {
  25901. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25902. } else {
  25903. infocode = resThree.Infcode
  25904. }
  25905. } else {
  25906. psn_info, _ := service.GetPsnByPatientId(id)
  25907. if id_card_type == 4 || id_card_type == 1 {
  25908. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25909. }
  25910. var rf []*ResultFive
  25911. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25912. var insutypes []*ResultFive
  25913. var insutype string
  25914. var is390 int = 0
  25915. var is310 int = 0
  25916. for _, item := range rf {
  25917. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25918. insutypes = append(insutypes, item)
  25919. }
  25920. }
  25921. if len(insutypes) == 1 {
  25922. insutype = insutypes[0].Insutype
  25923. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25924. } else {
  25925. for _, i := range insutypes {
  25926. if i.Insutype == "390" {
  25927. is390 = 1
  25928. }
  25929. if i.Insutype == "310" {
  25930. is310 = 1
  25931. }
  25932. }
  25933. }
  25934. if is390 == 1 {
  25935. insutype = "390"
  25936. }
  25937. if is310 == 1 {
  25938. insutype = "310"
  25939. }
  25940. fmt.Println(len(insutypes))
  25941. if len(insutypes) == 0 {
  25942. for index, item := range rf {
  25943. if index == 0 {
  25944. insutype = item.Insutype
  25945. insuplc_admdvs = item.InsuplcAdmdvs
  25946. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25947. }
  25948. }
  25949. fmt.Println(insutype)
  25950. fmt.Println(insuplc_admdvs)
  25951. }
  25952. if social_type > 0 {
  25953. insutype = strconv.FormatInt(social_type, 10)
  25954. }
  25955. fmt.Println("--------")
  25956. fmt.Println(psn_info)
  25957. fmt.Println(psn_info.PsnNo)
  25958. for _, item := range rf {
  25959. if item.Insutype == insutype {
  25960. insutype = item.Insutype
  25961. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25962. }
  25963. }
  25964. if miConfig.MdtrtareaAdmvs == "441202" {
  25965. var hisPrescription []*models.HisPrescription
  25966. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25967. if res3101.Infcode == 0 {
  25968. fmt.Println("33333333")
  25969. if len(res3101.Output.Result) > 0 {
  25970. fmt.Println("222222")
  25971. for _, item := range res3101.Output.Result {
  25972. if len(res3101.ErrMsg) == 0 {
  25973. res3101.ErrMsg = item.VolaCont
  25974. } else {
  25975. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25976. }
  25977. }
  25978. c.ServeSuccessJSON(map[string]interface{}{
  25979. "failed_code": -10,
  25980. "msg": res3101.ErrMsg,
  25981. })
  25982. return
  25983. } else {
  25984. hour := time.Now().Format("15")
  25985. min := time.Now().Format("04")
  25986. sec := time.Now().Format("05")
  25987. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25988. fmt.Println(record_time_two)
  25989. 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)
  25990. saveLog(result, requestLog, "2201A", "挂号")
  25991. if miConfig.Code == "H15049901371" {
  25992. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25993. utils.ErrorLog("解析失败:%v", err)
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. resThree.ErrMsg = resThree10265.ErrMsg
  25998. resThree.Output = resThree10265.Output
  25999. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26000. } else {
  26001. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26002. utils.ErrorLog("解析失败:%v", err)
  26003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26004. return
  26005. }
  26006. }
  26007. if miConfig.Code == "H15049901371" {
  26008. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26009. } else {
  26010. infocode = resThree.Infcode
  26011. }
  26012. }
  26013. } else if res3101.Infcode != 0 {
  26014. c.ServeSuccessJSON(map[string]interface{}{
  26015. "failed_code": -10,
  26016. "msg": res3101.ErrMsg,
  26017. })
  26018. return
  26019. }
  26020. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26021. var hisPrescription []*models.HisPrescription
  26022. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26023. if res3101.Infcode == 0 {
  26024. fmt.Println("33333333")
  26025. if len(res3101.Output.Result) > 0 {
  26026. fmt.Println("222222")
  26027. for _, item := range res3101.Output.Result {
  26028. if len(res3101.ErrMsg) == 0 {
  26029. res3101.ErrMsg = item.VolaCont
  26030. } else {
  26031. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  26032. }
  26033. }
  26034. c.ServeSuccessJSON(map[string]interface{}{
  26035. "failed_code": -10,
  26036. "msg": res3101.ErrMsg,
  26037. })
  26038. return
  26039. } else {
  26040. hour := time.Now().Format("15")
  26041. min := time.Now().Format("04")
  26042. sec := time.Now().Format("05")
  26043. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26044. fmt.Println(record_time_two)
  26045. 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)
  26046. saveLog(result, requestLog, "2201A", "挂号")
  26047. if miConfig.Code == "H15049901371" {
  26048. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26049. utils.ErrorLog("解析失败:%v", err)
  26050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26051. return
  26052. }
  26053. resThree.ErrMsg = resThree10265.ErrMsg
  26054. resThree.Output = resThree10265.Output
  26055. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26056. } else {
  26057. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26058. utils.ErrorLog("解析失败:%v", err)
  26059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26060. return
  26061. }
  26062. }
  26063. if miConfig.Code == "H15049901371" {
  26064. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26065. } else {
  26066. infocode = resThree.Infcode
  26067. }
  26068. }
  26069. } else if res3101.Infcode != 0 {
  26070. c.ServeSuccessJSON(map[string]interface{}{
  26071. "failed_code": -10,
  26072. "msg": res3101.ErrMsg,
  26073. })
  26074. return
  26075. }
  26076. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26077. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  26078. psn_info, _ := service.GetPsnByPatientId(id)
  26079. var verify_number string
  26080. if id_card_type == 4 {
  26081. verify_number = psn_info.VerifyNumber
  26082. } else if id_card_type == 1 {
  26083. bas := strings.Split(psn_info.CardInfo, "|")
  26084. cardNumber := bas[2]
  26085. verify_number = cardNumber
  26086. } else {
  26087. verify_number = psn_info.Certno
  26088. }
  26089. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  26090. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  26091. "&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
  26092. resp, requestErr := http.Get(api)
  26093. if requestErr != nil {
  26094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26095. return
  26096. }
  26097. body, ioErr := ioutil.ReadAll(resp.Body)
  26098. if ioErr != nil {
  26099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26101. return
  26102. }
  26103. var respJSON map[string]interface{}
  26104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26107. return
  26108. }
  26109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26110. result, _ := json.Marshal(respJSON)
  26111. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26112. utils.ErrorLog("解析失败:%v", err)
  26113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26114. return
  26115. }
  26116. infocode = resThree.Infcode
  26117. } else {
  26118. hour := time.Now().Format("15")
  26119. min := time.Now().Format("04")
  26120. sec := time.Now().Format("05")
  26121. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26122. if id_card_type == 1 {
  26123. for _, item := range rf {
  26124. if item.Insutype == strconv.FormatInt(social_type, 10) {
  26125. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  26126. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26127. } else if strconv.FormatInt(social_type, 10) == "390" {
  26128. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26129. } else {
  26130. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26131. }
  26132. }
  26133. }
  26134. }
  26135. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  26136. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26137. }
  26138. if id_card_type == 1 {
  26139. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  26140. bas := strings.Split(psn_info.CardInfo, "|")
  26141. basNumber := bas[1]
  26142. IdCardNo = basNumber
  26143. }
  26144. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  26145. IdCardNo = psn_info.VerifyNumber
  26146. }
  26147. if len(insuplc_admdvs_temp) == 0 {
  26148. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26149. }
  26150. var result string
  26151. var requestLog string
  26152. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  26153. var hisPrescription []*models.HisPrescription
  26154. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26155. if res3101.Infcode == 0 {
  26156. if len(res3101.Output.Result) > 0 {
  26157. if len(res3101.Output.Result) > 0 {
  26158. c.ServeSuccessJSON(map[string]interface{}{
  26159. "failed_code": -10,
  26160. "failed_type": 100,
  26161. "warm_type": 1,
  26162. "msg": res3101,
  26163. })
  26164. return
  26165. } else {
  26166. c.ServeSuccessJSON(map[string]interface{}{
  26167. "failed_code": -10,
  26168. "msg": res3101.ErrMsg,
  26169. })
  26170. return
  26171. }
  26172. } else {
  26173. hour := time.Now().Format("15")
  26174. min := time.Now().Format("04")
  26175. sec := time.Now().Format("05")
  26176. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26177. fmt.Println(record_time_two)
  26178. if his.IdCardType == 2 {
  26179. IdCardNo = psn_info.Certno
  26180. psn_info.VerifyNumber = psn_info.Certno
  26181. } else if his.IdCardType == 4 {
  26182. IdCardNo = psn_info.Certno
  26183. } else {
  26184. bas := strings.Split(psn_info.CardInfo, "|")
  26185. IdCardNo = bas[2]
  26186. }
  26187. aaaa = insutype
  26188. 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)
  26189. saveLog(result, requestLog, "2201A", "挂号")
  26190. if miConfig.Code == "H15049901371" {
  26191. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26192. utils.ErrorLog("解析失败:%v", err)
  26193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26194. return
  26195. }
  26196. resThree.ErrMsg = resThree10265.ErrMsg
  26197. resThree.Output = resThree10265.Output
  26198. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26199. } else {
  26200. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26201. utils.ErrorLog("解析失败:%v", err)
  26202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26203. return
  26204. }
  26205. }
  26206. if miConfig.Code == "H15049901371" {
  26207. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26208. } else {
  26209. infocode = resThree.Infcode
  26210. }
  26211. }
  26212. } else if res3101.Infcode != 0 {
  26213. c.ServeSuccessJSON(map[string]interface{}{
  26214. "failed_code": -10,
  26215. "msg": res3101.ErrMsg,
  26216. })
  26217. return
  26218. }
  26219. } else {
  26220. psn_info, _ := service.GetPsnByPatientId(id)
  26221. var rf []*ResultFive
  26222. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26223. //var insutypes []*ResultFive
  26224. var insutype string
  26225. var insutypes []*ResultFive
  26226. var is390 int = 0
  26227. var is310 int = 0
  26228. for _, item := range rf {
  26229. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26230. insutypes = append(insutypes, item)
  26231. }
  26232. }
  26233. if len(insutypes) == 1 {
  26234. insutype = insutypes[0].Insutype
  26235. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26236. } else {
  26237. for _, i := range insutypes {
  26238. if i.Insutype == "390" {
  26239. is390 = 1
  26240. }
  26241. if i.Insutype == "310" {
  26242. is310 = 1
  26243. }
  26244. }
  26245. }
  26246. if is390 == 1 {
  26247. insutype = "390"
  26248. }
  26249. if is310 == 1 {
  26250. insutype = "310"
  26251. }
  26252. if len(insutypes) == 0 {
  26253. insutype = "310"
  26254. }
  26255. if social_type > 0 {
  26256. insutype = strconv.FormatInt(social_type, 10)
  26257. }
  26258. for _, item := range rf {
  26259. if item.Insutype == insutype {
  26260. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26261. }
  26262. }
  26263. if len(insuplc_admdvs_tt) > 0 {
  26264. insuplc_admdvs_temp = insuplc_admdvs_tt
  26265. }
  26266. 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)
  26267. saveLog(result, requestLog, "2201A", "挂号")
  26268. }
  26269. if miConfig.Code == "H15049901371" {
  26270. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26271. utils.ErrorLog("解析失败:%v", err)
  26272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26273. return
  26274. }
  26275. resThree.ErrMsg = resThree10265.ErrMsg
  26276. resThree.Output = resThree10265.Output
  26277. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26278. } else {
  26279. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26280. utils.ErrorLog("解析失败:%v", err)
  26281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26282. return
  26283. }
  26284. }
  26285. if miConfig.Code == "H15049901371" {
  26286. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26287. } else {
  26288. infocode = resThree.Infcode
  26289. }
  26290. }
  26291. }
  26292. if infocode == -1 {
  26293. adminUser := c.GetAdminUserInfo()
  26294. errlog := &models.HisOrderError{
  26295. UserOrgId: adminUser.CurrentOrgId,
  26296. Ctime: time.Now().Unix(),
  26297. Mtime: time.Now().Unix(),
  26298. ErrMsg: resThree.ErrMsg,
  26299. Status: 1,
  26300. PatientId: id,
  26301. RecordTime: recordDateTime,
  26302. Stage: 2,
  26303. }
  26304. service.CreateErrMsgLog(errlog)
  26305. c.ServeSuccessJSON(map[string]interface{}{
  26306. "failed_code": -10,
  26307. "msg": resThree.ErrMsg,
  26308. })
  26309. return
  26310. }
  26311. utils.ErrorLog("解析失败:%v", insutype)
  26312. his.Number = resThree.Output.Data.MdtrtID
  26313. his.PsnNo = resThree.Output.Data.PsnNo
  26314. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26315. his.IdCardNo = patient.IdCardNo
  26316. his.PhoneNumber = patient.Phone
  26317. his.UserOrgId = adminInfo.CurrentOrgId
  26318. his.Insutype = insutype
  26319. if miConfig.Code == "H44030500255" {
  26320. his.Insutype = aaaa
  26321. }
  26322. his.Ctime = time.Now().Unix()
  26323. his.Mtime = time.Now().Unix()
  26324. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26325. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26326. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26327. }
  26328. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26329. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26330. }
  26331. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26332. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26333. }
  26334. his.Status = 1
  26335. his.MdtrtGrpType = mdtrt_type
  26336. service.UpdateHisPatientStatus(&his)
  26337. service.UpdateHisPatient123(&patient)
  26338. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26339. c.ServeSuccessJSON(map[string]interface{}{
  26340. "his_info": his,
  26341. })
  26342. } else {
  26343. adminUser := c.GetAdminUserInfo()
  26344. errlog := &models.HisOrderError{
  26345. UserOrgId: adminUser.CurrentOrgId,
  26346. Ctime: time.Now().Unix(),
  26347. Mtime: time.Now().Unix(),
  26348. ErrMsg: res.ErrMsg,
  26349. Status: 1,
  26350. PatientId: id,
  26351. RecordTime: recordDateTime,
  26352. Stage: 1,
  26353. }
  26354. service.CreateErrMsgLog(errlog)
  26355. c.ServeSuccessJSON(map[string]interface{}{
  26356. "failed_code": -10,
  26357. "msg": res.ErrMsg,
  26358. })
  26359. return
  26360. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26361. }
  26362. }
  26363. }
  26364. func (c *HisApiController) GetUploadInfo() {
  26365. id, _ := c.GetInt64("id")
  26366. record_time := c.GetString("record_time")
  26367. his_patient_id, _ := c.GetInt64("his_patient_id")
  26368. order_id, _ := c.GetInt64("order_id")
  26369. pay_way, _ := c.GetInt64("pay_way")
  26370. pay_ways := c.GetString("pay_ways")
  26371. oth_desc := c.GetString("oth_desc")
  26372. pay_price, _ := c.GetFloat("pay_price")
  26373. pay_card_no := c.GetString("pay_card_no")
  26374. discount_price, _ := c.GetFloat("discount_price")
  26375. preferential_price, _ := c.GetFloat("preferential_price")
  26376. reality_price, _ := c.GetFloat("reality_price")
  26377. found_price, _ := c.GetFloat("found_price")
  26378. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26379. private_price, _ := c.GetFloat("private_price")
  26380. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26381. admin_user_id, _ := c.GetInt64("admin_user_id")
  26382. fapiao_code := c.GetString("fapiao_code")
  26383. fapiao_number := c.GetString("fapiao_number")
  26384. diagnosis_id := c.GetString("diagnosis")
  26385. sick_type, _ := c.GetInt64("sick_type")
  26386. reg_type, _ := c.GetInt64("p_type")
  26387. begin_time := c.GetString("begin_time")
  26388. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26389. cash_pay := c.GetString("cash_pay")
  26390. band_card_pay := c.GetString("band_card_pay")
  26391. wechat_pay := c.GetString("wechat_pay")
  26392. ali_pay := c.GetString("ali_pay")
  26393. jifen_pay := c.GetString("jifen_pay")
  26394. //jifen_pay := c.GetString("jifen_pay")
  26395. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26396. fmt.Println(acct_used_flag)
  26397. id_str := c.GetString("ids")
  26398. ids_arr := strings.Split(id_str, ",")
  26399. timeLayout := "2006-01-02"
  26400. loc, _ := time.LoadLocation("Local")
  26401. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26402. if err != nil {
  26403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26404. return
  26405. }
  26406. recordDateTime := theTime.Unix()
  26407. adminUser := c.GetAdminUserInfo()
  26408. var tempOrder models.HisOrder
  26409. tempOrder, _ = service.GetHisOrderByID(order_id)
  26410. var prescriptions []*models.HisPrescription
  26411. var start_time int64
  26412. var end_time int64
  26413. //押金模块
  26414. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26415. tmp_decimal := c.GetString("tmp_decimal")
  26416. var decimal float64 //本次使用的押金
  26417. var errmsg error
  26418. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26419. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26420. return
  26421. }
  26422. if len(tmp_decimal) > 0 {
  26423. if tmp_decimal[0] == 45 {
  26424. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26425. return
  26426. }
  26427. }
  26428. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26429. fmt.Println(errs)
  26430. decimal = tt
  26431. //if adminUser.CurrentOrgId == 10106{
  26432. // if len(fapiao_code) == 0{
  26433. // fapiao_code = "144072080589"
  26434. // }
  26435. // if len(fapiao_number) == 0{
  26436. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26437. // if order.ID == 0{
  26438. // fapiao_number = "00001520"
  26439. // }else{
  26440. // //fapiao_code = "00001520"
  26441. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26442. // var zero string
  26443. // if fpNumber >= 1000{
  26444. // zero = "0000" + strconv.Itoa(fpNumber)
  26445. // }else if fpNumber >= 10000{
  26446. // zero = "000" + strconv.Itoa(fpNumber)
  26447. // } else if fpNumber >= 100000{
  26448. // zero = "00" + strconv.Itoa(fpNumber)
  26449. // } else if fpNumber >= 1000000{
  26450. // zero = "0" + strconv.Itoa(fpNumber)
  26451. // }else {
  26452. // zero = strconv.Itoa(fpNumber)
  26453. // }
  26454. // fapiao_number = zero
  26455. // }
  26456. // }
  26457. //}
  26458. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26459. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26460. var patientPrescription models.HisPrescriptionInfo
  26461. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26462. if patientPrescription.ID == 0 {
  26463. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26464. }
  26465. //if patientPrescription.Do
  26466. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26467. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26468. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26469. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26470. var config []*models.HisXtDiagnoseConfig
  26471. for _, item := range diagnosis_ids {
  26472. id, _ := strconv.ParseInt(item, 10, 64)
  26473. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26474. config = append(config, &diagnosisConfig)
  26475. }
  26476. sickConfig, _ := service.FindSickById(sick_type)
  26477. //if tempOrder.ID == 0 {
  26478. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26479. //}
  26480. if tempOrder.ID == 0 {
  26481. var result string
  26482. var requestLog string
  26483. var res2 ResultSix
  26484. var res3 GZResultSix
  26485. var ressix10265 ResultSix10265
  26486. if miConfig.MdtrtareaAdmvs == "421300" {
  26487. data := make(map[string]interface{})
  26488. client := &http.Client{}
  26489. data["psn_no"] = his.PsnNo
  26490. data["mdtrt_id"] = his.Number
  26491. data["opter"] = roles.UserName
  26492. data["org_name"] = miConfig.OrgName
  26493. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26494. data["doctor_id"] = doctor_info.DoctorNumber
  26495. data["doctor_name"] = doctor_info.UserName
  26496. data["department"] = department.Name
  26497. data["fixmedins_code"] = miConfig.Code
  26498. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26499. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26500. data["secret_key"] = miConfig.SecretKey
  26501. data["sick_code"] = sickConfig.CountryCode
  26502. data["sick_name"] = sickConfig.ClassName
  26503. data["dept"] = strconv.FormatInt(department.ID, 10)
  26504. data["config"] = config
  26505. data["begin_time"] = begin_time
  26506. bytesData, _ := json.Marshal(data)
  26507. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26508. resp, _ := client.Do(req)
  26509. defer resp.Body.Close()
  26510. body, ioErr := ioutil.ReadAll(resp.Body)
  26511. if ioErr != nil {
  26512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26514. return
  26515. }
  26516. var respJSON map[string]interface{}
  26517. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26520. return
  26521. }
  26522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26523. userJSONBytes, _ := json.Marshal(respJSON)
  26524. fmt.Println("log")
  26525. fmt.Println(string(userJSONBytes))
  26526. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26527. utils.ErrorLog("解析失败:%v", err)
  26528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26529. return
  26530. }
  26531. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26532. data := make(map[string]interface{})
  26533. client := &http.Client{}
  26534. data["psn_no"] = his.PsnNo
  26535. data["mdtrt_id"] = his.Number
  26536. data["opter"] = roles.UserName
  26537. data["org_name"] = miConfig.OrgName
  26538. if reg_type == 11 && his.Insutype == "390" {
  26539. data["med_type"] = "110104"
  26540. } else {
  26541. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26542. }
  26543. data["doctor_id"] = doctor_info.DoctorNumber
  26544. data["doctor_name"] = doctor_info.UserName
  26545. data["department"] = department.Name
  26546. data["fixmedins_code"] = miConfig.Code
  26547. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26548. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26549. data["secret_key"] = miConfig.SecretKey
  26550. data["sick_code"] = sickConfig.CountryCode
  26551. data["sick_name"] = sickConfig.ClassName
  26552. data["dept"] = strconv.FormatInt(department.ID, 10)
  26553. data["config"] = config
  26554. data["begin_time"] = begin_time
  26555. bytesData, _ := json.Marshal(data)
  26556. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26557. resp, _ := client.Do(req)
  26558. defer resp.Body.Close()
  26559. body, ioErr := ioutil.ReadAll(resp.Body)
  26560. if ioErr != nil {
  26561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26563. return
  26564. }
  26565. var respJSON map[string]interface{}
  26566. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26569. return
  26570. }
  26571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26572. userJSONBytes, _ := json.Marshal(respJSON)
  26573. fmt.Println("log")
  26574. fmt.Println(string(userJSONBytes))
  26575. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26576. utils.ErrorLog("解析失败:%v", err)
  26577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26578. return
  26579. }
  26580. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26581. data := make(map[string]interface{})
  26582. client := &http.Client{}
  26583. data["psn_no"] = his.PsnNo
  26584. data["mdtrt_id"] = his.Number
  26585. data["opter"] = roles.UserName
  26586. data["org_name"] = miConfig.OrgName
  26587. if reg_type == 11 && his.Insutype == "390" {
  26588. data["med_type"] = "110104"
  26589. } else {
  26590. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26591. }
  26592. data["doctor_id"] = doctor_info.DoctorNumber
  26593. data["doctor_name"] = doctor_info.UserName
  26594. data["department"] = department.Name
  26595. data["fixmedins_code"] = miConfig.Code
  26596. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26597. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26598. data["secret_key"] = miConfig.SecretKey
  26599. data["sick_code"] = sickConfig.CountryCode
  26600. data["sick_name"] = sickConfig.ClassName
  26601. data["dept"] = strconv.FormatInt(department.ID, 10)
  26602. data["config"] = config
  26603. data["begin_time"] = begin_time
  26604. bytesData, _ := json.Marshal(data)
  26605. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26606. resp, _ := client.Do(req)
  26607. defer resp.Body.Close()
  26608. body, ioErr := ioutil.ReadAll(resp.Body)
  26609. if ioErr != nil {
  26610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26612. return
  26613. }
  26614. var respJSON map[string]interface{}
  26615. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26618. return
  26619. }
  26620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26621. userJSONBytes, _ := json.Marshal(respJSON)
  26622. fmt.Println("log")
  26623. fmt.Println(string(userJSONBytes))
  26624. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26625. utils.ErrorLog("解析失败:%v", err)
  26626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26627. return
  26628. }
  26629. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26630. data := make(map[string]interface{})
  26631. client := &http.Client{}
  26632. data["psn_no"] = his.PsnNo
  26633. data["mdtrt_id"] = his.Number
  26634. data["opter"] = roles.UserName
  26635. data["org_name"] = miConfig.OrgName
  26636. if reg_type == 11 && his.Insutype == "390" {
  26637. data["med_type"] = "110104"
  26638. } else {
  26639. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26640. }
  26641. data["doctor_id"] = doctor_info.DoctorNumber
  26642. data["doctor_name"] = doctor_info.UserName
  26643. data["department"] = department.Name
  26644. data["fixmedins_code"] = miConfig.Code
  26645. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26646. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26647. data["secret_key"] = miConfig.SecretKey
  26648. data["sick_code"] = sickConfig.CountryCode
  26649. data["sick_name"] = sickConfig.ClassName
  26650. data["dept"] = strconv.FormatInt(department.ID, 10)
  26651. data["config"] = config
  26652. data["begin_time"] = begin_time
  26653. bytesData, _ := json.Marshal(data)
  26654. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26655. resp, _ := client.Do(req)
  26656. defer resp.Body.Close()
  26657. body, ioErr := ioutil.ReadAll(resp.Body)
  26658. if ioErr != nil {
  26659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26661. return
  26662. }
  26663. var respJSON map[string]interface{}
  26664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26667. return
  26668. }
  26669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26670. userJSONBytes, _ := json.Marshal(respJSON)
  26671. fmt.Println("log")
  26672. fmt.Println(string(userJSONBytes))
  26673. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26674. utils.ErrorLog("解析失败:%v", err)
  26675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26676. return
  26677. }
  26678. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26679. utils.ErrorLog("解析失败:%v", doctor_info)
  26680. data := make(map[string]interface{})
  26681. client := &http.Client{}
  26682. data["psn_no"] = his.PsnNo
  26683. data["mdtrt_id"] = his.Number
  26684. data["doctor"] = roles.UserName
  26685. data["department"] = department.Name
  26686. data["org_name"] = miConfig.OrgName
  26687. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26688. data["doctor_id"] = doctor_info.DoctorNumber
  26689. data["new_doctor_name"] = doctor_info.UserName
  26690. data["fixmedins_code"] = miConfig.Code
  26691. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26692. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26693. data["secret_key"] = miConfig.SecretKey
  26694. data["sick_code"] = sickConfig.CountryCode
  26695. data["sick_name"] = sickConfig.ClassName
  26696. data["url"] = miConfig.Url
  26697. data["ak"] = miConfig.AccessKey
  26698. data["begin_time"] = begin_time
  26699. data["cainfo"] = miConfig.Cainfo
  26700. data["dept"] = strconv.FormatInt(department.ID, 10)
  26701. data["config"] = config
  26702. bytesData, _ := json.Marshal(data)
  26703. var req *http.Request
  26704. if miConfig.MdtrtareaAdmvs == "320830" {
  26705. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26706. //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 +
  26707. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26708. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26709. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26710. //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 +
  26711. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26712. } else {
  26713. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26714. }
  26715. resp, _ := client.Do(req)
  26716. defer resp.Body.Close()
  26717. body, ioErr := ioutil.ReadAll(resp.Body)
  26718. if ioErr != nil {
  26719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26721. return
  26722. }
  26723. var respJSON map[string]interface{}
  26724. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26727. return
  26728. }
  26729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26730. userJSONBytes, _ := json.Marshal(respJSON)
  26731. fmt.Println("log")
  26732. fmt.Println(string(userJSONBytes))
  26733. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26734. utils.ErrorLog("解析失败:%v", err)
  26735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26736. return
  26737. }
  26738. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26739. res2.Output = ressix10265.Output
  26740. res2.ErrMsg = ressix10265.ErrMsg
  26741. res2.Cainfo = ressix10265.Cainfo
  26742. res2.WarnMsg = ressix10265.WarnMsg
  26743. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26744. res2.Infcode = infocode
  26745. } else if miConfig.MdtrtareaAdmvs == "150404" {
  26746. data := make(map[string]interface{})
  26747. client := &http.Client{}
  26748. data["psn_no"] = his.PsnNo
  26749. data["mdtrt_id"] = his.Number
  26750. data["doctor"] = roles.UserName
  26751. data["department"] = department.Name
  26752. data["org_name"] = miConfig.OrgName
  26753. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26754. data["doctor_id"] = doctor_info.DoctorNumber
  26755. data["new_doctor_name"] = doctor_info.UserName
  26756. data["fixmedins_code"] = miConfig.Code
  26757. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26758. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26759. data["secret_key"] = miConfig.SecretKey
  26760. data["sick_code"] = sickConfig.CountryCode
  26761. data["sick_name"] = sickConfig.ClassName
  26762. data["url"] = miConfig.Url
  26763. data["ak"] = miConfig.AccessKey
  26764. data["begin_time"] = begin_time
  26765. data["cainfo"] = miConfig.Cainfo
  26766. data["dept"] = strconv.FormatInt(department.ID, 10)
  26767. data["config"] = config
  26768. bytesData, _ := json.Marshal(data)
  26769. var req *http.Request
  26770. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26771. resp, _ := client.Do(req)
  26772. defer resp.Body.Close()
  26773. body, ioErr := ioutil.ReadAll(resp.Body)
  26774. if ioErr != nil {
  26775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26777. return
  26778. }
  26779. var respJSON map[string]interface{}
  26780. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26783. return
  26784. }
  26785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26786. userJSONBytes, _ := json.Marshal(respJSON)
  26787. fmt.Println("log")
  26788. fmt.Println(string(userJSONBytes))
  26789. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26790. utils.ErrorLog("解析失败:%v", err)
  26791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26792. return
  26793. }
  26794. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26795. res2.Output = ressix10265.Output
  26796. res2.ErrMsg = ressix10265.ErrMsg
  26797. res2.Cainfo = ressix10265.Cainfo
  26798. res2.WarnMsg = ressix10265.WarnMsg
  26799. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26800. res2.Infcode = infocode
  26801. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26802. 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)
  26803. saveLog(result, requestLog, "2203", "上传就诊信息")
  26804. var respJSON2 map[string]interface{}
  26805. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26808. return
  26809. }
  26810. userJSONBytes2, _ := json.Marshal(respJSON2)
  26811. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26812. utils.ErrorLog("解析失败:%v", err)
  26813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26814. return
  26815. }
  26816. 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)
  26817. fmt.Println(result2)
  26818. fmt.Println(src_request)
  26819. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26820. data := make(map[string]interface{})
  26821. client := &http.Client{}
  26822. data["psn_no"] = his.PsnNo
  26823. data["mdtrt_id"] = his.Number
  26824. data["doctor"] = roles.UserName
  26825. data["department"] = department.Name
  26826. data["org_name"] = miConfig.OrgName
  26827. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26828. data["doctor_id"] = doctor_info.DoctorNumber
  26829. data["new_doctor_name"] = doctor_info.UserName
  26830. data["fixmedins_code"] = miConfig.Code
  26831. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26832. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26833. data["secret_key"] = miConfig.SecretKey
  26834. data["sick_code"] = sickConfig.CountryCode
  26835. data["sick_name"] = sickConfig.ClassName
  26836. data["url"] = miConfig.Url
  26837. data["ak"] = miConfig.AccessKey
  26838. data["begin_time"] = begin_time
  26839. data["cainfo"] = miConfig.Cainfo
  26840. data["dept"] = strconv.FormatInt(department.ID, 10)
  26841. data["config"] = config
  26842. bytesData, _ := json.Marshal(data)
  26843. var req *http.Request
  26844. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26845. resp, _ := client.Do(req)
  26846. defer resp.Body.Close()
  26847. body, ioErr := ioutil.ReadAll(resp.Body)
  26848. if ioErr != nil {
  26849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26851. return
  26852. }
  26853. var respJSON map[string]interface{}
  26854. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26857. return
  26858. }
  26859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26860. userJSONBytes, _ := json.Marshal(respJSON)
  26861. fmt.Println("log")
  26862. fmt.Println(string(userJSONBytes))
  26863. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26864. utils.ErrorLog("解析失败:%v", err)
  26865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26866. return
  26867. }
  26868. } else {
  26869. if miConfig.MdtrtareaAdmvs == "440781" { //
  26870. 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)
  26871. } else {
  26872. if miConfig.Code == "H15049901371" {
  26873. //赤峰地区国家医保医疗类别
  26874. //职工透析:医疗类别选特殊情况门诊990502
  26875. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26876. var med_type string
  26877. if his.Insutype == "390" {
  26878. if reg_type == 14 {
  26879. med_type = "9933"
  26880. } else if reg_type == 11 {
  26881. med_type = "11"
  26882. }
  26883. } else if his.Insutype == "310" {
  26884. if reg_type == 14 {
  26885. med_type = "990502"
  26886. } else if reg_type == 11 {
  26887. med_type = "11"
  26888. }
  26889. }
  26890. 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)
  26891. } else {
  26892. 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)
  26893. }
  26894. }
  26895. saveLog(result, requestLog, "2203", "上传就诊信息")
  26896. var respJSON2 map[string]interface{}
  26897. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26900. return
  26901. }
  26902. userJSONBytes2, _ := json.Marshal(respJSON2)
  26903. if miConfig.Code == "H15049901371" {
  26904. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26905. utils.ErrorLog("解析失败:%v", err)
  26906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26907. return
  26908. }
  26909. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26910. res2.Output = ressix10265.Output
  26911. res2.ErrMsg = ressix10265.ErrMsg
  26912. res2.Cainfo = ressix10265.Cainfo
  26913. res2.WarnMsg = ressix10265.WarnMsg
  26914. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26915. res2.Infcode = infocode
  26916. } else {
  26917. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26918. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26919. utils.ErrorLog("解析失败:%v", err)
  26920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26921. return
  26922. }
  26923. res2.Infcode = res3.Infcode
  26924. } else {
  26925. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26926. utils.ErrorLog("解析失败:%v", err)
  26927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26928. return
  26929. }
  26930. }
  26931. }
  26932. }
  26933. if res2.Infcode == -1 {
  26934. adminUser := c.GetAdminUserInfo()
  26935. errlog := &models.HisOrderError{
  26936. UserOrgId: adminUser.CurrentOrgId,
  26937. Ctime: time.Now().Unix(),
  26938. Mtime: time.Now().Unix(),
  26939. ErrMsg: res2.ErrMsg,
  26940. Status: 1,
  26941. PatientId: id,
  26942. RecordTime: recordDateTime,
  26943. Stage: 3,
  26944. }
  26945. service.CreateErrMsgLog(errlog)
  26946. c.ServeSuccessJSON(map[string]interface{}{
  26947. "failed_code": -10,
  26948. "msg": res2.ErrMsg,
  26949. })
  26950. return
  26951. } else {
  26952. his.Diagnosis = diagnosis_id
  26953. his.SickType = sickConfig.ID
  26954. //var p_type int64
  26955. //if reg_type == 1111 || reg_type == 1112 {
  26956. // p_type = 11
  26957. //
  26958. //}
  26959. his.PType = fmt.Sprintf("%d", reg_type)
  26960. service.UpdateHisPatientThree(&his)
  26961. data := make(map[string]interface{})
  26962. if settle_accounts_type == 1 { //日结
  26963. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26964. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26965. } else {
  26966. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26967. }
  26968. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26969. data["pre"] = prescriptions
  26970. } else { //月结
  26971. start_time_str := c.GetString("start_time")
  26972. end_time_str := c.GetString("end_time")
  26973. timeLayout := "2006-01-02"
  26974. loc, _ := time.LoadLocation("Local")
  26975. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26976. if err != nil {
  26977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26978. return
  26979. }
  26980. recordStartTime := theStartTime.Unix()
  26981. start_time = recordStartTime
  26982. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26983. if err != nil {
  26984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26985. return
  26986. }
  26987. recordEndTime := theEndTime.Unix()
  26988. end_time = recordEndTime
  26989. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26990. data["pre"] = prescriptions
  26991. }
  26992. timestamp := time.Now().Unix()
  26993. tempTime := time.Unix(timestamp, 0)
  26994. timeFormat := tempTime.Format("20060102150405")
  26995. chrgBchno := rand.Intn(100000) + 10000
  26996. new_chrg_bchno := ""
  26997. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26998. new_chrg_bchno = chrg_bchno
  26999. strconv.FormatInt(his.PatientId, 10)
  27000. client := &http.Client{}
  27001. if adminUser.CurrentOrgId == 10265 {
  27002. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27003. new_chrg_bchno = "0000"
  27004. }
  27005. }
  27006. data["psn_no"] = his.PsnNo
  27007. data["mdtrt_id"] = his.Number
  27008. data["chrg_bchno"] = new_chrg_bchno
  27009. data["org_name"] = miConfig.OrgName
  27010. data["doctor"] = doctor_info.UserName
  27011. data["doctor_id"] = doctor_info.DoctorNumber
  27012. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  27013. data["fixmedins_code"] = miConfig.Code
  27014. data["dept_code"] = department.Number
  27015. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27016. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27017. data["secret_key"] = miConfig.SecretKey
  27018. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  27019. data["url"] = miConfig.Url
  27020. data["ak"] = miConfig.AccessKey
  27021. data["new_doctor_name"] = patientPrescription.Doctor
  27022. data["diag_code"] = sickConfig.CountryCode
  27023. data["cainfo"] = miConfig.Cainfo
  27024. data["opter"] = roles.UserName
  27025. var ids []int64
  27026. for _, item := range prescriptions {
  27027. ids = append(ids, item.ID)
  27028. }
  27029. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27030. if config.IsOpen == 1 { //对接了医保,走医保流程
  27031. var res ResultFour
  27032. var resFour10265 ResultFour10265
  27033. if miConfig.MdtrtareaAdmvs == "421300" {
  27034. bytesData, _ := json.Marshal(data)
  27035. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27036. resp, _ := client.Do(req)
  27037. defer resp.Body.Close()
  27038. body, ioErr := ioutil.ReadAll(resp.Body)
  27039. if ioErr != nil {
  27040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27042. return
  27043. }
  27044. var respJSON map[string]interface{}
  27045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27048. return
  27049. }
  27050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27051. userJSONBytes, _ := json.Marshal(respJSON)
  27052. fmt.Println("log")
  27053. fmt.Println(string(userJSONBytes))
  27054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27055. utils.ErrorLog("解析失败:%v", err)
  27056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27057. return
  27058. }
  27059. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27060. bytesData, _ := json.Marshal(data)
  27061. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27062. resp, _ := client.Do(req)
  27063. defer resp.Body.Close()
  27064. body, ioErr := ioutil.ReadAll(resp.Body)
  27065. if ioErr != nil {
  27066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27068. return
  27069. }
  27070. var respJSON map[string]interface{}
  27071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27074. return
  27075. }
  27076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27077. userJSONBytes, _ := json.Marshal(respJSON)
  27078. fmt.Println("log")
  27079. fmt.Println(string(userJSONBytes))
  27080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27081. utils.ErrorLog("解析失败:%v", err)
  27082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27083. return
  27084. }
  27085. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27086. bytesData, _ := json.Marshal(data)
  27087. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27088. resp, _ := client.Do(req)
  27089. defer resp.Body.Close()
  27090. body, ioErr := ioutil.ReadAll(resp.Body)
  27091. if ioErr != nil {
  27092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27094. return
  27095. }
  27096. var respJSON map[string]interface{}
  27097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27100. return
  27101. }
  27102. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27103. userJSONBytes, _ := json.Marshal(respJSON)
  27104. fmt.Println("log")
  27105. fmt.Println(string(userJSONBytes))
  27106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27107. utils.ErrorLog("解析失败:%v", err)
  27108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27109. return
  27110. }
  27111. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27112. bytesData, _ := json.Marshal(data)
  27113. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27114. resp, _ := client.Do(req)
  27115. defer resp.Body.Close()
  27116. body, ioErr := ioutil.ReadAll(resp.Body)
  27117. if ioErr != nil {
  27118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27120. return
  27121. }
  27122. var respJSON map[string]interface{}
  27123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27126. return
  27127. }
  27128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27129. userJSONBytes, _ := json.Marshal(respJSON)
  27130. fmt.Println("log")
  27131. fmt.Println(string(userJSONBytes))
  27132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27133. utils.ErrorLog("解析失败:%v", err)
  27134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27135. return
  27136. }
  27137. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27138. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27139. var result3101 Result3101
  27140. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27141. result3101.Infcode = "0"
  27142. if result3101.Infcode == "0" {
  27143. if len(result3101.Output.Result) > 0 {
  27144. var errMsgs []string
  27145. for _, item := range result3101.Output.Result {
  27146. errMsgs = append(errMsgs, item.VolaCont)
  27147. }
  27148. c.ServeSuccessJSON(map[string]interface{}{
  27149. "failed_code": -10,
  27150. "msg": errMsgs,
  27151. })
  27152. return
  27153. }
  27154. }
  27155. bytesData, _ := json.Marshal(data)
  27156. var req *http.Request
  27157. if miConfig.MdtrtareaAdmvs == "320830" {
  27158. data["diag_code"] = sickConfig.CountryCode
  27159. fmt.Println(data)
  27160. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  27161. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27162. data["diag_code"] = sickConfig.CountryCode
  27163. fmt.Println(data)
  27164. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27165. } else {
  27166. data["diag_code"] = sickConfig.CountryCode
  27167. fmt.Println(data)
  27168. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27169. }
  27170. resp, _ := client.Do(req)
  27171. defer resp.Body.Close()
  27172. body, ioErr := ioutil.ReadAll(resp.Body)
  27173. if ioErr != nil {
  27174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27176. return
  27177. }
  27178. var respJSON map[string]interface{}
  27179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27182. return
  27183. }
  27184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27185. userJSONBytes, _ := json.Marshal(respJSON)
  27186. fmt.Println("log")
  27187. fmt.Println(string(userJSONBytes))
  27188. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27189. utils.ErrorLog("解析失败:%v", err)
  27190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27191. return
  27192. }
  27193. res.InfRefmsgid = resFour10265.InfRefmsgid
  27194. res.Output = resFour10265.Output
  27195. res.ErrMsg = resFour10265.ErrMsg
  27196. res.Cainfo = resFour10265.Cainfo
  27197. res.WarnMsg = resFour10265.WarnMsg
  27198. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27199. res.Infcode = infocode
  27200. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27201. var pagesize int = 2
  27202. var start int = 1
  27203. var stop int
  27204. var pagecount int
  27205. var curpage int
  27206. var isSuccess bool = true
  27207. data["doctor_id"] = doctor_info.DoctorNumber
  27208. //总页数,向上取整,注意除之前要先转换类型为float64
  27209. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27210. for curpage = 1; curpage <= pagecount; curpage++ {
  27211. if curpage == 1 {
  27212. start = 1
  27213. } else {
  27214. start = (curpage-1)*pagesize + 1
  27215. }
  27216. stop = curpage * pagesize
  27217. if stop > len(prescriptions) {
  27218. stop = len(prescriptions)
  27219. }
  27220. //var requestLog string
  27221. data["pre"] = prescriptions[start-1 : stop]
  27222. fmt.Println(data["pre"])
  27223. bytesData, _ := json.Marshal(data)
  27224. var req *http.Request
  27225. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27226. resp, _ := client.Do(req)
  27227. defer resp.Body.Close()
  27228. body, ioErr := ioutil.ReadAll(resp.Body)
  27229. if ioErr != nil {
  27230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27232. return
  27233. }
  27234. var respJSON map[string]interface{}
  27235. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27238. return
  27239. }
  27240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27241. userJSONBytes, _ := json.Marshal(respJSON)
  27242. fmt.Println("log")
  27243. fmt.Println(string(userJSONBytes))
  27244. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27245. utils.ErrorLog("解析失败:%v", err)
  27246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27247. return
  27248. }
  27249. res.InfRefmsgid = resFour10265.InfRefmsgid
  27250. res.Output = resFour10265.Output
  27251. res.ErrMsg = resFour10265.ErrMsg
  27252. res.Cainfo = resFour10265.Cainfo
  27253. res.WarnMsg = resFour10265.WarnMsg
  27254. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27255. res.Infcode = infocode
  27256. if infocode == 0 {
  27257. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27258. } else {
  27259. isSuccess = false
  27260. errlog := &models.HisOrderError{
  27261. UserOrgId: adminUser.CurrentOrgId,
  27262. Ctime: time.Now().Unix(),
  27263. Mtime: time.Now().Unix(),
  27264. Number: chrg_bchno,
  27265. ErrMsg: "",
  27266. Status: 1,
  27267. PatientId: id,
  27268. RecordTime: recordDateTime,
  27269. Stage: 4,
  27270. }
  27271. service.CreateErrMsgLog(errlog)
  27272. c.ServeSuccessJSON(map[string]interface{}{
  27273. "failed_code": -10,
  27274. "msg": res.ErrMsg,
  27275. })
  27276. return
  27277. }
  27278. }
  27279. if isSuccess {
  27280. res.Infcode = 0
  27281. }
  27282. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27283. 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)
  27284. var dat map[string]interface{}
  27285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27286. fmt.Println(dat)
  27287. } else {
  27288. fmt.Println(err)
  27289. }
  27290. saveLog(result, request_log, "2204", "上传费用明细")
  27291. userJSONBytes, _ := json.Marshal(dat)
  27292. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27293. utils.ErrorLog("解析失败:%v", err)
  27294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27295. return
  27296. }
  27297. res.InfRefmsgid = resFour10265.InfRefmsgid
  27298. res.Output = resFour10265.Output
  27299. res.ErrMsg = resFour10265.ErrMsg
  27300. res.Cainfo = resFour10265.Cainfo
  27301. res.WarnMsg = resFour10265.WarnMsg
  27302. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27303. res.Infcode = infocode
  27304. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27305. bytesData, _ := json.Marshal(data)
  27306. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27307. resp, _ := client.Do(req)
  27308. defer resp.Body.Close()
  27309. body, ioErr := ioutil.ReadAll(resp.Body)
  27310. if ioErr != nil {
  27311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27313. return
  27314. }
  27315. var respJSON map[string]interface{}
  27316. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27319. return
  27320. }
  27321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27322. userJSONBytes, _ := json.Marshal(respJSON)
  27323. fmt.Println("log")
  27324. fmt.Println(string(userJSONBytes))
  27325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27326. utils.ErrorLog("解析失败:%v", err)
  27327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27328. return
  27329. }
  27330. } else {
  27331. if miConfig.Code == "H15049901371" {
  27332. 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)
  27333. var dat map[string]interface{}
  27334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27335. fmt.Println(dat)
  27336. } else {
  27337. fmt.Println(err)
  27338. }
  27339. saveLog(result, request_log, "2204", "上传费用明细")
  27340. userJSONBytes, _ := json.Marshal(dat)
  27341. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27342. utils.ErrorLog("解析失败:%v", err)
  27343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27344. return
  27345. }
  27346. res.InfRefmsgid = resFour10265.InfRefmsgid
  27347. res.Output = resFour10265.Output
  27348. res.ErrMsg = resFour10265.ErrMsg
  27349. res.Cainfo = resFour10265.Cainfo
  27350. res.WarnMsg = resFour10265.WarnMsg
  27351. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27352. res.Infcode = infocode
  27353. } else {
  27354. 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)
  27355. var dat map[string]interface{}
  27356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27357. fmt.Println(dat)
  27358. } else {
  27359. fmt.Println(err)
  27360. }
  27361. saveLog(result, request_log, "2204", "上传费用明细")
  27362. userJSONBytes, _ := json.Marshal(dat)
  27363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27364. utils.ErrorLog("解析失败:%v", err)
  27365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27366. return
  27367. }
  27368. }
  27369. }
  27370. if res.Infcode == 0 {
  27371. order := &models.HisOrder{
  27372. UserOrgId: adminUser.CurrentOrgId,
  27373. HisPatientId: his.ID,
  27374. PatientId: his.PatientId,
  27375. SettleAccountsDate: recordDateTime,
  27376. MdtrtId: his.Number,
  27377. PsnNo: his.PsnNo,
  27378. MedType: strconv.FormatInt(reg_type, 10),
  27379. Ctime: time.Now().Unix(),
  27380. Mtime: time.Now().Unix(),
  27381. Status: 1,
  27382. Number: chrg_bchno,
  27383. Infcode: res.Infcode,
  27384. WarnMsg: res.WarnMsg,
  27385. Cainfo: res.Cainfo,
  27386. ErrMsg: res.ErrMsg,
  27387. RespondTime: res.RefmsgTime,
  27388. InfRefmsgid: res.InfRefmsgid,
  27389. OrderStatus: 1,
  27390. PayWay: pay_way,
  27391. PayWays: pay_ways,
  27392. OthDesc: oth_desc,
  27393. PayPrice: pay_price,
  27394. PayCardNo: pay_card_no,
  27395. DiscountPrice: discount_price,
  27396. PreferentialPrice: preferential_price,
  27397. RealityPrice: reality_price,
  27398. FoundPrice: found_price,
  27399. MedicalInsurancePrice: medical_insurance_price,
  27400. PrivatePrice: private_price,
  27401. IsMedicineInsurance: 1,
  27402. SettleType: settle_accounts_type,
  27403. SettleStartTime: start_time,
  27404. SettleEndTime: end_time,
  27405. Creator: roles.AdminUserId,
  27406. Modify: roles.AdminUserId,
  27407. FaPiaoNumber: fapiao_number,
  27408. FaPiaoCode: fapiao_code,
  27409. PType: 2,
  27410. Diagnosis: diagnosis_id,
  27411. CashPay: cash_pay,
  27412. WechatPay: wechat_pay,
  27413. AliPay: ali_pay,
  27414. JifenPay: jifen_pay,
  27415. BandCardPay: band_card_pay,
  27416. }
  27417. err = service.CreateOrder(order)
  27418. if err != nil {
  27419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27420. return
  27421. }
  27422. for _, item := range res.Output.Result {
  27423. temp := strings.Split(item.FeedetlSn, "-")
  27424. var advice_id int64 = 0
  27425. var project_id int64 = 0
  27426. var types int64 = 0
  27427. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27428. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27429. if temp[1] == "1" {
  27430. advice_id = id
  27431. project_id = 0
  27432. } else if temp[1] == "2" {
  27433. advice_id = 0
  27434. project_id = id
  27435. }
  27436. if item.MedChrgitmType == "9" {
  27437. item.MedChrgitmType = "09"
  27438. }
  27439. info := &models.HisOrderInfo{
  27440. OrderNumber: order.Number,
  27441. FeedetlSn: item.FeedetlSn,
  27442. UploadDate: time.Now().Unix(),
  27443. AdviceId: advice_id,
  27444. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27445. Cnt: item.Cnt,
  27446. Pric: float64(item.Pric),
  27447. PatientId: his.PatientId,
  27448. PricUplmtAmt: item.PricUplmtAmt,
  27449. SelfpayProp: item.SelfpayProp,
  27450. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27451. OverlmtAmt: item.OverlmtAmt,
  27452. PreselfpayAmt: item.PreselfpayAmt,
  27453. BasMednFlag: item.BasMednFlag,
  27454. MedChrgitmType: item.MedChrgitmType,
  27455. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27456. Status: 1,
  27457. Memo: item.Memo,
  27458. Mtime: time.Now().Unix(),
  27459. InscpScpAmt: item.InscpScpAmt,
  27460. DrtReimFlag: item.DrtReimFlag,
  27461. Ctime: time.Now().Unix(),
  27462. ListSpItemFlag: item.ListSpItemFlag,
  27463. ChldMedcFlag: item.ChldMedcFlag,
  27464. LmtUsedFlag: item.LmtUsedFlag,
  27465. ChrgitmLv: item.ChrgitmLv,
  27466. UserOrgId: adminUser.CurrentOrgId,
  27467. HisPatientId: his.ID,
  27468. OrderId: order.ID,
  27469. ProjectId: project_id,
  27470. Type: types,
  27471. }
  27472. service.CreateOrderInfo(info)
  27473. }
  27474. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27475. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27476. var total float64
  27477. for _, item := range prescriptions {
  27478. if item.Type == 1 { //药品
  27479. for _, subItem := range item.HisDoctorAdviceInfo {
  27480. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27481. total_one := price * subItem.PrescribingNumber
  27482. total = total + total_one
  27483. }
  27484. }
  27485. if item.Type == 2 { //项目
  27486. for _, subItem := range item.HisPrescriptionProject {
  27487. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27488. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27489. total_one := price * cnt
  27490. total = total + total_one
  27491. }
  27492. }
  27493. }
  27494. allTotal := fmt.Sprintf("%.2f", total)
  27495. //if adminUser.CurrentOrgId == 9919 {
  27496. //
  27497. // allTotal = fmt.Sprintf("%.2f", total)
  27498. //
  27499. //} else {
  27500. //
  27501. // allTotal = fmt.Sprintf("%.2f", total)
  27502. //
  27503. //}
  27504. if res.Infcode == 0 {
  27505. var rf []*ResultFive
  27506. json.Unmarshal([]byte(his.Iinfo), &rf)
  27507. chrg_bchno := chrg_bchno
  27508. cert_no := his.Certno
  27509. var insutypes []string
  27510. var insutype string
  27511. var is390 int = 0
  27512. var is310 int = 0
  27513. for _, item := range rf {
  27514. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27515. insutypes = append(insutypes, item.Insutype)
  27516. }
  27517. }
  27518. if len(insutypes) == 1 {
  27519. insutype = insutypes[0]
  27520. } else {
  27521. for _, i := range insutypes {
  27522. if i == "390" {
  27523. is390 = 1
  27524. }
  27525. if i == "310" {
  27526. is310 = 1
  27527. }
  27528. }
  27529. }
  27530. if is390 == 1 {
  27531. insutype = "390"
  27532. }
  27533. if is310 == 1 {
  27534. insutype = "310"
  27535. }
  27536. if len(insutypes) == 0 {
  27537. insutype = "310"
  27538. }
  27539. if len(insutypes) == 2 {
  27540. insutype = strconv.FormatInt(his.SocialType, 10)
  27541. }
  27542. insutype = strconv.FormatInt(his.SocialType, 10)
  27543. //insutype = "390"
  27544. if his.IdCardType == 1 {
  27545. // cert_no = his.MedicalInsuranceNumber
  27546. cert_no = his.Certno
  27547. } else {
  27548. cert_no = his.Certno
  27549. }
  27550. var res ResultSeven
  27551. var resSeven10265 ResultSeven10265
  27552. var gzresSeven10265Two GZResultSeven10265Two
  27553. var src_resquest string
  27554. var result2 string
  27555. if miConfig.MdtrtareaAdmvs == "421300" {
  27556. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27557. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27558. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27559. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27560. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27561. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27562. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27563. resp, requestErr := http.Get(api)
  27564. if requestErr != nil {
  27565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27566. return
  27567. }
  27568. body, ioErr := ioutil.ReadAll(resp.Body)
  27569. if ioErr != nil {
  27570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27572. return
  27573. }
  27574. var respJSON map[string]interface{}
  27575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27578. return
  27579. }
  27580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27581. result, _ := json.Marshal(respJSON)
  27582. if miConfig.Code == "H15049901371" {
  27583. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27584. utils.ErrorLog("解析失败:%v", err)
  27585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27586. return
  27587. }
  27588. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27589. res.Output = resSeven10265.Output
  27590. res.ErrMsg = resSeven10265.ErrMsg
  27591. res.Cainfo = resSeven10265.Cainfo
  27592. res.WarnMsg = resSeven10265.WarnMsg
  27593. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27594. res.Infcode = infocode
  27595. } else {
  27596. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27597. utils.ErrorLog("解析失败:%v", err)
  27598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27599. return
  27600. }
  27601. }
  27602. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27603. if reg_type == 11 && his.Insutype == "390" {
  27604. reg_type = 110104
  27605. }
  27606. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27607. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27608. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27609. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27610. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27611. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27612. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27613. resp, requestErr := http.Get(api)
  27614. if requestErr != nil {
  27615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27616. return
  27617. }
  27618. body, ioErr := ioutil.ReadAll(resp.Body)
  27619. if ioErr != nil {
  27620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27622. return
  27623. }
  27624. var respJSON map[string]interface{}
  27625. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27628. return
  27629. }
  27630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27631. result, _ := json.Marshal(respJSON)
  27632. if miConfig.Code == "H15049901371" {
  27633. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27634. utils.ErrorLog("解析失败:%v", err)
  27635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27636. return
  27637. }
  27638. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27639. res.Output = resSeven10265.Output
  27640. res.ErrMsg = resSeven10265.ErrMsg
  27641. res.Cainfo = resSeven10265.Cainfo
  27642. res.WarnMsg = resSeven10265.WarnMsg
  27643. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27644. res.Infcode = infocode
  27645. } else {
  27646. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27647. utils.ErrorLog("解析失败:%v", err)
  27648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27649. return
  27650. }
  27651. }
  27652. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27653. if reg_type == 11 && his.Insutype == "390" {
  27654. reg_type = 110104
  27655. }
  27656. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27657. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27658. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27659. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27660. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27661. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27662. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27663. resp, requestErr := http.Get(api)
  27664. if requestErr != nil {
  27665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27666. return
  27667. }
  27668. body, ioErr := ioutil.ReadAll(resp.Body)
  27669. if ioErr != nil {
  27670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27672. return
  27673. }
  27674. var respJSON map[string]interface{}
  27675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27678. return
  27679. }
  27680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27681. result, _ := json.Marshal(respJSON)
  27682. if miConfig.Code == "H15049901371" {
  27683. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27684. utils.ErrorLog("解析失败:%v", err)
  27685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27686. return
  27687. }
  27688. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27689. res.Output = resSeven10265.Output
  27690. res.ErrMsg = resSeven10265.ErrMsg
  27691. res.Cainfo = resSeven10265.Cainfo
  27692. res.WarnMsg = resSeven10265.WarnMsg
  27693. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27694. res.Infcode = infocode
  27695. } else {
  27696. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27697. utils.ErrorLog("解析失败:%v", err)
  27698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27699. return
  27700. }
  27701. }
  27702. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27703. if reg_type == 11 && his.Insutype == "390" {
  27704. reg_type = 110104
  27705. }
  27706. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27707. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27708. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27710. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27711. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27712. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27713. resp, requestErr := http.Get(api)
  27714. if requestErr != nil {
  27715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27716. return
  27717. }
  27718. body, ioErr := ioutil.ReadAll(resp.Body)
  27719. if ioErr != nil {
  27720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27722. return
  27723. }
  27724. var respJSON map[string]interface{}
  27725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27728. return
  27729. }
  27730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27731. result, _ := json.Marshal(respJSON)
  27732. if miConfig.Code == "H15049901371" {
  27733. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27734. utils.ErrorLog("解析失败:%v", err)
  27735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27736. return
  27737. }
  27738. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27739. res.Output = resSeven10265.Output
  27740. res.ErrMsg = resSeven10265.ErrMsg
  27741. res.Cainfo = resSeven10265.Cainfo
  27742. res.WarnMsg = resSeven10265.WarnMsg
  27743. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27744. res.Infcode = infocode
  27745. } else {
  27746. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27747. utils.ErrorLog("解析失败:%v", err)
  27748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27749. return
  27750. }
  27751. }
  27752. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27753. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27754. var result3101 Result3101
  27755. //utils.ErrorLog("解析失败:%v", result3101)
  27756. result3101.Infcode = "0"
  27757. if result3101.Infcode == "0" {
  27758. if len(result3101.Output.Result) > 0 {
  27759. var errMsgs []string
  27760. for _, item := range result3101.Output.Result {
  27761. errMsgs = append(errMsgs, item.VolaCont)
  27762. }
  27763. c.ServeSuccessJSON(map[string]interface{}{
  27764. "failed_code": -10,
  27765. "msg": errMsgs,
  27766. })
  27767. return
  27768. } else {
  27769. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27770. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27771. bas := strings.Split(psn_info.CardInfo, "|")
  27772. if his.IdCardType == 1 {
  27773. cert_no = bas[2]
  27774. } else if his.IdCardType == 3 {
  27775. cert_no = his.Certno
  27776. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27777. } else if his.IdCardType == 4 {
  27778. cert_no = his.Certno
  27779. psn_info.VerifyNumber = psn_info.VerifyNumber
  27780. }
  27781. var api string
  27782. if miConfig.MdtrtareaAdmvs == "320830" {
  27783. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27784. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27785. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27787. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27788. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27789. "&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
  27790. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27791. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27792. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27793. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27794. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27795. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27796. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27797. "&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
  27798. } else {
  27799. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27800. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27801. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27802. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27803. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27804. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27805. "&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
  27806. }
  27807. resp, requestErr := http.Get(api)
  27808. if requestErr != nil {
  27809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27810. return
  27811. }
  27812. body, ioErr := ioutil.ReadAll(resp.Body)
  27813. if ioErr != nil {
  27814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27816. return
  27817. }
  27818. var respJSON map[string]interface{}
  27819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27822. return
  27823. }
  27824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27825. result, _ := json.Marshal(respJSON)
  27826. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27827. utils.ErrorLog("解析失败:%v", err)
  27828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27829. return
  27830. }
  27831. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27832. res.Output = resSeven10265.Output
  27833. res.ErrMsg = resSeven10265.ErrMsg
  27834. res.Cainfo = resSeven10265.Cainfo
  27835. res.WarnMsg = resSeven10265.WarnMsg
  27836. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27837. res.Infcode = infocode
  27838. }
  27839. }
  27840. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27841. psn_info, _ := service.GetPsnByPatientId(id)
  27842. var verify_number string
  27843. if psn_info.IdCardType == 4 {
  27844. verify_number = psn_info.VerifyNumber
  27845. } else if psn_info.IdCardType == 1 {
  27846. bas := strings.Split(psn_info.CardInfo, "|")
  27847. cardNumber := bas[2]
  27848. verify_number = cardNumber
  27849. } else {
  27850. psn_info.IdCardType = 2
  27851. verify_number = psn_info.Certno
  27852. }
  27853. var api string
  27854. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27855. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27856. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27857. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27858. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27859. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27860. "&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
  27861. resp, requestErr := http.Get(api)
  27862. if requestErr != nil {
  27863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27864. return
  27865. }
  27866. body, ioErr := ioutil.ReadAll(resp.Body)
  27867. if ioErr != nil {
  27868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27870. return
  27871. }
  27872. var respJSON map[string]interface{}
  27873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27876. return
  27877. }
  27878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27879. result, _ := json.Marshal(respJSON)
  27880. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27881. utils.ErrorLog("解析失败:%v", err)
  27882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27883. return
  27884. }
  27885. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27886. res.Output = resSeven10265.Output
  27887. res.ErrMsg = resSeven10265.ErrMsg
  27888. res.Cainfo = resSeven10265.Cainfo
  27889. res.WarnMsg = resSeven10265.WarnMsg
  27890. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27891. res.Infcode = infocode
  27892. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27893. var cert_no string
  27894. if his.IdCardType == 4 {
  27895. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27896. cert_no = psn_info.VerifyNumber
  27897. 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)
  27898. } else if his.IdCardType == 1 {
  27899. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27900. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27901. 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)
  27902. }
  27903. //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)
  27904. var dat map[string]interface{}
  27905. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27906. fmt.Println(dat)
  27907. } else {
  27908. fmt.Println(err)
  27909. }
  27910. saveLog(result2, src_resquest, "2207", "结算")
  27911. userJSONBytes, _ := json.Marshal(dat)
  27912. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27913. utils.ErrorLog("解析失败:%v", err)
  27914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27915. return
  27916. }
  27917. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27918. res.Output = resSeven10265.Output
  27919. res.ErrMsg = resSeven10265.ErrMsg
  27920. res.Cainfo = resSeven10265.Cainfo
  27921. res.WarnMsg = resSeven10265.WarnMsg
  27922. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27923. res.Infcode = infocode
  27924. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27925. res2 := c.GetoleInfo()
  27926. if res2.Infcode == 0 {
  27927. var result string
  27928. var request_log string
  27929. var result_log string
  27930. if res2.Output.MdtrtCertType == "02" {
  27931. 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)
  27932. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27933. } else if res2.Output.MdtrtCertType == "01" {
  27934. 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)
  27935. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27936. } else {
  27937. 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)
  27938. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27939. }
  27940. var dat map[string]interface{}
  27941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27942. fmt.Println(dat)
  27943. } else {
  27944. fmt.Println(err)
  27945. }
  27946. userJSONBytes, _ := json.Marshal(dat)
  27947. var res5 ResultTwo
  27948. //var resTwo10265 ResultTwo10265
  27949. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27950. utils.ErrorLog("解析失败:%v", err)
  27951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27952. return
  27953. }
  27954. if res5.Infcode == -1 {
  27955. c.ServeSuccessJSON(map[string]interface{}{
  27956. "failed_code": -10,
  27957. "msg": res5.ErrMsg,
  27958. })
  27959. return
  27960. }
  27961. var insutypes []string
  27962. var insutype string
  27963. var is390 int = 0
  27964. var is310 int = 0
  27965. for _, item := range res5.Output.Iinfo {
  27966. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27967. insutypes = append(insutypes, item.Insutype)
  27968. }
  27969. }
  27970. if len(insutypes) == 1 {
  27971. insutype = insutypes[0]
  27972. } else {
  27973. for _, i := range insutypes {
  27974. if i == "390" {
  27975. is390 = 1
  27976. }
  27977. if i == "310" {
  27978. is310 = 1
  27979. }
  27980. }
  27981. }
  27982. if is390 == 1 {
  27983. insutype = "390"
  27984. }
  27985. if is310 == 1 {
  27986. insutype = "310"
  27987. }
  27988. if len(insutypes) == 0 {
  27989. insutype = "310"
  27990. }
  27991. fmt.Println(insutype)
  27992. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27993. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27994. infoStr := string(Iinfos)
  27995. idetinfoStr := string(Idetinfos)
  27996. psn := &models.HisPsn{
  27997. PsnNo: res5.Output.Baseinfo.PsnNo,
  27998. PatientId: id,
  27999. Certno: res5.Output.Baseinfo.Certno,
  28000. Gend: res5.Output.Baseinfo.Gend,
  28001. Naty: res5.Output.Baseinfo.Naty,
  28002. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28003. PsnName: res5.Output.Baseinfo.PsnName,
  28004. Idetinfo: idetinfoStr,
  28005. Insuinfo: infoStr,
  28006. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28007. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28008. VerifyNumber: res2.Output.EcToken,
  28009. }
  28010. if res2.Output.MdtrtCertType == "01" {
  28011. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28012. psn.VerifyNumber = res2.Output.EcToken
  28013. } else if res2.Output.MdtrtCertType == "02" {
  28014. psn.VerifyNumber = res2.Output.CardNo
  28015. } else {
  28016. psn.VerifyNumber = res2.Output.MdtrtCertNo
  28017. }
  28018. service.CreateHisPsn(psn)
  28019. if res2.Output.MdtrtCertType == "01" {
  28020. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28021. token := res2.Output.EcToken
  28022. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  28023. } else if res2.Output.MdtrtCertType == "02" {
  28024. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  28025. } else {
  28026. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  28027. }
  28028. var dat2 map[string]interface{}
  28029. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28030. fmt.Println(dat2)
  28031. } else {
  28032. fmt.Println(err)
  28033. }
  28034. userJSONBytes3, _ := json.Marshal(dat2)
  28035. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28036. utils.ErrorLog("解析失败:%v", err)
  28037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28038. return
  28039. }
  28040. saveLog(result2, src_resquest, "2207", "结算")
  28041. } else {
  28042. c.ServeSuccessJSON(map[string]interface{}{
  28043. "failed_code": -10,
  28044. "msg": res2.ErrMsg,
  28045. })
  28046. return
  28047. }
  28048. } else {
  28049. if miConfig.Code == "H15049901371" {
  28050. //赤峰地区国家医保医疗类别
  28051. //职工透析:医疗类别选特殊情况门诊990502
  28052. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28053. var med_type string
  28054. if his.Insutype == "390" {
  28055. if reg_type == 14 {
  28056. med_type = "9933"
  28057. } else if reg_type == 11 {
  28058. med_type = "11"
  28059. }
  28060. } else if his.Insutype == "310" {
  28061. if reg_type == 14 {
  28062. med_type = "990502"
  28063. } else if reg_type == 11 {
  28064. med_type = "11"
  28065. }
  28066. }
  28067. 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)
  28068. } else {
  28069. if his.IdCardType == 4 {
  28070. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28071. var token string
  28072. token = psn_info.VerifyNumber
  28073. 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)
  28074. } else {
  28075. if his.IdCardType == 1 {
  28076. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28077. bas := strings.Split(psn_info.CardInfo, "|")
  28078. basNumber := bas[2]
  28079. cert_no = basNumber
  28080. }
  28081. 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)
  28082. }
  28083. }
  28084. //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)
  28085. var dat map[string]interface{}
  28086. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28087. fmt.Println(dat)
  28088. } else {
  28089. fmt.Println(err)
  28090. }
  28091. saveLog(result2, src_resquest, "2207", "结算")
  28092. userJSONBytes, _ := json.Marshal(dat)
  28093. if miConfig.Code == "H15049901371" {
  28094. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28095. utils.ErrorLog("解析失败:%v", err)
  28096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28097. return
  28098. }
  28099. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28100. res.Output = resSeven10265.Output
  28101. res.ErrMsg = resSeven10265.ErrMsg
  28102. res.Cainfo = resSeven10265.Cainfo
  28103. res.WarnMsg = resSeven10265.WarnMsg
  28104. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28105. res.Infcode = infocode
  28106. } else {
  28107. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28108. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28109. utils.ErrorLog("解析失败:%v", err)
  28110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28111. return
  28112. }
  28113. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28114. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28115. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28116. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28117. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28118. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28119. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28120. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28121. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28122. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28123. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28124. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28125. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28126. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28127. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28128. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28129. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28130. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28131. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28132. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28133. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28134. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28135. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28136. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28137. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28138. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28139. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28140. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28141. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28142. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28143. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28144. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28145. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28146. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28147. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28148. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28149. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28150. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28151. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28152. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28153. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28154. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28155. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28156. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28157. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28158. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28159. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28160. res.Cainfo = gzresSeven10265Two.Cainfo
  28161. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28162. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28163. //res.Infcode = infocode
  28164. } else {
  28165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28166. utils.ErrorLog("解析失败:%v", err)
  28167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28168. return
  28169. }
  28170. }
  28171. }
  28172. }
  28173. if res.Infcode == -1 {
  28174. errlog := &models.HisOrderError{
  28175. UserOrgId: adminUser.CurrentOrgId,
  28176. Ctime: time.Now().Unix(),
  28177. Mtime: time.Now().Unix(),
  28178. Number: chrg_bchno,
  28179. ErrMsg: res.ErrMsg,
  28180. Status: 1,
  28181. PatientId: id,
  28182. RecordTime: recordDateTime,
  28183. Stage: 6,
  28184. }
  28185. service.CreateErrMsgLog(errlog)
  28186. c.ServeSuccessJSON(map[string]interface{}{
  28187. "failed_code": -10,
  28188. "msg": res.ErrMsg,
  28189. })
  28190. return
  28191. } else {
  28192. sickConfig, _ := service.FindSickById(his.SickType)
  28193. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28194. order.OrderStatus = 2
  28195. order.Status = 1
  28196. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28197. order.SetlId = res.Output.Setlinfo.SetlID
  28198. order.PsnNo = res.Output.Setlinfo.PsnNo
  28199. order.PsnName = res.Output.Setlinfo.PsnName
  28200. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28201. order.Certno = res.Output.Setlinfo.Certno
  28202. order.Gend = res.Output.Setlinfo.Gend
  28203. order.Naty = res.Output.Setlinfo.Naty
  28204. order.Age = res.Output.Setlinfo.Age
  28205. order.Insutype = res.Output.Setlinfo.Insutype
  28206. order.PsnType = res.Output.Setlinfo.PsnType
  28207. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28208. order.SetlTime = res.Output.Setlinfo.SetlTime
  28209. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28210. if res.Output.Setlinfo.MedType == "140101" {
  28211. order.MedType = "14"
  28212. } else {
  28213. if res.Output.Setlinfo.MedType == "110104" {
  28214. order.MedType = "11"
  28215. } else {
  28216. order.MedType = res.Output.Setlinfo.MedType
  28217. }
  28218. }
  28219. if reg_type == 1112 {
  28220. order.MedType = "1112"
  28221. }
  28222. if reg_type == 1111 {
  28223. order.MedType = "1111"
  28224. }
  28225. order.ClrType = res.Output.Setlinfo.ClrType
  28226. if adminUser.CurrentOrgId == 10480 {
  28227. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28228. order.ClrType = "11"
  28229. } else {
  28230. order.ClrType = "9903"
  28231. }
  28232. }
  28233. if adminUser.CurrentOrgId == 10721 {
  28234. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28235. order.ClrType = "11"
  28236. } else {
  28237. order.ClrType = "9903"
  28238. }
  28239. }
  28240. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28241. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28242. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28243. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28244. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28245. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28246. order.HifpPay = res.Output.Setlinfo.HifpPay
  28247. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28248. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28249. order.HifesPay = res.Output.Setlinfo.HifesPay
  28250. order.HifobPay = res.Output.Setlinfo.HifobPay
  28251. order.MafPay = res.Output.Setlinfo.MafPay
  28252. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28253. order.OthPay = res.Output.Setlinfo.OthPay
  28254. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28255. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28256. order.AcctPay = res.Output.Setlinfo.AcctPay
  28257. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28258. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28259. order.Balc = res.Output.Setlinfo.Balc
  28260. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28261. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28262. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28263. //order.ClrType = res.Output.Setlinfo.ClrType
  28264. order.ClrWay = res.Output.Setlinfo.ClrWay
  28265. order.Creator = order.Creator
  28266. order.Modify = roles.AdminUserId
  28267. order.RequestLog = src_resquest
  28268. order.FaPiaoNumber = fapiao_number
  28269. order.FaPiaoCode = fapiao_code
  28270. order.SickName = sickConfig.ClassName
  28271. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28272. //detailStr := string(setlDetail)
  28273. //order.SetlDetail = detailStr
  28274. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28275. err = service.UpDateOrder(order)
  28276. if err == nil {
  28277. //判断是否使用了押金
  28278. if dec_way == "true" {
  28279. tmpstring := strconv.FormatInt(order.ID, 10)
  28280. order.Decimal = decimal
  28281. service.UpDateOrder(order)
  28282. //扣押金
  28283. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28284. if errmsg != nil {
  28285. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28286. return
  28287. }
  28288. }
  28289. c.ServeSuccessJSON(map[string]interface{}{
  28290. "msg": "结算成功",
  28291. })
  28292. } else {
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28294. return
  28295. }
  28296. }
  28297. } else {
  28298. adminUser := c.GetAdminUserInfo()
  28299. errlog := &models.HisOrderError{
  28300. UserOrgId: adminUser.CurrentOrgId,
  28301. Ctime: time.Now().Unix(),
  28302. Mtime: time.Now().Unix(),
  28303. ErrMsg: res.ErrMsg,
  28304. Status: 1,
  28305. PatientId: id,
  28306. RecordTime: recordDateTime,
  28307. Stage: 4,
  28308. }
  28309. service.CreateErrMsgLog(errlog)
  28310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28311. return
  28312. }
  28313. } else {
  28314. adminUser := c.GetAdminUserInfo()
  28315. errlog := &models.HisOrderError{
  28316. UserOrgId: adminUser.CurrentOrgId,
  28317. Ctime: time.Now().Unix(),
  28318. Mtime: time.Now().Unix(),
  28319. ErrMsg: res.ErrMsg,
  28320. Status: 1,
  28321. PatientId: id,
  28322. RecordTime: recordDateTime,
  28323. Stage: 4,
  28324. }
  28325. service.CreateErrMsgLog(errlog)
  28326. c.ServeSuccessJSON(map[string]interface{}{
  28327. "failed_code": -10,
  28328. "msg": res.ErrMsg,
  28329. })
  28330. return
  28331. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28332. //return
  28333. }
  28334. }
  28335. }
  28336. } else if tempOrder.ID > 0 {
  28337. if tempOrder.IsPre == 1 {
  28338. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28339. var rf []*ResultFive
  28340. json.Unmarshal([]byte(his.Iinfo), &rf)
  28341. chrg_bchno := tempOrder.Number
  28342. cert_no := his.Certno
  28343. var insutypes []string
  28344. var insutype string
  28345. var is390 int = 0
  28346. var is310 int = 0
  28347. for _, item := range rf {
  28348. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28349. insutypes = append(insutypes, item.Insutype)
  28350. }
  28351. }
  28352. if len(insutypes) == 1 {
  28353. insutype = insutypes[0]
  28354. } else {
  28355. for _, i := range insutypes {
  28356. if i == "390" {
  28357. is390 = 1
  28358. }
  28359. if i == "310" {
  28360. is310 = 1
  28361. }
  28362. }
  28363. }
  28364. if is390 == 1 {
  28365. insutype = "390"
  28366. }
  28367. if is310 == 1 {
  28368. insutype = "310"
  28369. }
  28370. if len(insutypes) == 0 {
  28371. insutype = "310"
  28372. }
  28373. if len(insutypes) == 2 {
  28374. insutype = strconv.FormatInt(his.SocialType, 10)
  28375. }
  28376. //insutype = "390"
  28377. if his.IdCardType == 1 {
  28378. // cert_no = his.MedicalInsuranceNumber
  28379. cert_no = his.Certno
  28380. } else {
  28381. cert_no = his.Certno
  28382. }
  28383. var res ResultSeven
  28384. var ahres ResultSevenAH
  28385. var resSeven10265 ResultSeven10265
  28386. var gzresSeven10265Two GZResultSeven10265Two
  28387. var src_resquest string
  28388. var result2 string
  28389. if miConfig.MdtrtareaAdmvs == "450721" {
  28390. res2 := c.GetoleInfo()
  28391. if res2.Infcode == 0 {
  28392. var result string
  28393. var request_log string
  28394. var result_log string
  28395. if res2.Output.MdtrtCertType == "02" {
  28396. 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)
  28397. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28398. } else if res2.Output.MdtrtCertType == "01" {
  28399. 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)
  28400. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28401. } else {
  28402. 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)
  28403. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28404. }
  28405. var dat map[string]interface{}
  28406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28407. fmt.Println(dat)
  28408. } else {
  28409. fmt.Println(err)
  28410. }
  28411. userJSONBytes, _ := json.Marshal(dat)
  28412. var res5 ResultTwo
  28413. //var resTwo10265 ResultTwo10265
  28414. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28415. utils.ErrorLog("解析失败:%v", err)
  28416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28417. return
  28418. }
  28419. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28420. if res5.Infcode == -1 {
  28421. c.ServeSuccessJSON(map[string]interface{}{
  28422. "failed_code": -10,
  28423. "msg": res5.ErrMsg,
  28424. })
  28425. return
  28426. }
  28427. var insutypes []string
  28428. var insutype string
  28429. var is390 int = 0
  28430. var is310 int = 0
  28431. for _, item := range res5.Output.Iinfo {
  28432. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28433. insutypes = append(insutypes, item.Insutype)
  28434. }
  28435. }
  28436. if len(insutypes) == 1 {
  28437. insutype = insutypes[0]
  28438. } else {
  28439. for _, i := range insutypes {
  28440. if i == "390" {
  28441. is390 = 1
  28442. }
  28443. if i == "310" {
  28444. is310 = 1
  28445. }
  28446. }
  28447. }
  28448. if is390 == 1 {
  28449. insutype = "390"
  28450. }
  28451. if is310 == 1 {
  28452. insutype = "310"
  28453. }
  28454. if len(insutypes) == 0 {
  28455. insutype = "310"
  28456. }
  28457. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28458. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28459. infoStr := string(Iinfos)
  28460. idetinfoStr := string(Idetinfos)
  28461. psn := &models.HisPsn{
  28462. PsnNo: res5.Output.Baseinfo.PsnNo,
  28463. PatientId: id,
  28464. Certno: res5.Output.Baseinfo.Certno,
  28465. Gend: res5.Output.Baseinfo.Gend,
  28466. Naty: res5.Output.Baseinfo.Naty,
  28467. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28468. PsnName: res5.Output.Baseinfo.PsnName,
  28469. Idetinfo: idetinfoStr,
  28470. Insuinfo: infoStr,
  28471. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28472. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28473. VerifyNumber: res2.Output.EcToken,
  28474. }
  28475. service.CreateHisPsn(psn)
  28476. if res2.Output.MdtrtCertType == "01" {
  28477. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28478. token := res2.Output.EcToken
  28479. 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)
  28480. } else if res2.Output.MdtrtCertType == "02" {
  28481. 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)
  28482. } else {
  28483. 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)
  28484. }
  28485. var dat2 map[string]interface{}
  28486. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28487. fmt.Println(dat2)
  28488. } else {
  28489. fmt.Println(err)
  28490. }
  28491. userJSONBytes3, _ := json.Marshal(dat2)
  28492. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28493. utils.ErrorLog("解析失败:%v", err)
  28494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28495. return
  28496. }
  28497. saveLog(result2, src_resquest, "2207", "结算")
  28498. } else {
  28499. c.ServeSuccessJSON(map[string]interface{}{
  28500. "failed_code": -10,
  28501. "msg": res2.ErrMsg,
  28502. })
  28503. return
  28504. }
  28505. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28506. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28507. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28508. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28509. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28510. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28511. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28512. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28513. resp, requestErr := http.Get(api)
  28514. if requestErr != nil {
  28515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28516. return
  28517. }
  28518. body, ioErr := ioutil.ReadAll(resp.Body)
  28519. if ioErr != nil {
  28520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28522. return
  28523. }
  28524. var respJSON map[string]interface{}
  28525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28528. return
  28529. }
  28530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28531. result, _ := json.Marshal(respJSON)
  28532. fmt.Println("log")
  28533. fmt.Println(string(result))
  28534. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28535. utils.ErrorLog("解析失败:%v", err)
  28536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28537. return
  28538. }
  28539. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28540. if reg_type == 11 && his.Insutype == "390" {
  28541. reg_type = 110104
  28542. }
  28543. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28544. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28545. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28547. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28548. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28549. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28550. resp, requestErr := http.Get(api)
  28551. if requestErr != nil {
  28552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28553. return
  28554. }
  28555. body, ioErr := ioutil.ReadAll(resp.Body)
  28556. if ioErr != nil {
  28557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28559. return
  28560. }
  28561. var respJSON map[string]interface{}
  28562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28565. return
  28566. }
  28567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28568. result, _ := json.Marshal(respJSON)
  28569. fmt.Println("log")
  28570. fmt.Println(string(result))
  28571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28572. utils.ErrorLog("解析失败:%v", err)
  28573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28574. return
  28575. }
  28576. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28577. if reg_type == 11 && his.Insutype == "390" {
  28578. reg_type = 110104
  28579. }
  28580. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28581. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28582. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28583. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28584. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28585. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28586. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28587. resp, requestErr := http.Get(api)
  28588. if requestErr != nil {
  28589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28590. return
  28591. }
  28592. body, ioErr := ioutil.ReadAll(resp.Body)
  28593. if ioErr != nil {
  28594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28596. return
  28597. }
  28598. var respJSON map[string]interface{}
  28599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28602. return
  28603. }
  28604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28605. result, _ := json.Marshal(respJSON)
  28606. fmt.Println("log")
  28607. fmt.Println(string(result))
  28608. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28609. utils.ErrorLog("解析失败:%v", err)
  28610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28611. return
  28612. }
  28613. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28614. if reg_type == 11 && his.Insutype == "390" {
  28615. reg_type = 110104
  28616. }
  28617. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28618. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28619. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28620. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28621. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28622. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28623. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28624. resp, requestErr := http.Get(api)
  28625. if requestErr != nil {
  28626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28627. return
  28628. }
  28629. body, ioErr := ioutil.ReadAll(resp.Body)
  28630. if ioErr != nil {
  28631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28633. return
  28634. }
  28635. var respJSON map[string]interface{}
  28636. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28639. return
  28640. }
  28641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28642. result, _ := json.Marshal(respJSON)
  28643. fmt.Println("log")
  28644. fmt.Println(string(result))
  28645. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28646. utils.ErrorLog("解析失败:%v", err)
  28647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28648. return
  28649. }
  28650. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28651. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28652. var result3101 Result3101
  28653. //utils.ErrorLog("解析失败:%v", result3101)
  28654. result3101.Infcode = "0"
  28655. if result3101.Infcode == "0" {
  28656. if len(result3101.Output.Result) > 0 {
  28657. var errMsgs []string
  28658. for _, item := range result3101.Output.Result {
  28659. errMsgs = append(errMsgs, item.VolaCont)
  28660. }
  28661. c.ServeSuccessJSON(map[string]interface{}{
  28662. "failed_code": -10,
  28663. "msg": errMsgs,
  28664. })
  28665. return
  28666. } else {
  28667. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28668. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28669. bas := strings.Split(psn_info.CardInfo, "|")
  28670. if his.IdCardType == 1 {
  28671. cert_no = bas[2]
  28672. } else if his.IdCardType == 3 {
  28673. cert_no = his.Certno
  28674. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28675. } else if his.IdCardType == 4 {
  28676. cert_no = his.Certno
  28677. psn_info.VerifyNumber = psn_info.VerifyNumber
  28678. }
  28679. //江苏地区国家医保医疗类别
  28680. //职工透析:医疗类别选特殊情况门诊9933
  28681. //居民血透门慢: 医疗类别选门诊慢病1402
  28682. //var med_type string
  28683. //if his.Insutype == "310" {
  28684. // if reg_type == 14 {
  28685. // med_type = "9933"
  28686. // } else if reg_type == 11 {
  28687. // med_type = "11"
  28688. //
  28689. // }
  28690. //} else if his.Insutype == "390" {
  28691. // if reg_type == 14 {
  28692. // med_type = "1402"
  28693. // } else if reg_type == 11 {
  28694. // med_type = "11"
  28695. // }
  28696. //}
  28697. var api string
  28698. if miConfig.MdtrtareaAdmvs == "320830" {
  28699. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28700. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28701. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28702. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28703. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28704. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28705. "&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
  28706. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28707. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28708. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28709. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28710. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28711. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28712. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28713. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28714. "&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
  28715. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28716. } else {
  28717. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28718. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28719. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28720. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28721. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28722. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28723. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28724. "&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
  28725. }
  28726. resp, requestErr := http.Get(api)
  28727. if requestErr != nil {
  28728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28729. return
  28730. }
  28731. body, ioErr := ioutil.ReadAll(resp.Body)
  28732. if ioErr != nil {
  28733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28735. return
  28736. }
  28737. var respJSON map[string]interface{}
  28738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28741. return
  28742. }
  28743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28744. result, _ := json.Marshal(respJSON)
  28745. fmt.Println("log")
  28746. fmt.Println(string(result))
  28747. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28748. utils.ErrorLog("解析失败:%v", err)
  28749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28750. return
  28751. }
  28752. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28753. res.Output = resSeven10265.Output
  28754. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28755. res.ErrMsg = resSeven10265.ErrMsg
  28756. res.Cainfo = resSeven10265.Cainfo
  28757. res.WarnMsg = resSeven10265.WarnMsg
  28758. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28759. res.Infcode = infocode
  28760. }
  28761. }
  28762. } else if miConfig.MdtrtareaAdmvs == "150404" {
  28763. psn_info, _ := service.GetPsnByPatientId(id)
  28764. var verify_number string
  28765. if psn_info.IdCardType == 4 {
  28766. verify_number = psn_info.VerifyNumber
  28767. } else if psn_info.IdCardType == 1 {
  28768. bas := strings.Split(psn_info.CardInfo, "|")
  28769. cardNumber := bas[2]
  28770. verify_number = cardNumber
  28771. } else {
  28772. verify_number = psn_info.Certno
  28773. psn_info.IdCardType = 2
  28774. }
  28775. var api string
  28776. new_chrg_bchno := chrg_bchno
  28777. if adminUser.CurrentOrgId == 10265 {
  28778. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28779. new_chrg_bchno = "0000"
  28780. }
  28781. }
  28782. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28783. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28784. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28786. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28787. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28788. "&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
  28789. resp, requestErr := http.Get(api)
  28790. if requestErr != nil {
  28791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28792. return
  28793. }
  28794. body, ioErr := ioutil.ReadAll(resp.Body)
  28795. if ioErr != nil {
  28796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28798. return
  28799. }
  28800. var respJSON map[string]interface{}
  28801. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28804. return
  28805. }
  28806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28807. result, _ := json.Marshal(respJSON)
  28808. fmt.Println("log")
  28809. fmt.Println(string(result))
  28810. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28811. utils.ErrorLog("解析失败:%v", err)
  28812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28813. return
  28814. }
  28815. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28816. res.Output = resSeven10265.Output
  28817. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28818. res.ErrMsg = resSeven10265.ErrMsg
  28819. res.Cainfo = resSeven10265.Cainfo
  28820. res.WarnMsg = resSeven10265.WarnMsg
  28821. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28822. res.Infcode = infocode
  28823. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28824. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28825. var cert_no string
  28826. if his.IdCardType == 1 {
  28827. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28828. } else {
  28829. cert_no = psn_info.VerifyNumber
  28830. }
  28831. 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)
  28832. var dat map[string]interface{}
  28833. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28834. fmt.Println(dat)
  28835. } else {
  28836. fmt.Println(err)
  28837. }
  28838. saveLog(result2, src_resquest, "2207", "结算")
  28839. userJSONBytes, _ := json.Marshal(dat)
  28840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28841. utils.ErrorLog("解析失败:%v", err)
  28842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28843. return
  28844. }
  28845. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28846. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28847. var cert_no string
  28848. var card_sn string
  28849. if his.IdCardType == 1 {
  28850. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28851. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28852. bas := strings.Split(psn_info.CardInfo, "|")
  28853. card_sn = bas[3]
  28854. } else if his.IdCardType == 2 {
  28855. cert_no = his.IdCardNo
  28856. } else {
  28857. cert_no = psn_info.VerifyNumber
  28858. }
  28859. var rf []*ResultFive
  28860. json.Unmarshal([]byte(his.Iinfo), &rf)
  28861. var psn_type string
  28862. for _, item := range rf {
  28863. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28864. psn_type = item.PsnType
  28865. }
  28866. }
  28867. 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)
  28868. var dat map[string]interface{}
  28869. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28870. fmt.Println(dat)
  28871. } else {
  28872. fmt.Println(err)
  28873. }
  28874. saveLog(result2, src_resquest, "2207", "结算")
  28875. userJSONBytes, _ := json.Marshal(dat)
  28876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28877. utils.ErrorLog("解析失败:%v", err)
  28878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28879. return
  28880. }
  28881. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28882. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28883. var cert_no string
  28884. var card_sn string
  28885. if his.IdCardType == 1 {
  28886. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28887. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28888. //bas := strings.Split(psn_info.CardInfo, "|")
  28889. card_sn = ""
  28890. } else if his.IdCardType == 2 {
  28891. cert_no = his.IdCardNo
  28892. } else {
  28893. cert_no = psn_info.VerifyNumber
  28894. }
  28895. var rf []*ResultFive
  28896. json.Unmarshal([]byte(his.Iinfo), &rf)
  28897. var psn_type string
  28898. for _, item := range rf {
  28899. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28900. psn_type = item.PsnType
  28901. }
  28902. }
  28903. 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)
  28904. var dat map[string]interface{}
  28905. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28906. fmt.Println(dat)
  28907. } else {
  28908. fmt.Println(err)
  28909. }
  28910. saveLog(result2, src_resquest, "2207", "结算")
  28911. userJSONBytes, _ := json.Marshal(dat)
  28912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28913. utils.ErrorLog("解析失败:%v", err)
  28914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28915. return
  28916. }
  28917. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28918. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28919. var cert_no string
  28920. var card_sn string
  28921. if his.IdCardType == 1 {
  28922. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28923. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28924. //bas := strings.Split(psn_info.CardInfo, "|")
  28925. card_sn = ""
  28926. } else if his.IdCardType == 2 {
  28927. cert_no = his.IdCardNo
  28928. } else {
  28929. cert_no = psn_info.VerifyNumber
  28930. }
  28931. var rf []*ResultFive
  28932. json.Unmarshal([]byte(his.Iinfo), &rf)
  28933. var psn_type string
  28934. for _, item := range rf {
  28935. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28936. psn_type = item.PsnType
  28937. }
  28938. }
  28939. 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)
  28940. var dat map[string]interface{}
  28941. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28942. fmt.Println(dat)
  28943. } else {
  28944. fmt.Println(err)
  28945. }
  28946. saveLog(result2, src_resquest, "2207", "结算")
  28947. userJSONBytes, _ := json.Marshal(dat)
  28948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28949. utils.ErrorLog("解析失败:%v", err)
  28950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28951. return
  28952. }
  28953. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28954. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28955. if his.IdCardType == 1 {
  28956. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28957. bas := strings.Split(psn_info.CardInfo, "|")
  28958. cert_no = bas[2]
  28959. } else if his.IdCardType == 3 {
  28960. cert_no = his.Certno
  28961. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28962. } else if his.IdCardType == 4 {
  28963. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28964. cert_no = psn_info.VerifyNumber
  28965. psn_info.VerifyNumber = psn_info.VerifyNumber
  28966. } else {
  28967. cert_no = his.Certno
  28968. psn_info.VerifyNumber = his.Certno
  28969. }
  28970. var api string
  28971. var med_type string
  28972. if his.Insutype == "390" {
  28973. if reg_type == 992102 {
  28974. med_type = "992102"
  28975. }
  28976. if reg_type == 1104 {
  28977. med_type = "1104"
  28978. }
  28979. if reg_type == 1104 {
  28980. med_type = "1104"
  28981. }
  28982. if reg_type == 140104 {
  28983. med_type = "140104"
  28984. }
  28985. if reg_type == 140201 {
  28986. med_type = "140201"
  28987. }
  28988. if reg_type == 14 {
  28989. med_type = "14"
  28990. }
  28991. } else if his.Insutype == "310" {
  28992. if reg_type == 1104 {
  28993. med_type = "1104"
  28994. }
  28995. if reg_type == 992102 {
  28996. med_type = "992102"
  28997. }
  28998. if reg_type == 140104 {
  28999. med_type = "140104"
  29000. }
  29001. if reg_type == 140201 {
  29002. med_type = "140201"
  29003. }
  29004. if reg_type == 14 {
  29005. med_type = "14"
  29006. }
  29007. }
  29008. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29009. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29010. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29011. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29012. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29013. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29014. "&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
  29015. resp, requestErr := http.Get(api)
  29016. if requestErr != nil {
  29017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29018. return
  29019. }
  29020. body, ioErr := ioutil.ReadAll(resp.Body)
  29021. if ioErr != nil {
  29022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29024. return
  29025. }
  29026. var respJSON map[string]interface{}
  29027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29030. return
  29031. }
  29032. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29033. if status == "0" {
  29034. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29035. c.ServeSuccessJSON(map[string]interface{}{
  29036. "failed_code": -10,
  29037. "msg": err_msg,
  29038. })
  29039. return
  29040. }
  29041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29042. result, _ := json.Marshal(respJSON)
  29043. fmt.Println("log")
  29044. fmt.Println(string(result))
  29045. if err := json.Unmarshal(result, &ahres); err != nil {
  29046. utils.ErrorLog("解析失败:%v", err)
  29047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29048. return
  29049. }
  29050. res.InfRefmsgid = ahres.InfRefmsgid
  29051. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29052. // 创建对应的Time类型
  29053. t := time.UnixMilli(timestamp)
  29054. // 格式化成指定的日期字符串
  29055. str := t.Format("2006-01-02 15:04:05")
  29056. res.Output.Setlinfo.SetlTime = str
  29057. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29058. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29059. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29060. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29061. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29062. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29063. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29064. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29065. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29066. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29067. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29068. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29069. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29070. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29071. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29072. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29073. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29074. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29075. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29076. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29077. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29078. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29079. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29080. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29081. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29082. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29083. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29084. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29085. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29086. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29087. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29088. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29089. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29090. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29091. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29092. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29093. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29094. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29095. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29096. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29097. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29098. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29099. res.Output.Setldetail = ahres.Output.Setldetail
  29100. res.ErrMsg = ahres.ErrMsg
  29101. res.Cainfo = ahres.Cainfo
  29102. res.WarnMsg = ahres.WarnMsg
  29103. res.Infcode = ahres.Infcode
  29104. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29105. res.Output.Setlinfo.ClrType = "11"
  29106. } else {
  29107. res.Output.Setlinfo.ClrType = "9903"
  29108. }
  29109. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29110. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29111. if his.IdCardType == 1 {
  29112. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29113. bas := strings.Split(psn_info.CardInfo, "|")
  29114. cert_no = bas[2]
  29115. } else if his.IdCardType == 3 {
  29116. cert_no = his.Certno
  29117. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  29118. } else if his.IdCardType == 4 {
  29119. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29120. cert_no = his.Certno
  29121. psn_info.VerifyNumber = psn_info.VerifyNumber
  29122. } else {
  29123. cert_no = his.Certno
  29124. psn_info.VerifyNumber = his.Certno
  29125. }
  29126. var api string
  29127. var med_type string
  29128. if his.Insutype == "390" {
  29129. if reg_type == 1104 {
  29130. med_type = "1104"
  29131. }
  29132. if reg_type == 992102 {
  29133. med_type = "992102"
  29134. }
  29135. if reg_type == 140104 {
  29136. med_type = "140104"
  29137. }
  29138. if reg_type == 14 {
  29139. med_type = "14"
  29140. }
  29141. if reg_type == 140201 {
  29142. med_type = "140201"
  29143. }
  29144. } else if his.Insutype == "310" {
  29145. if reg_type == 1104 {
  29146. med_type = "1104"
  29147. }
  29148. if reg_type == 992102 {
  29149. med_type = "992102"
  29150. }
  29151. if reg_type == 14 {
  29152. med_type = "14"
  29153. }
  29154. if reg_type == 140104 {
  29155. med_type = "140104"
  29156. }
  29157. if reg_type == 140201 {
  29158. med_type = "140201"
  29159. }
  29160. }
  29161. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29162. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29163. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29164. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29165. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29166. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29167. "&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
  29168. resp, requestErr := http.Get(api)
  29169. if requestErr != nil {
  29170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29171. return
  29172. }
  29173. body, ioErr := ioutil.ReadAll(resp.Body)
  29174. if ioErr != nil {
  29175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29177. return
  29178. }
  29179. var respJSON map[string]interface{}
  29180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29183. return
  29184. }
  29185. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29186. if status == "0" {
  29187. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29188. c.ServeSuccessJSON(map[string]interface{}{
  29189. "failed_code": -10,
  29190. "msg": err_msg,
  29191. })
  29192. return
  29193. }
  29194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29195. result, _ := json.Marshal(respJSON)
  29196. fmt.Println("log")
  29197. fmt.Println(string(result))
  29198. if err := json.Unmarshal(result, &ahres); err != nil {
  29199. utils.ErrorLog("解析失败:%v", err)
  29200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29201. return
  29202. }
  29203. res.InfRefmsgid = ahres.InfRefmsgid
  29204. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29205. // 创建对应的Time类型
  29206. t := time.UnixMilli(timestamp)
  29207. // 格式化成指定的日期字符串
  29208. str := t.Format("2006-01-02 15:04:05")
  29209. res.Output.Setlinfo.SetlTime = str
  29210. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29211. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29212. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29213. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29214. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29215. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29216. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29217. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29218. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29219. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29220. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29221. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29222. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29223. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29224. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29225. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29226. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29227. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29228. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29229. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29230. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29231. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29232. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29233. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29234. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29235. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29236. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29237. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29238. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29239. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29240. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29241. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29242. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29243. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29244. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29245. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29246. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29247. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29248. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29249. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29250. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29251. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29252. res.Output.Setldetail = ahres.Output.Setldetail
  29253. res.ErrMsg = ahres.ErrMsg
  29254. res.Cainfo = ahres.Cainfo
  29255. res.WarnMsg = ahres.WarnMsg
  29256. res.Infcode = ahres.Infcode
  29257. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29258. res.Output.Setlinfo.ClrType = "11"
  29259. } else {
  29260. res.Output.Setlinfo.ClrType = "9903"
  29261. }
  29262. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29263. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29264. var cert_no string
  29265. if his.IdCardType == 1 {
  29266. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29267. } else if his.IdCardType == 2 {
  29268. cert_no = his.IdCardNo
  29269. } else {
  29270. cert_no = psn_info.VerifyNumber
  29271. }
  29272. 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, "")
  29273. var dat map[string]interface{}
  29274. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29275. fmt.Println(dat)
  29276. } else {
  29277. fmt.Println(err)
  29278. }
  29279. saveLog(result2, src_resquest, "2207", "结算")
  29280. userJSONBytes, _ := json.Marshal(dat)
  29281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29282. utils.ErrorLog("解析失败:%v", err)
  29283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29284. return
  29285. }
  29286. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29287. psn_info, _ := service.GetPsnByPatientId(id)
  29288. var verify_number string
  29289. if psn_info.IdCardType == 4 {
  29290. verify_number = psn_info.VerifyNumber
  29291. } else if psn_info.IdCardType == 1 {
  29292. bas := strings.Split(psn_info.CardInfo, "|")
  29293. cardNumber := bas[2]
  29294. verify_number = cardNumber
  29295. } else {
  29296. verify_number = psn_info.Certno
  29297. psn_info.IdCardType = 2
  29298. }
  29299. var api string
  29300. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29301. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29302. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29303. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29304. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29305. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29306. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29307. resp, requestErr := http.Get(api)
  29308. if requestErr != nil {
  29309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29310. return
  29311. }
  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(string(body)), &respJSON); err != nil {
  29320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29322. return
  29323. }
  29324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29325. result, _ := json.Marshal(respJSON)
  29326. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29327. utils.ErrorLog("解析失败:%v", err)
  29328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29329. return
  29330. }
  29331. } else {
  29332. var src_resquest string
  29333. if miConfig.Code == "H15049901371" {
  29334. //赤峰地区国家医保医疗类别
  29335. //职工透析:医疗类别选特殊情况门诊990502
  29336. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29337. var med_type string
  29338. if his.Insutype == "390" {
  29339. if reg_type == 14 {
  29340. med_type = "9933"
  29341. } else if reg_type == 11 {
  29342. med_type = "11"
  29343. }
  29344. } else if his.Insutype == "310" {
  29345. if reg_type == 14 {
  29346. med_type = "990502"
  29347. } else if reg_type == 11 {
  29348. med_type = "11"
  29349. }
  29350. }
  29351. 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)
  29352. } else {
  29353. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  29354. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29355. if result3101.Infcode == 0 {
  29356. if len(result3101.Output.Result) > 0 {
  29357. c.ServeSuccessJSON(map[string]interface{}{
  29358. "failed_code": -10,
  29359. "failed_type": 100,
  29360. "warm_type": 2,
  29361. "msg": result3101,
  29362. })
  29363. return
  29364. }
  29365. } else {
  29366. c.ServeSuccessJSON(map[string]interface{}{
  29367. "failed_code": -10,
  29368. "msg": result3101.ErrMsg,
  29369. })
  29370. return
  29371. }
  29372. }
  29373. if his.IdCardType == 4 {
  29374. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29375. token := psn_info.VerifyNumber
  29376. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token, admin_user_id)
  29377. } else {
  29378. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "", admin_user_id)
  29379. }
  29380. }
  29381. var dat map[string]interface{}
  29382. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29383. fmt.Println(dat)
  29384. } else {
  29385. fmt.Println(err)
  29386. }
  29387. saveLog(result2, src_resquest, "2207", "结算")
  29388. userJSONBytes, _ := json.Marshal(dat)
  29389. if miConfig.Code == "H15049901371" {
  29390. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29391. utils.ErrorLog("解析失败:%v", err)
  29392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29393. return
  29394. }
  29395. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29396. res.Output = resSeven10265.Output
  29397. res.ErrMsg = resSeven10265.ErrMsg
  29398. res.Cainfo = resSeven10265.Cainfo
  29399. res.WarnMsg = resSeven10265.WarnMsg
  29400. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29401. res.Infcode = infocode
  29402. } else {
  29403. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29404. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29405. utils.ErrorLog("解析失败:%v", err)
  29406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29407. return
  29408. }
  29409. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29410. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29411. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29412. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29413. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29414. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29415. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29416. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29417. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29418. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29419. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29420. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29421. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29422. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29423. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29424. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29425. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29426. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29427. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29428. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29429. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29430. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29431. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29432. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29433. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29434. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29435. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29436. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29437. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29438. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29439. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29440. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29441. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29442. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29443. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29444. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29445. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29446. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29447. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29448. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29449. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29450. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29451. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29452. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29453. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29454. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29455. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29456. res.Cainfo = gzresSeven10265Two.Cainfo
  29457. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29458. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29459. //res.Infcode = infocode
  29460. } else {
  29461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29462. utils.ErrorLog("解析失败:%v", err)
  29463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29464. return
  29465. }
  29466. }
  29467. }
  29468. }
  29469. if res.Infcode != 0 {
  29470. errlog := &models.HisOrderError{
  29471. UserOrgId: adminUser.CurrentOrgId,
  29472. Ctime: time.Now().Unix(),
  29473. Mtime: time.Now().Unix(),
  29474. Number: chrg_bchno,
  29475. ErrMsg: res.ErrMsg,
  29476. Status: 1,
  29477. PatientId: id,
  29478. RecordTime: recordDateTime,
  29479. Stage: 6,
  29480. }
  29481. service.CreateErrMsgLog(errlog)
  29482. c.ServeSuccessJSON(map[string]interface{}{
  29483. "failed_code": -10,
  29484. "msg": res.ErrMsg,
  29485. })
  29486. return
  29487. } else {
  29488. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29489. order.OrderStatus = 2
  29490. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29491. order.SetlId = res.Output.Setlinfo.SetlID
  29492. order.PsnNo = res.Output.Setlinfo.PsnNo
  29493. order.PsnName = res.Output.Setlinfo.PsnName
  29494. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29495. order.Certno = res.Output.Setlinfo.Certno
  29496. order.Gend = res.Output.Setlinfo.Gend
  29497. order.Naty = res.Output.Setlinfo.Naty
  29498. order.Age = res.Output.Setlinfo.Age
  29499. order.Insutype = res.Output.Setlinfo.Insutype
  29500. order.PsnType = res.Output.Setlinfo.PsnType
  29501. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29502. order.SetlTime = res.Output.Setlinfo.SetlTime
  29503. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29504. order.PayWays = pay_ways
  29505. order.AcctUsedFlag = acct_used_flag
  29506. order.WechatPay = wechat_pay
  29507. order.AliPay = ali_pay
  29508. order.JifenPay = jifen_pay
  29509. order.BandCardPay = band_card_pay
  29510. order.CashPay = cash_pay
  29511. order.OthDesc = oth_desc
  29512. //order.MedType = res.Output.Setlinfo.MedType
  29513. if reg_type == 1112 {
  29514. order.MedType = "1112"
  29515. }
  29516. if reg_type == 1111 {
  29517. order.MedType = "1111"
  29518. }
  29519. order.ClrType = res.Output.Setlinfo.ClrType
  29520. if adminUser.CurrentOrgId == 10480 {
  29521. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29522. order.ClrType = "11"
  29523. } else {
  29524. order.ClrType = "9903"
  29525. }
  29526. }
  29527. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29528. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29529. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29530. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29531. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29532. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29533. order.HifpPay = res.Output.Setlinfo.HifpPay
  29534. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29535. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29536. order.HifesPay = res.Output.Setlinfo.HifesPay
  29537. order.HifobPay = res.Output.Setlinfo.HifobPay
  29538. order.MafPay = res.Output.Setlinfo.MafPay
  29539. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29540. order.OthPay = res.Output.Setlinfo.OthPay
  29541. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29542. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29543. order.AcctPay = res.Output.Setlinfo.AcctPay
  29544. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29545. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29546. order.Balc = res.Output.Setlinfo.Balc
  29547. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29548. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29549. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29550. order.ClrWay = res.Output.Setlinfo.ClrWay
  29551. order.Creator = order.Creator
  29552. order.Modify = roles.AdminUserId
  29553. order.RequestLog = src_resquest
  29554. order.Diagnosis = diagnosis_id
  29555. order.FaPiaoNumber = fapiao_number
  29556. order.FaPiaoCode = fapiao_code
  29557. order.PayCardNo = pay_card_no
  29558. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29559. detailStr := string(setlDetail)
  29560. order.SetlDetail = detailStr
  29561. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29562. err = service.UpDateOrder(order)
  29563. if err == nil {
  29564. //判断是否使用了押金
  29565. if dec_way == "true" {
  29566. tmpstring := strconv.FormatInt(order.ID, 10)
  29567. //扣押金
  29568. order.Decimal = decimal
  29569. service.UpDateOrder(order)
  29570. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29571. if errmsg != nil {
  29572. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29573. return
  29574. }
  29575. }
  29576. c.ServeSuccessJSON(map[string]interface{}{
  29577. "msg": "结算成功",
  29578. })
  29579. } else {
  29580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29581. return
  29582. }
  29583. }
  29584. }
  29585. }
  29586. }
  29587. // 上传明细-预结算-
  29588. func (c *HisApiController) GetPreUploadInfo() {
  29589. id, _ := c.GetInt64("id")
  29590. record_time := c.GetString("record_time")
  29591. his_patient_id, _ := c.GetInt64("his_patient_id")
  29592. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29593. admin_user_id, _ := c.GetInt64("admin_user_id")
  29594. diagnosis_id := c.GetString("diagnosis")
  29595. sick_type, _ := c.GetInt64("sick_type")
  29596. reg_type, _ := c.GetInt64("p_type")
  29597. begin_time := c.GetString("begin_time")
  29598. acct_used_flag := c.GetString("acct_used_flag")
  29599. id_str := c.GetString("ids")
  29600. ids_arr := strings.Split(id_str, ",")
  29601. timeLayout := "2006-01-02"
  29602. loc, _ := time.LoadLocation("Local")
  29603. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29604. if err != nil {
  29605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29606. return
  29607. }
  29608. recordDateTime := theTime.Unix()
  29609. adminUser := c.GetAdminUserInfo()
  29610. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29611. var config []*models.HisXtDiagnoseConfig
  29612. for _, item := range diagnosis_ids {
  29613. id, _ := strconv.ParseInt(item, 10, 64)
  29614. if id > 0 {
  29615. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29616. config = append(config, &diagnosisConfig)
  29617. }
  29618. }
  29619. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29620. sickConfig, _ := service.FindSickById(sick_type)
  29621. var prescriptions []*models.HisPrescription
  29622. var start_time int64
  29623. var end_time int64
  29624. var isSuccess bool = true
  29625. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29626. fmt.Println(his_patient_id)
  29627. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29628. timestamp := time.Now().Unix()
  29629. tempTime := time.Unix(timestamp, 0)
  29630. timeFormat := tempTime.Format("20060102150405")
  29631. chrgBchno := rand.Intn(100000) + 10000
  29632. new_chrg_bchno := ""
  29633. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29634. new_chrg_bchno = chrg_bchno
  29635. if adminUser.CurrentOrgId == 10265 {
  29636. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29637. new_chrg_bchno = "0000"
  29638. }
  29639. }
  29640. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29641. var patientPrescription models.HisPrescriptionInfo
  29642. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29643. if patientPrescription.ID == 0 {
  29644. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29645. }
  29646. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29647. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29648. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29649. strconv.FormatInt(his.PatientId, 10)
  29650. var res2406 Result2406
  29651. //安徽单病种处理
  29652. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29653. data := make(map[string]interface{})
  29654. client := &http.Client{}
  29655. data["psn_no"] = his.PsnNo
  29656. data["mdtrt_id"] = his.Number
  29657. data["operator"] = roles.UserName
  29658. data["cert_no"] = his.IdCardNo
  29659. data["org_name"] = miConfig.OrgName
  29660. data["psn_name"] = his.Name
  29661. data["ipt_otp_no"] = his.IptOtpNo
  29662. data["ipt_psn_sp_flag_type"] = "0901"
  29663. data["ipt_psn_sp_flag"] = "1"
  29664. data["fixmedins_code"] = miConfig.Code
  29665. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29666. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29667. data["url"] = miConfig.Url
  29668. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29669. bytesData, _ := json.Marshal(data)
  29670. var req *http.Request
  29671. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29672. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29673. resp, _ := client.Do(req)
  29674. defer resp.Body.Close()
  29675. body, ioErr := ioutil.ReadAll(resp.Body)
  29676. if ioErr != nil {
  29677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29679. return
  29680. }
  29681. var respJSON map[string]interface{}
  29682. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29685. return
  29686. }
  29687. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29688. if status == "0" {
  29689. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29690. c.ServeSuccessJSON(map[string]interface{}{
  29691. "failed_code": -10,
  29692. "msg": err_msg,
  29693. })
  29694. return
  29695. }
  29696. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29697. userJSONBytes, _ := json.Marshal(respJSON)
  29698. fmt.Println("log")
  29699. fmt.Println(string(userJSONBytes))
  29700. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29701. utils.ErrorLog("解析失败:%v", err)
  29702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29703. return
  29704. }
  29705. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29706. data := make(map[string]interface{})
  29707. client := &http.Client{}
  29708. data["psn_no"] = his.PsnNo
  29709. data["mdtrt_id"] = his.Number
  29710. data["operator"] = roles.UserName
  29711. data["cert_no"] = his.IdCardNo
  29712. data["org_name"] = miConfig.OrgName
  29713. data["psn_name"] = his.Name
  29714. data["ipt_otp_no"] = his.IptOtpNo
  29715. data["ipt_psn_sp_flag_type"] = "0901"
  29716. data["ipt_psn_sp_flag"] = "1"
  29717. data["fixmedins_code"] = miConfig.Code
  29718. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29719. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29720. data["url"] = miConfig.Url
  29721. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29722. bytesData, _ := json.Marshal(data)
  29723. var req *http.Request
  29724. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29725. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29726. resp, _ := client.Do(req)
  29727. defer resp.Body.Close()
  29728. body, ioErr := ioutil.ReadAll(resp.Body)
  29729. if ioErr != nil {
  29730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29732. return
  29733. }
  29734. var respJSON map[string]interface{}
  29735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29738. return
  29739. }
  29740. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29741. if status == "0" {
  29742. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29743. c.ServeSuccessJSON(map[string]interface{}{
  29744. "failed_code": -10,
  29745. "msg": err_msg,
  29746. })
  29747. return
  29748. }
  29749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29750. userJSONBytes, _ := json.Marshal(respJSON)
  29751. fmt.Println("log")
  29752. fmt.Println(string(userJSONBytes))
  29753. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29754. utils.ErrorLog("解析失败:%v", err)
  29755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29756. return
  29757. }
  29758. }
  29759. if res2406.Infcode != 0 {
  29760. adminUser := c.GetAdminUserInfo()
  29761. errlog := &models.HisOrderError{
  29762. UserOrgId: adminUser.CurrentOrgId,
  29763. Ctime: time.Now().Unix(),
  29764. Mtime: time.Now().Unix(),
  29765. ErrMsg: res2406.ErrMsg,
  29766. Status: 1,
  29767. PatientId: id,
  29768. RecordTime: recordDateTime,
  29769. Stage: 3,
  29770. }
  29771. service.CreateErrMsgLog(errlog)
  29772. c.ServeSuccessJSON(map[string]interface{}{
  29773. "failed_code": -10,
  29774. "msg": res2406.ErrMsg,
  29775. })
  29776. return
  29777. }
  29778. var res2 ResultSix
  29779. var res3 GZResultSix
  29780. var resSix10265 ResultSix10265
  29781. //var time_stamp string
  29782. if miConfig.MdtrtareaAdmvs == "421300" {
  29783. data := make(map[string]interface{})
  29784. client := &http.Client{}
  29785. data["psn_no"] = his.PsnNo
  29786. data["mdtrt_id"] = his.Number
  29787. data["department"] = department.Name
  29788. data["org_name"] = miConfig.OrgName
  29789. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29790. data["doctor_id"] = doctor_info.DoctorNumber
  29791. data["doctor_name"] = roles.UserName
  29792. data["fixmedins_code"] = miConfig.Code
  29793. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29794. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29795. data["secret_key"] = miConfig.SecretKey
  29796. data["sick_code"] = sickConfig.CountryCode
  29797. data["sick_name"] = sickConfig.ClassName
  29798. data["begin_time"] = begin_time
  29799. data["dept"] = strconv.FormatInt(department.ID, 10)
  29800. data["config"] = config
  29801. data["opter"] = roles.UserName
  29802. fmt.Println(data)
  29803. bytesData, _ := json.Marshal(data)
  29804. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29805. resp, _ := client.Do(req)
  29806. defer resp.Body.Close()
  29807. body, ioErr := ioutil.ReadAll(resp.Body)
  29808. if ioErr != nil {
  29809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29811. return
  29812. }
  29813. var respJSON map[string]interface{}
  29814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29817. return
  29818. }
  29819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29820. userJSONBytes, _ := json.Marshal(respJSON)
  29821. fmt.Println("log")
  29822. fmt.Println(string(userJSONBytes))
  29823. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29824. utils.ErrorLog("解析失败:%v", err)
  29825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29826. return
  29827. }
  29828. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29829. data := make(map[string]interface{})
  29830. client := &http.Client{}
  29831. data["psn_no"] = his.PsnNo
  29832. data["mdtrt_id"] = his.Number
  29833. data["department"] = department.Name
  29834. data["org_name"] = miConfig.OrgName
  29835. if reg_type == 11 && his.Insutype == "390" {
  29836. data["med_type"] = "110104"
  29837. } else {
  29838. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29839. }
  29840. data["doctor_id"] = doctor_info.DoctorNumber
  29841. data["doctor_name"] = roles.UserName
  29842. data["fixmedins_code"] = miConfig.Code
  29843. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29844. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29845. data["secret_key"] = miConfig.SecretKey
  29846. data["sick_code"] = sickConfig.CountryCode
  29847. data["sick_name"] = sickConfig.ClassName
  29848. data["begin_time"] = begin_time
  29849. data["dept"] = strconv.FormatInt(department.ID, 10)
  29850. data["config"] = config
  29851. data["opter"] = roles.UserName
  29852. fmt.Println(data)
  29853. bytesData, _ := json.Marshal(data)
  29854. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29855. resp, _ := client.Do(req)
  29856. defer resp.Body.Close()
  29857. body, ioErr := ioutil.ReadAll(resp.Body)
  29858. if ioErr != nil {
  29859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29861. return
  29862. }
  29863. var respJSON map[string]interface{}
  29864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29867. return
  29868. }
  29869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29870. userJSONBytes, _ := json.Marshal(respJSON)
  29871. fmt.Println("log")
  29872. fmt.Println(string(userJSONBytes))
  29873. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29874. utils.ErrorLog("解析失败:%v", err)
  29875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29876. return
  29877. }
  29878. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29879. data := make(map[string]interface{})
  29880. client := &http.Client{}
  29881. data["psn_no"] = his.PsnNo
  29882. data["mdtrt_id"] = his.Number
  29883. data["department"] = department.Name
  29884. data["org_name"] = miConfig.OrgName
  29885. if reg_type == 11 && his.Insutype == "390" {
  29886. data["med_type"] = "110104"
  29887. } else {
  29888. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29889. }
  29890. data["doctor_id"] = doctor_info.DoctorNumber
  29891. data["doctor_name"] = roles.UserName
  29892. data["fixmedins_code"] = miConfig.Code
  29893. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29894. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29895. data["secret_key"] = miConfig.SecretKey
  29896. data["sick_code"] = sickConfig.CountryCode
  29897. data["sick_name"] = sickConfig.ClassName
  29898. data["begin_time"] = begin_time
  29899. data["dept"] = strconv.FormatInt(department.ID, 10)
  29900. data["config"] = config
  29901. data["opter"] = roles.UserName
  29902. fmt.Println(data)
  29903. bytesData, _ := json.Marshal(data)
  29904. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29905. resp, _ := client.Do(req)
  29906. defer resp.Body.Close()
  29907. body, ioErr := ioutil.ReadAll(resp.Body)
  29908. if ioErr != nil {
  29909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29911. return
  29912. }
  29913. var respJSON map[string]interface{}
  29914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29917. return
  29918. }
  29919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29920. userJSONBytes, _ := json.Marshal(respJSON)
  29921. fmt.Println("log")
  29922. fmt.Println(string(userJSONBytes))
  29923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29924. utils.ErrorLog("解析失败:%v", err)
  29925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29926. return
  29927. }
  29928. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29929. data := make(map[string]interface{})
  29930. client := &http.Client{}
  29931. data["psn_no"] = his.PsnNo
  29932. data["mdtrt_id"] = his.Number
  29933. data["department"] = department.Name
  29934. data["org_name"] = miConfig.OrgName
  29935. if reg_type == 11 && his.Insutype == "390" {
  29936. data["med_type"] = "110104"
  29937. } else {
  29938. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29939. }
  29940. data["doctor_id"] = doctor_info.DoctorNumber
  29941. data["doctor_name"] = roles.UserName
  29942. data["fixmedins_code"] = miConfig.Code
  29943. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29944. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29945. data["secret_key"] = miConfig.SecretKey
  29946. data["sick_code"] = sickConfig.CountryCode
  29947. data["sick_name"] = sickConfig.ClassName
  29948. data["begin_time"] = begin_time
  29949. data["dept"] = strconv.FormatInt(department.ID, 10)
  29950. data["config"] = config
  29951. data["opter"] = roles.UserName
  29952. fmt.Println(data)
  29953. bytesData, _ := json.Marshal(data)
  29954. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29955. resp, _ := client.Do(req)
  29956. defer resp.Body.Close()
  29957. body, ioErr := ioutil.ReadAll(resp.Body)
  29958. if ioErr != nil {
  29959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29961. return
  29962. }
  29963. var respJSON map[string]interface{}
  29964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29967. return
  29968. }
  29969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29970. userJSONBytes, _ := json.Marshal(respJSON)
  29971. fmt.Println("log")
  29972. fmt.Println(string(userJSONBytes))
  29973. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29974. utils.ErrorLog("解析失败:%v", err)
  29975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29976. return
  29977. }
  29978. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29979. utils.ErrorLog("解析失败:%v", doctor_info)
  29980. data := make(map[string]interface{})
  29981. client := &http.Client{}
  29982. data["psn_no"] = his.PsnNo
  29983. data["mdtrt_id"] = his.Number
  29984. data["doctor"] = roles.UserName
  29985. data["department"] = department.Name
  29986. data["org_name"] = miConfig.OrgName
  29987. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29988. data["doctor_id"] = doctor_info.DoctorNumber
  29989. data["new_doctor_name"] = doctor_info.UserName
  29990. data["fixmedins_code"] = miConfig.Code
  29991. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29992. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29993. data["secret_key"] = miConfig.SecretKey
  29994. data["sick_code"] = sickConfig.CountryCode
  29995. data["sick_name"] = sickConfig.ClassName
  29996. data["url"] = miConfig.Url
  29997. data["ak"] = miConfig.AccessKey
  29998. data["begin_time"] = begin_time
  29999. data["cainfo"] = miConfig.Cainfo
  30000. data["dept"] = strconv.FormatInt(department.ID, 10)
  30001. data["config"] = config
  30002. bytesData, _ := json.Marshal(data)
  30003. var req *http.Request
  30004. if miConfig.MdtrtareaAdmvs == "320830" {
  30005. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  30006. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30007. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  30008. } else {
  30009. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  30010. }
  30011. resp, _ := client.Do(req)
  30012. defer resp.Body.Close()
  30013. body, ioErr := ioutil.ReadAll(resp.Body)
  30014. if ioErr != nil {
  30015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30017. return
  30018. }
  30019. var respJSON map[string]interface{}
  30020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30023. return
  30024. }
  30025. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30026. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30027. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30029. userJSONBytes, _ := json.Marshal(respJSON)
  30030. fmt.Println("log")
  30031. fmt.Println(string(userJSONBytes))
  30032. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30033. utils.ErrorLog("解析失败:%v", err)
  30034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30035. return
  30036. }
  30037. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30038. res2.Output = resSix10265.Output
  30039. res2.ErrMsg = resSix10265.ErrMsg
  30040. res2.Cainfo = resSix10265.Cainfo
  30041. res2.WarnMsg = resSix10265.WarnMsg
  30042. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30043. res2.Infcode = infocode
  30044. } else if miConfig.MdtrtareaAdmvs == "150404" {
  30045. data := make(map[string]interface{})
  30046. client := &http.Client{}
  30047. data["psn_no"] = his.PsnNo
  30048. data["mdtrt_id"] = his.Number
  30049. data["doctor"] = roles.UserName
  30050. data["department"] = department.Name
  30051. data["org_name"] = miConfig.OrgName
  30052. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30053. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  30054. data["fixmedins_code"] = miConfig.Code
  30055. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30056. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30057. data["secret_key"] = miConfig.SecretKey
  30058. data["sick_code"] = sickConfig.CountryCode
  30059. data["sick_name"] = sickConfig.ClassName
  30060. data["begin_time"] = begin_time
  30061. data["dept"] = strconv.FormatInt(department.ID, 10)
  30062. data["config"] = config
  30063. //data["url"] = miConfig.Url
  30064. //data["ak"] = miConfig.AccessKey
  30065. data["cainfo"] = miConfig.Cainfo
  30066. fmt.Println(data)
  30067. bytesData, _ := json.Marshal(data)
  30068. var req *http.Request
  30069. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  30070. resp, _ := client.Do(req)
  30071. defer resp.Body.Close()
  30072. body, ioErr := ioutil.ReadAll(resp.Body)
  30073. if ioErr != nil {
  30074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30076. return
  30077. }
  30078. var respJSON map[string]interface{}
  30079. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30082. return
  30083. }
  30084. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30085. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30086. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30088. userJSONBytes, _ := json.Marshal(respJSON)
  30089. fmt.Println("log")
  30090. fmt.Println(string(userJSONBytes))
  30091. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30092. utils.ErrorLog("解析失败:%v", err)
  30093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30094. return
  30095. }
  30096. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30097. res2.Output = resSix10265.Output
  30098. res2.ErrMsg = resSix10265.ErrMsg
  30099. res2.Cainfo = resSix10265.Cainfo
  30100. res2.WarnMsg = resSix10265.WarnMsg
  30101. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30102. res2.Infcode = infocode
  30103. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30104. 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)
  30105. saveLog(result, requestLog, "2203", "上传就诊信息")
  30106. var respJSON2 map[string]interface{}
  30107. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30110. return
  30111. }
  30112. userJSONBytes2, _ := json.Marshal(respJSON2)
  30113. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30114. utils.ErrorLog("解析失败:%v", err)
  30115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30116. return
  30117. }
  30118. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30119. var result string
  30120. var requestLog string
  30121. 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, "")
  30122. saveLog(result, requestLog, "2203", "上传就诊信息")
  30123. var respJSON2 map[string]interface{}
  30124. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30127. return
  30128. }
  30129. userJSONBytes2, _ := json.Marshal(respJSON2)
  30130. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30131. utils.ErrorLog("解析失败:%v", err)
  30132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30133. return
  30134. }
  30135. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30136. var result string
  30137. var requestLog string
  30138. 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, "")
  30139. saveLog(result, requestLog, "2203", "上传就诊信息")
  30140. var respJSON2 map[string]interface{}
  30141. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30144. return
  30145. }
  30146. userJSONBytes2, _ := json.Marshal(respJSON2)
  30147. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30148. utils.ErrorLog("解析失败:%v", err)
  30149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30150. return
  30151. }
  30152. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30153. var result string
  30154. var requestLog string
  30155. 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, "")
  30156. saveLog(result, requestLog, "2203", "上传就诊信息")
  30157. var respJSON2 map[string]interface{}
  30158. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30161. return
  30162. }
  30163. userJSONBytes2, _ := json.Marshal(respJSON2)
  30164. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30165. utils.ErrorLog("解析失败:%v", err)
  30166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30167. return
  30168. }
  30169. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30170. data := make(map[string]interface{})
  30171. client := &http.Client{}
  30172. data["psn_no"] = his.PsnNo
  30173. data["mdtrt_id"] = his.Number
  30174. data["operator"] = roles.UserName
  30175. data["department"] = department.Name
  30176. data["org_name"] = miConfig.OrgName
  30177. var med_type string
  30178. if his.Insutype == "390" {
  30179. if reg_type == 992102 {
  30180. med_type = "992102"
  30181. data["sick_code"] = "ZDZ940"
  30182. data["sick_name"] = "慢性肾衰竭"
  30183. }
  30184. if reg_type == 140104 {
  30185. med_type = "140104"
  30186. data["sick_code"] = sickConfig.CountryCode
  30187. data["sick_name"] = sickConfig.ClassName
  30188. }
  30189. if reg_type == 14 {
  30190. med_type = "140104"
  30191. data["sick_code"] = sickConfig.CountryCode
  30192. data["sick_name"] = sickConfig.ClassName
  30193. }
  30194. if reg_type == 1104 {
  30195. med_type = "1104"
  30196. data["sick_code"] = sickConfig.CountryCode
  30197. data["sick_name"] = sickConfig.ClassName
  30198. }
  30199. } else if his.Insutype == "310" {
  30200. if reg_type == 992102 {
  30201. med_type = "992102"
  30202. data["sick_code"] = "ZDZ940"
  30203. data["sick_name"] = "慢性肾衰竭"
  30204. }
  30205. if reg_type == 140104 {
  30206. med_type = "140104"
  30207. data["sick_code"] = sickConfig.CountryCode
  30208. data["sick_name"] = sickConfig.ClassName
  30209. }
  30210. if reg_type == 14 {
  30211. med_type = "14"
  30212. data["sick_code"] = sickConfig.CountryCode
  30213. data["sick_name"] = sickConfig.ClassName
  30214. }
  30215. if reg_type == 1104 {
  30216. med_type = "1104"
  30217. data["sick_code"] = sickConfig.CountryCode
  30218. data["sick_name"] = sickConfig.ClassName
  30219. }
  30220. }
  30221. data["med_type"] = med_type
  30222. data["doctor_number"] = doctor_info.DoctorNumber
  30223. data["doctor_name"] = doctor_info.UserName
  30224. data["fixmedins_code"] = miConfig.Code
  30225. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30226. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30227. data["secret_key"] = miConfig.SecretKey
  30228. data["begin_time"] = begin_time
  30229. data["dept"] = strconv.FormatInt(department.ID, 10)
  30230. data["config"] = config
  30231. data["url"] = miConfig.Url
  30232. data["ak"] = miConfig.AccessKey
  30233. data["cainfo"] = miConfig.Cainfo
  30234. bytesData, _ := json.Marshal(data)
  30235. var req *http.Request
  30236. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30237. resp, _ := client.Do(req)
  30238. defer resp.Body.Close()
  30239. body, ioErr := ioutil.ReadAll(resp.Body)
  30240. if ioErr != nil {
  30241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30243. return
  30244. }
  30245. var respJSON map[string]interface{}
  30246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30249. return
  30250. }
  30251. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30252. if status == "0" {
  30253. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30254. c.ServeSuccessJSON(map[string]interface{}{
  30255. "failed_code": -10,
  30256. "msg": err_msg,
  30257. })
  30258. return
  30259. }
  30260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30261. userJSONBytes, _ := json.Marshal(respJSON)
  30262. fmt.Println("log")
  30263. fmt.Println(string(userJSONBytes))
  30264. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30265. utils.ErrorLog("解析失败:%v", err)
  30266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30267. return
  30268. }
  30269. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30270. data := make(map[string]interface{})
  30271. client := &http.Client{}
  30272. data["psn_no"] = his.PsnNo
  30273. data["mdtrt_id"] = his.Number
  30274. data["operator"] = roles.UserName
  30275. data["department"] = department.Name
  30276. data["org_name"] = miConfig.OrgName
  30277. var med_type string
  30278. if his.Insutype == "390" {
  30279. if reg_type == 992102 {
  30280. med_type = "992102"
  30281. data["sick_code"] = sickConfig.CountryCode
  30282. data["sick_name"] = sickConfig.ClassName
  30283. }
  30284. if reg_type == 140104 {
  30285. med_type = "140104"
  30286. data["sick_code"] = sickConfig.CountryCode
  30287. data["sick_name"] = sickConfig.ClassName
  30288. }
  30289. if reg_type == 140201 {
  30290. med_type = "140201"
  30291. data["sick_code"] = sickConfig.CountryCode
  30292. data["sick_name"] = sickConfig.ClassName
  30293. }
  30294. if reg_type == 14 {
  30295. med_type = "14"
  30296. data["sick_code"] = sickConfig.CountryCode
  30297. data["sick_name"] = sickConfig.ClassName
  30298. }
  30299. if reg_type == 11 {
  30300. med_type = "11"
  30301. data["sick_code"] = sickConfig.CountryCode
  30302. data["sick_name"] = sickConfig.ClassName
  30303. }
  30304. } else if his.Insutype == "310" {
  30305. if reg_type == 992102 {
  30306. med_type = "992102"
  30307. data["sick_code"] = sickConfig.CountryCode
  30308. data["sick_name"] = sickConfig.ClassName
  30309. }
  30310. if reg_type == 140104 {
  30311. med_type = "140104"
  30312. data["sick_code"] = sickConfig.CountryCode
  30313. data["sick_name"] = sickConfig.ClassName
  30314. }
  30315. if reg_type == 140201 {
  30316. med_type = "140201"
  30317. data["sick_code"] = sickConfig.CountryCode
  30318. data["sick_name"] = sickConfig.ClassName
  30319. }
  30320. if reg_type == 14 {
  30321. med_type = "14"
  30322. data["sick_code"] = sickConfig.CountryCode
  30323. data["sick_name"] = sickConfig.ClassName
  30324. }
  30325. if reg_type == 11 {
  30326. med_type = "11"
  30327. data["sick_code"] = sickConfig.CountryCode
  30328. data["sick_name"] = sickConfig.ClassName
  30329. }
  30330. }
  30331. data["med_type"] = med_type
  30332. data["doctor_number"] = doctor_info.DoctorNumber
  30333. data["doctor_name"] = doctor_info.UserName
  30334. data["fixmedins_code"] = miConfig.Code
  30335. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30336. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30337. data["secret_key"] = miConfig.SecretKey
  30338. data["begin_time"] = begin_time
  30339. data["dept"] = strconv.FormatInt(department.ID, 10)
  30340. data["config"] = config
  30341. data["url"] = miConfig.Url
  30342. data["ak"] = miConfig.AccessKey
  30343. data["cainfo"] = miConfig.Cainfo
  30344. bytesData, _ := json.Marshal(data)
  30345. var req *http.Request
  30346. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30347. resp, _ := client.Do(req)
  30348. defer resp.Body.Close()
  30349. body, ioErr := ioutil.ReadAll(resp.Body)
  30350. if ioErr != nil {
  30351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30353. return
  30354. }
  30355. var respJSON map[string]interface{}
  30356. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30359. return
  30360. }
  30361. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30362. if status == "0" {
  30363. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30364. c.ServeSuccessJSON(map[string]interface{}{
  30365. "failed_code": -10,
  30366. "msg": err_msg,
  30367. })
  30368. return
  30369. }
  30370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30371. userJSONBytes, _ := json.Marshal(respJSON)
  30372. fmt.Println("log")
  30373. fmt.Println(string(userJSONBytes))
  30374. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30375. utils.ErrorLog("解析失败:%v", err)
  30376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30377. return
  30378. }
  30379. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30380. var result string
  30381. var requestLog string
  30382. result, requestLog = service.Hnyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "", begin_time)
  30383. saveLog(result, requestLog, "2203", "上传就诊信息")
  30384. var respJSON2 map[string]interface{}
  30385. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30388. return
  30389. }
  30390. userJSONBytes2, _ := json.Marshal(respJSON2)
  30391. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30392. utils.ErrorLog("解析失败:%v", err)
  30393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30394. return
  30395. }
  30396. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30397. data := make(map[string]interface{})
  30398. client := &http.Client{}
  30399. data["psn_no"] = his.PsnNo
  30400. data["mdtrt_id"] = his.Number
  30401. data["doctor"] = roles.UserName
  30402. data["department"] = department.Name
  30403. data["org_name"] = miConfig.OrgName
  30404. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30405. data["doctor_id"] = doctor_info.DoctorNumber
  30406. data["fixmedins_code"] = miConfig.Code
  30407. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30408. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30409. data["secret_key"] = miConfig.SecretKey
  30410. data["sick_code"] = sickConfig.CountryCode
  30411. data["sick_name"] = sickConfig.ClassName
  30412. data["begin_time"] = begin_time
  30413. data["new_doctor_name"] = doctor_info.UserName
  30414. data["dept"] = strconv.FormatInt(department.ID, 10)
  30415. data["config"] = config
  30416. bytesData, _ := json.Marshal(data)
  30417. var req *http.Request
  30418. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30419. resp, _ := client.Do(req)
  30420. defer resp.Body.Close()
  30421. body, ioErr := ioutil.ReadAll(resp.Body)
  30422. if ioErr != nil {
  30423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30425. return
  30426. }
  30427. var respJSON map[string]interface{}
  30428. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30431. return
  30432. }
  30433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30434. userJSONBytes, _ := json.Marshal(respJSON)
  30435. fmt.Println("log")
  30436. fmt.Println(string(userJSONBytes))
  30437. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30438. utils.ErrorLog("解析失败:%v", err)
  30439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30440. return
  30441. }
  30442. } else {
  30443. var result string
  30444. var requestLog string
  30445. if miConfig.MdtrtareaAdmvs == "440781" { //
  30446. 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)
  30447. } else {
  30448. if miConfig.Code == "H15049901371" {
  30449. //赤峰地区国家医保医疗类别
  30450. //职工透析:医疗类别选特殊情况门诊990502
  30451. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30452. var med_type string
  30453. if his.Insutype == "390" {
  30454. if reg_type == 14 {
  30455. med_type = "9933"
  30456. } else if reg_type == 11 {
  30457. med_type = "11"
  30458. }
  30459. } else if his.Insutype == "310" {
  30460. if reg_type == 14 {
  30461. med_type = "990502"
  30462. } else if reg_type == 11 {
  30463. med_type = "11"
  30464. }
  30465. }
  30466. 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)
  30467. } else {
  30468. 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)
  30469. }
  30470. saveLog(result, requestLog, "2203", "上传就诊信息")
  30471. var respJSON2 map[string]interface{}
  30472. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30475. return
  30476. }
  30477. userJSONBytes2, _ := json.Marshal(respJSON2)
  30478. if miConfig.Code == "H15049901371" {
  30479. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30480. utils.ErrorLog("解析失败:%v", err)
  30481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30482. return
  30483. }
  30484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30485. res2.Output = resSix10265.Output
  30486. res2.ErrMsg = resSix10265.ErrMsg
  30487. res2.Cainfo = resSix10265.Cainfo
  30488. res2.WarnMsg = resSix10265.WarnMsg
  30489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30490. res2.Infcode = infocode
  30491. } else {
  30492. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30493. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30494. utils.ErrorLog("解析失败:%v", err)
  30495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30496. return
  30497. }
  30498. res2.Infcode = res3.Infcode
  30499. } else {
  30500. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30501. utils.ErrorLog("解析失败:%v", err)
  30502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30503. return
  30504. }
  30505. }
  30506. }
  30507. }
  30508. }
  30509. if res2.Infcode == -1 {
  30510. adminUser := c.GetAdminUserInfo()
  30511. errlog := &models.HisOrderError{
  30512. UserOrgId: adminUser.CurrentOrgId,
  30513. Ctime: time.Now().Unix(),
  30514. Mtime: time.Now().Unix(),
  30515. ErrMsg: res2.ErrMsg,
  30516. Status: 1,
  30517. PatientId: id,
  30518. RecordTime: recordDateTime,
  30519. Stage: 3,
  30520. }
  30521. service.CreateErrMsgLog(errlog)
  30522. c.ServeSuccessJSON(map[string]interface{}{
  30523. "failed_code": -10,
  30524. "msg": res2.ErrMsg,
  30525. })
  30526. return
  30527. }
  30528. if res2.Infcode != 0 {
  30529. adminUser := c.GetAdminUserInfo()
  30530. errlog := &models.HisOrderError{
  30531. UserOrgId: adminUser.CurrentOrgId,
  30532. Ctime: time.Now().Unix(),
  30533. Mtime: time.Now().Unix(),
  30534. ErrMsg: res2.ErrMsg,
  30535. Status: 1,
  30536. PatientId: id,
  30537. RecordTime: recordDateTime,
  30538. Stage: 3,
  30539. }
  30540. service.CreateErrMsgLog(errlog)
  30541. c.ServeSuccessJSON(map[string]interface{}{
  30542. "failed_code": -10,
  30543. "msg": res2.ErrMsg,
  30544. })
  30545. return
  30546. } else {
  30547. his.Diagnosis = diagnosis_id
  30548. his.SickType = sickConfig.ID
  30549. his.PType = fmt.Sprintf("%d", reg_type)
  30550. service.UpdateHisPatientThree(&his)
  30551. data := make(map[string]interface{})
  30552. if settle_accounts_type == 1 { //日结
  30553. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30554. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30555. } else {
  30556. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30557. }
  30558. data["pre"] = prescriptions
  30559. } else { //月结
  30560. start_time_str := c.GetString("start_time")
  30561. end_time_str := c.GetString("end_time")
  30562. timeLayout := "2006-01-02"
  30563. loc, _ := time.LoadLocation("Local")
  30564. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30565. if err != nil {
  30566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30567. return
  30568. }
  30569. recordStartTime := theStartTime.Unix()
  30570. start_time = recordStartTime
  30571. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30572. if err != nil {
  30573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30574. return
  30575. }
  30576. recordEndTime := theEndTime.Unix()
  30577. end_time = recordEndTime
  30578. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30579. data["pre"] = prescriptions
  30580. }
  30581. client := &http.Client{}
  30582. data["psn_no"] = his.PsnNo
  30583. data["mdtrt_id"] = his.Number
  30584. data["chrg_bchno"] = new_chrg_bchno
  30585. data["org_name"] = miConfig.OrgName
  30586. data["doctor"] = doctor_info.UserName
  30587. data["doctor_id"] = doctor_info.DoctorNumber
  30588. data["dept"] = department.Name
  30589. data["fixmedins_code"] = miConfig.Code
  30590. data["opter"] = roles.UserName
  30591. data["dept_code"] = department.Number
  30592. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30594. data["secret_key"] = miConfig.SecretKey
  30595. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30596. data["url"] = miConfig.Url
  30597. data["ak"] = miConfig.AccessKey
  30598. data["new_doctor_name"] = patientPrescription.Doctor
  30599. if his.Insutype == "390" {
  30600. if reg_type == 992102 {
  30601. data["diag_code"] = "ZDZ940"
  30602. }
  30603. if reg_type == 140104 {
  30604. data["diag_code"] = sickConfig.CountryCode
  30605. }
  30606. if reg_type == 140201 {
  30607. data["diag_code"] = sickConfig.CountryCode
  30608. }
  30609. if reg_type == 14 {
  30610. data["diag_code"] = sickConfig.CountryCode
  30611. }
  30612. if reg_type == 1104 {
  30613. data["diag_code"] = sickConfig.CountryCode
  30614. }
  30615. } else if his.Insutype == "310" {
  30616. if miConfig.MdtrtareaAdmvs == "341203" {
  30617. if reg_type == 992102 {
  30618. data["diag_code"] = "ZDZ940"
  30619. }
  30620. if reg_type != 992102 {
  30621. data["diag_code"] = sickConfig.CountryCode
  30622. }
  30623. } else {
  30624. data["diag_code"] = sickConfig.CountryCode
  30625. }
  30626. }
  30627. data["cainfo"] = miConfig.Cainfo
  30628. data["opter"] = roles.UserName
  30629. var ids []int64
  30630. for _, item := range prescriptions {
  30631. ids = append(ids, item.ID)
  30632. }
  30633. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30634. if config.IsOpen == 1 { //对接了医保,走医保流程
  30635. var res ResultFour
  30636. var resFour10265 ResultFour10265
  30637. if miConfig.MdtrtareaAdmvs == "421300" {
  30638. bytesData, _ := json.Marshal(data)
  30639. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30640. resp, _ := client.Do(req)
  30641. defer resp.Body.Close()
  30642. body, ioErr := ioutil.ReadAll(resp.Body)
  30643. if ioErr != nil {
  30644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30646. return
  30647. }
  30648. var respJSON map[string]interface{}
  30649. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30652. return
  30653. }
  30654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30655. userJSONBytes, _ := json.Marshal(respJSON)
  30656. fmt.Println("log")
  30657. fmt.Println(string(userJSONBytes))
  30658. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30659. utils.ErrorLog("解析失败:%v", err)
  30660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30661. return
  30662. }
  30663. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30664. bytesData, _ := json.Marshal(data)
  30665. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30666. resp, _ := client.Do(req)
  30667. defer resp.Body.Close()
  30668. body, ioErr := ioutil.ReadAll(resp.Body)
  30669. if ioErr != nil {
  30670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30672. return
  30673. }
  30674. var respJSON map[string]interface{}
  30675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30678. return
  30679. }
  30680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30681. userJSONBytes, _ := json.Marshal(respJSON)
  30682. fmt.Println("log")
  30683. fmt.Println(string(userJSONBytes))
  30684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30685. utils.ErrorLog("解析失败:%v", err)
  30686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30687. return
  30688. }
  30689. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30690. bytesData, _ := json.Marshal(data)
  30691. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30692. resp, _ := client.Do(req)
  30693. defer resp.Body.Close()
  30694. body, ioErr := ioutil.ReadAll(resp.Body)
  30695. if ioErr != nil {
  30696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30698. return
  30699. }
  30700. var respJSON map[string]interface{}
  30701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30704. return
  30705. }
  30706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30707. userJSONBytes, _ := json.Marshal(respJSON)
  30708. fmt.Println("log")
  30709. fmt.Println(string(userJSONBytes))
  30710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30711. utils.ErrorLog("解析失败:%v", err)
  30712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30713. return
  30714. }
  30715. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30716. bytesData, _ := json.Marshal(data)
  30717. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30718. resp, _ := client.Do(req)
  30719. defer resp.Body.Close()
  30720. body, ioErr := ioutil.ReadAll(resp.Body)
  30721. if ioErr != nil {
  30722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30724. return
  30725. }
  30726. var respJSON map[string]interface{}
  30727. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30730. return
  30731. }
  30732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30733. userJSONBytes, _ := json.Marshal(respJSON)
  30734. fmt.Println("log")
  30735. fmt.Println(string(userJSONBytes))
  30736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30737. utils.ErrorLog("解析失败:%v", err)
  30738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30739. return
  30740. }
  30741. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30742. var result3101 Result3101
  30743. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30744. result3101.Infcode = "0"
  30745. if result3101.Infcode == "0" {
  30746. if len(result3101.Output.Result) > 0 {
  30747. var errMsgs []string
  30748. for _, item := range result3101.Output.Result {
  30749. errMsgs = append(errMsgs, item.VolaCont)
  30750. }
  30751. c.ServeSuccessJSON(map[string]interface{}{
  30752. "failed_code": -10,
  30753. "msg": errMsgs,
  30754. })
  30755. return
  30756. } else {
  30757. if miConfig.MdtrtareaAdmvs == "320921" {
  30758. data["doctor_id"] = doctor_info.DoctorNumber
  30759. } else {
  30760. data["doctor_id"] = doctor_info.DoctorNumber
  30761. }
  30762. bytesData, _ := json.Marshal(data)
  30763. var req *http.Request
  30764. if miConfig.MdtrtareaAdmvs == "320830" {
  30765. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30766. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30767. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30768. } else {
  30769. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30770. }
  30771. resp, _ := client.Do(req)
  30772. defer resp.Body.Close()
  30773. body, ioErr := ioutil.ReadAll(resp.Body)
  30774. if ioErr != nil {
  30775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30777. return
  30778. }
  30779. var respJSON map[string]interface{}
  30780. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30783. return
  30784. }
  30785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30786. userJSONBytes, _ := json.Marshal(respJSON)
  30787. fmt.Println("log")
  30788. fmt.Println(string(userJSONBytes))
  30789. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30790. utils.ErrorLog("解析失败:%v", err)
  30791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30792. return
  30793. }
  30794. res.InfRefmsgid = resFour10265.InfRefmsgid
  30795. res.Output = resFour10265.Output
  30796. res.ErrMsg = resFour10265.ErrMsg
  30797. res.Cainfo = resFour10265.Cainfo
  30798. res.WarnMsg = resFour10265.WarnMsg
  30799. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30800. res.Infcode = infocode
  30801. }
  30802. }
  30803. } else if miConfig.MdtrtareaAdmvs == "150404" {
  30804. var pagesize int = 5
  30805. var start int = 1
  30806. var stop int
  30807. var pagecount int
  30808. var curpage int
  30809. data["doctor_id"] = doctor_info.DoctorNumber
  30810. var res2 ResultFour
  30811. //var result res.
  30812. //总页数,向上取整,注意除之前要先转换类型为float64
  30813. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30814. for curpage = 1; curpage <= pagecount; curpage++ {
  30815. if curpage == 1 {
  30816. start = 1
  30817. } else {
  30818. start = (curpage-1)*pagesize + 1
  30819. }
  30820. stop = curpage * pagesize
  30821. if stop > len(prescriptions) {
  30822. stop = len(prescriptions)
  30823. }
  30824. //var requestLog string
  30825. data["pre"] = prescriptions[start-1 : stop]
  30826. fmt.Println(data["pre"])
  30827. bytesData, _ := json.Marshal(data)
  30828. var req *http.Request
  30829. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30830. resp, _ := client.Do(req)
  30831. defer resp.Body.Close()
  30832. body, ioErr := ioutil.ReadAll(resp.Body)
  30833. if ioErr != nil {
  30834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30836. return
  30837. }
  30838. var respJSON map[string]interface{}
  30839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30842. return
  30843. }
  30844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30845. userJSONBytes, _ := json.Marshal(respJSON)
  30846. fmt.Println("log")
  30847. fmt.Println(string(userJSONBytes))
  30848. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30849. utils.ErrorLog("解析失败:%v", err)
  30850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30851. return
  30852. }
  30853. res.InfRefmsgid = resFour10265.InfRefmsgid
  30854. res.Output = resFour10265.Output
  30855. res.ErrMsg = resFour10265.ErrMsg
  30856. res.Cainfo = resFour10265.Cainfo
  30857. res.WarnMsg = resFour10265.WarnMsg
  30858. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30859. res.Infcode = infocode
  30860. if infocode == 0 {
  30861. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30862. } else {
  30863. isSuccess = false
  30864. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30865. res.Infcode = -1
  30866. res.ErrMsg = resFour10265.ErrMsg
  30867. errlog := &models.HisOrderError{
  30868. UserOrgId: adminUser.CurrentOrgId,
  30869. Ctime: time.Now().Unix(),
  30870. Mtime: time.Now().Unix(),
  30871. Number: chrg_bchno,
  30872. ErrMsg: "",
  30873. Status: 1,
  30874. PatientId: id,
  30875. RecordTime: recordDateTime,
  30876. Stage: 4,
  30877. }
  30878. service.CreateErrMsgLog(errlog)
  30879. }
  30880. }
  30881. if isSuccess {
  30882. res.Infcode = 0
  30883. res.Output.Result = res2.Output.Result
  30884. } else {
  30885. order := &models.HisOrder{
  30886. UserOrgId: adminUser.CurrentOrgId,
  30887. HisPatientId: his.ID,
  30888. PatientId: his.PatientId,
  30889. SettleAccountsDate: recordDateTime,
  30890. Ctime: time.Now().Unix(),
  30891. Mtime: time.Now().Unix(),
  30892. MdtrtId: his.Number,
  30893. PsnNo: his.PsnNo,
  30894. MedType: strconv.FormatInt(reg_type, 10),
  30895. Status: 1,
  30896. Number: chrg_bchno,
  30897. Infcode: res.Infcode,
  30898. WarnMsg: res.WarnMsg,
  30899. Cainfo: res.Cainfo,
  30900. ErrMsg: res.ErrMsg,
  30901. RespondTime: res.RefmsgTime,
  30902. InfRefmsgid: res.InfRefmsgid,
  30903. OrderStatus: 1,
  30904. IsMedicineInsurance: 1,
  30905. SettleType: settle_accounts_type,
  30906. SettleStartTime: start_time,
  30907. SettleEndTime: end_time,
  30908. Creator: roles.AdminUserId,
  30909. Modify: roles.AdminUserId,
  30910. PType: 2,
  30911. Diagnosis: diagnosis_id,
  30912. }
  30913. err = service.CreateOrder(order)
  30914. if err != nil {
  30915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30916. return
  30917. }
  30918. c.ServeSuccessJSON(map[string]interface{}{
  30919. "failed_code": -10,
  30920. "msg": res2.ErrMsg,
  30921. })
  30922. return
  30923. }
  30924. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30925. 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)
  30926. var dat map[string]interface{}
  30927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30928. fmt.Println(dat)
  30929. } else {
  30930. fmt.Println(err)
  30931. }
  30932. saveLog(result, request_log, "2204", "上传费用明细")
  30933. userJSONBytes, _ := json.Marshal(dat)
  30934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30935. utils.ErrorLog("解析失败:%v", err)
  30936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30937. return
  30938. }
  30939. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30940. 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, "", "")
  30941. var dat map[string]interface{}
  30942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30943. fmt.Println(dat)
  30944. } else {
  30945. fmt.Println(err)
  30946. }
  30947. saveLog(result, request_log, "2204", "上传费用明细")
  30948. userJSONBytes, _ := json.Marshal(dat)
  30949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30950. utils.ErrorLog("解析失败:%v", err)
  30951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30952. return
  30953. }
  30954. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30955. 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, "", "")
  30956. var dat map[string]interface{}
  30957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30958. fmt.Println(dat)
  30959. } else {
  30960. fmt.Println(err)
  30961. }
  30962. saveLog(result, request_log, "2204", "上传费用明细")
  30963. userJSONBytes, _ := json.Marshal(dat)
  30964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30965. utils.ErrorLog("解析失败:%v", err)
  30966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30967. return
  30968. }
  30969. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30970. 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, "", "")
  30971. var dat map[string]interface{}
  30972. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30973. fmt.Println(dat)
  30974. } else {
  30975. fmt.Println(err)
  30976. }
  30977. saveLog(result, request_log, "2204", "上传费用明细")
  30978. userJSONBytes, _ := json.Marshal(dat)
  30979. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30980. utils.ErrorLog("解析失败:%v", err)
  30981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30982. return
  30983. }
  30984. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30985. bytesData, _ := json.Marshal(data)
  30986. var req *http.Request
  30987. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30988. resp, _ := client.Do(req)
  30989. defer resp.Body.Close()
  30990. body, ioErr := ioutil.ReadAll(resp.Body)
  30991. if ioErr != nil {
  30992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30994. return
  30995. }
  30996. var respJSON map[string]interface{}
  30997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31000. return
  31001. }
  31002. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31003. if status == "0" {
  31004. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31005. c.ServeSuccessJSON(map[string]interface{}{
  31006. "failed_code": -10,
  31007. "msg": err_msg,
  31008. })
  31009. return
  31010. }
  31011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31012. userJSONBytes, _ := json.Marshal(respJSON)
  31013. fmt.Println("log")
  31014. fmt.Println(string(userJSONBytes))
  31015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31016. utils.ErrorLog("解析失败:%v", err)
  31017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31018. return
  31019. }
  31020. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31021. bytesData, _ := json.Marshal(data)
  31022. var req *http.Request
  31023. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  31024. resp, _ := client.Do(req)
  31025. defer resp.Body.Close()
  31026. body, ioErr := ioutil.ReadAll(resp.Body)
  31027. if ioErr != nil {
  31028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31030. return
  31031. }
  31032. var respJSON map[string]interface{}
  31033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31036. return
  31037. }
  31038. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31039. if status == "0" {
  31040. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31041. c.ServeSuccessJSON(map[string]interface{}{
  31042. "failed_code": -10,
  31043. "msg": err_msg,
  31044. })
  31045. return
  31046. }
  31047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31048. userJSONBytes, _ := json.Marshal(respJSON)
  31049. fmt.Println("log")
  31050. fmt.Println(string(userJSONBytes))
  31051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31052. utils.ErrorLog("解析失败:%v", err)
  31053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31054. return
  31055. }
  31056. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31057. 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, "", "")
  31058. var dat map[string]interface{}
  31059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31060. fmt.Println(dat)
  31061. } else {
  31062. fmt.Println(err)
  31063. }
  31064. saveLog(result, request_log, "2204", "上传费用明细")
  31065. userJSONBytes, _ := json.Marshal(dat)
  31066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31067. utils.ErrorLog("解析失败:%v", err)
  31068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31069. return
  31070. }
  31071. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31072. bytesData, _ := json.Marshal(data)
  31073. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  31074. resp, _ := client.Do(req)
  31075. defer resp.Body.Close()
  31076. body, ioErr := ioutil.ReadAll(resp.Body)
  31077. if ioErr != nil {
  31078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31080. return
  31081. }
  31082. var respJSON map[string]interface{}
  31083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31086. return
  31087. }
  31088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31089. userJSONBytes, _ := json.Marshal(respJSON)
  31090. fmt.Println("log")
  31091. fmt.Println(string(userJSONBytes))
  31092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31093. utils.ErrorLog("解析失败:%v", err)
  31094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31095. return
  31096. }
  31097. } else {
  31098. if miConfig.MdtrtareaAdmvs == "441202" {
  31099. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31100. if result3101.Infcode == 0 {
  31101. if len(result3101.Output.Result) > 0 {
  31102. var errMsgs []string
  31103. for _, item := range result3101.Output.Result {
  31104. errMsgs = append(errMsgs, item.VolaCont)
  31105. }
  31106. c.ServeSuccessJSON(map[string]interface{}{
  31107. "failed_code": -10,
  31108. "msg": errMsgs,
  31109. })
  31110. return
  31111. } else {
  31112. 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)
  31113. var dat map[string]interface{}
  31114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31115. fmt.Println(dat)
  31116. } else {
  31117. fmt.Println(err)
  31118. }
  31119. saveLog(result, request_log, "2204", "上传费用明细")
  31120. userJSONBytes, _ := json.Marshal(dat)
  31121. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31122. utils.ErrorLog("解析失败:%v", err)
  31123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31124. return
  31125. }
  31126. }
  31127. } else {
  31128. c.ServeSuccessJSON(map[string]interface{}{
  31129. "failed_code": -10,
  31130. "msg": result3101.ErrMsg,
  31131. })
  31132. return
  31133. }
  31134. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31135. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31136. if result3101.Infcode == 0 {
  31137. if len(result3101.Output.Result) > 0 {
  31138. var errMsgs []string
  31139. for _, item := range result3101.Output.Result {
  31140. errMsgs = append(errMsgs, item.VolaCont)
  31141. }
  31142. c.ServeSuccessJSON(map[string]interface{}{
  31143. "failed_code": -10,
  31144. "msg": errMsgs,
  31145. })
  31146. return
  31147. } else {
  31148. 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)
  31149. var dat map[string]interface{}
  31150. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31151. fmt.Println(dat)
  31152. } else {
  31153. fmt.Println(err)
  31154. }
  31155. saveLog(result, request_log, "2204", "上传费用明细")
  31156. userJSONBytes, _ := json.Marshal(dat)
  31157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31158. utils.ErrorLog("解析失败:%v", err)
  31159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31160. return
  31161. }
  31162. }
  31163. } else {
  31164. c.ServeSuccessJSON(map[string]interface{}{
  31165. "failed_code": -10,
  31166. "msg": result3101.ErrMsg,
  31167. })
  31168. return
  31169. }
  31170. } else {
  31171. if miConfig.Code == "H15049901371" {
  31172. 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)
  31173. var dat map[string]interface{}
  31174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31175. fmt.Println(dat)
  31176. } else {
  31177. fmt.Println(err)
  31178. }
  31179. saveLog(result, request_log, "2204", "上传费用明细")
  31180. userJSONBytes, _ := json.Marshal(dat)
  31181. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  31182. utils.ErrorLog("解析失败:%v", err)
  31183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31184. return
  31185. }
  31186. res.InfRefmsgid = resFour10265.InfRefmsgid
  31187. res.Output = resFour10265.Output
  31188. res.ErrMsg = resFour10265.ErrMsg
  31189. res.Cainfo = resFour10265.Cainfo
  31190. res.WarnMsg = resFour10265.WarnMsg
  31191. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  31192. res.Infcode = infocode
  31193. } else {
  31194. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  31195. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31196. if result3101.Infcode == 0 {
  31197. if len(result3101.Output.Result) > 0 {
  31198. c.ServeSuccessJSON(map[string]interface{}{
  31199. "failed_code": -10,
  31200. "failed_type": 100,
  31201. "warm_type": 1,
  31202. "msg": result3101,
  31203. })
  31204. return
  31205. } else {
  31206. 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)
  31207. var dat map[string]interface{}
  31208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31209. fmt.Println(dat)
  31210. } else {
  31211. fmt.Println(err)
  31212. }
  31213. saveLog(result, request_log, "2204", "上传费用明细")
  31214. userJSONBytes, _ := json.Marshal(dat)
  31215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31216. utils.ErrorLog("解析失败:%v", err)
  31217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31218. return
  31219. }
  31220. }
  31221. } else {
  31222. c.ServeSuccessJSON(map[string]interface{}{
  31223. "failed_code": -10,
  31224. "msg": result3101.ErrMsg,
  31225. })
  31226. return
  31227. }
  31228. } else {
  31229. 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)
  31230. var dat map[string]interface{}
  31231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31232. fmt.Println(dat)
  31233. } else {
  31234. fmt.Println(err)
  31235. }
  31236. saveLog(result, request_log, "2204", "上传费用明细")
  31237. userJSONBytes, _ := json.Marshal(dat)
  31238. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31239. utils.ErrorLog("解析失败:%v", err)
  31240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31241. return
  31242. }
  31243. }
  31244. }
  31245. }
  31246. }
  31247. var total_two float64
  31248. if res.Infcode == -1 {
  31249. errlog := &models.HisOrderError{
  31250. UserOrgId: adminUser.CurrentOrgId,
  31251. Ctime: time.Now().Unix(),
  31252. Mtime: time.Now().Unix(),
  31253. Number: chrg_bchno,
  31254. ErrMsg: res.ErrMsg,
  31255. Status: 1,
  31256. PatientId: id,
  31257. RecordTime: recordDateTime,
  31258. Stage: 4,
  31259. }
  31260. service.CreateErrMsgLog(errlog)
  31261. c.ServeSuccessJSON(map[string]interface{}{
  31262. "failed_code": -10,
  31263. "msg": res.ErrMsg,
  31264. })
  31265. return
  31266. }
  31267. if res.Infcode == 0 {
  31268. order := &models.HisOrder{
  31269. UserOrgId: adminUser.CurrentOrgId,
  31270. HisPatientId: his.ID,
  31271. PatientId: his.PatientId,
  31272. SettleAccountsDate: recordDateTime,
  31273. Ctime: time.Now().Unix(),
  31274. Mtime: time.Now().Unix(),
  31275. MdtrtId: his.Number,
  31276. PsnNo: his.PsnNo,
  31277. MedType: strconv.FormatInt(reg_type, 10),
  31278. Status: 1,
  31279. Number: chrg_bchno,
  31280. Infcode: res.Infcode,
  31281. WarnMsg: res.WarnMsg,
  31282. Cainfo: res.Cainfo,
  31283. ErrMsg: res.ErrMsg,
  31284. RespondTime: res.RefmsgTime,
  31285. InfRefmsgid: res.InfRefmsgid,
  31286. OrderStatus: 1,
  31287. IsMedicineInsurance: 1,
  31288. SettleType: settle_accounts_type,
  31289. SettleStartTime: start_time,
  31290. SettleEndTime: end_time,
  31291. Creator: roles.AdminUserId,
  31292. Modify: roles.AdminUserId,
  31293. PType: 2,
  31294. Diagnosis: diagnosis_id,
  31295. }
  31296. err = service.CreateOrder(order)
  31297. if err != nil {
  31298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31299. return
  31300. }
  31301. for _, item := range res.Output.Result {
  31302. temp := strings.Split(item.FeedetlSn, "-")
  31303. var advice_id int64 = 0
  31304. var project_id int64 = 0
  31305. var types int64 = 0
  31306. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31307. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31308. if temp[1] == "1" {
  31309. advice_id = id
  31310. project_id = 0
  31311. } else if temp[1] == "2" {
  31312. advice_id = 0
  31313. project_id = id
  31314. }
  31315. total_two = total_two + item.DetItemFeeSumamt
  31316. info := &models.HisOrderInfo{
  31317. OrderNumber: order.Number,
  31318. FeedetlSn: item.FeedetlSn,
  31319. UploadDate: time.Now().Unix(),
  31320. AdviceId: advice_id,
  31321. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31322. Cnt: item.Cnt,
  31323. Pric: float64(item.Pric),
  31324. PatientId: his.PatientId,
  31325. PricUplmtAmt: item.PricUplmtAmt,
  31326. SelfpayProp: item.SelfpayProp,
  31327. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31328. OverlmtAmt: item.OverlmtAmt,
  31329. PreselfpayAmt: item.PreselfpayAmt,
  31330. BasMednFlag: item.BasMednFlag,
  31331. MedChrgitmType: item.MedChrgitmType,
  31332. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31333. Status: 1,
  31334. Memo: item.Memo,
  31335. Mtime: time.Now().Unix(),
  31336. InscpScpAmt: item.InscpScpAmt,
  31337. DrtReimFlag: item.DrtReimFlag,
  31338. Ctime: time.Now().Unix(),
  31339. ListSpItemFlag: item.ListSpItemFlag,
  31340. ChldMedcFlag: item.ChldMedcFlag,
  31341. LmtUsedFlag: item.LmtUsedFlag,
  31342. ChrgitmLv: item.ChrgitmLv,
  31343. UserOrgId: adminUser.CurrentOrgId,
  31344. HisPatientId: his.ID,
  31345. OrderId: order.ID,
  31346. ProjectId: project_id,
  31347. Type: types,
  31348. }
  31349. service.CreateOrderInfo(info)
  31350. }
  31351. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31352. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31353. var total float64
  31354. for _, item := range prescriptions {
  31355. if item.Type == 1 { //药品
  31356. for _, subItem := range item.HisDoctorAdviceInfo {
  31357. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31358. total_one := price * subItem.PrescribingNumber
  31359. fmt.Println("subItem")
  31360. fmt.Println(subItem.Price)
  31361. fmt.Println("price")
  31362. fmt.Println(price)
  31363. fmt.Println("total_one")
  31364. fmt.Println(total_one)
  31365. total = total + total_one
  31366. fmt.Println(total)
  31367. }
  31368. }
  31369. if item.Type == 2 { //项目
  31370. for _, subItem := range item.HisPrescriptionProject {
  31371. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31372. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31373. total_one := price * cnt
  31374. total = total + total_one
  31375. }
  31376. }
  31377. }
  31378. allTotal := fmt.Sprintf("%.2f", total)
  31379. if res.Infcode == 0 {
  31380. var rf []*ResultFive
  31381. json.Unmarshal([]byte(his.Iinfo), &rf)
  31382. chrg_bchno := chrg_bchno
  31383. cert_no := his.Certno
  31384. var insutypes []string
  31385. var insutype string
  31386. var is390 int = 0
  31387. var is310 int = 0
  31388. for _, item := range rf {
  31389. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31390. insutypes = append(insutypes, item.Insutype)
  31391. }
  31392. }
  31393. if len(insutypes) == 1 {
  31394. insutype = insutypes[0]
  31395. } else {
  31396. for _, i := range insutypes {
  31397. if i == "390" {
  31398. is390 = 1
  31399. }
  31400. if i == "310" {
  31401. is310 = 1
  31402. }
  31403. }
  31404. }
  31405. if is390 == 1 {
  31406. insutype = "390"
  31407. }
  31408. if is310 == 1 {
  31409. insutype = "310"
  31410. }
  31411. if len(insutypes) == 0 {
  31412. insutype = "390"
  31413. }
  31414. if len(insutypes) == 2 {
  31415. insutype = strconv.FormatInt(his.SocialType, 10)
  31416. }
  31417. //insutype = "390"
  31418. if his.IdCardType == 1 {
  31419. cert_no = his.MedicalInsuranceNumber
  31420. } else {
  31421. cert_no = his.Certno
  31422. }
  31423. var res ResultSeven
  31424. var res10633 ResultSeven10633
  31425. var ahres ResultSevenAH
  31426. var resSeven10265 ResultSeven10265
  31427. var resSeven10265Two ResultSeven10265Two
  31428. var resSeven10633Three ResultSeven10633Three
  31429. var gzresSeven10265Two GZResultSeven10265Two
  31430. if miConfig.MdtrtareaAdmvs == "421300" {
  31431. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31432. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31433. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31434. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31435. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31436. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31437. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31438. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31439. resp, requestErr := http.Get(api)
  31440. if requestErr != nil {
  31441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31442. return
  31443. }
  31444. body, ioErr := ioutil.ReadAll(resp.Body)
  31445. if ioErr != nil {
  31446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31448. return
  31449. }
  31450. var respJSON map[string]interface{}
  31451. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31454. return
  31455. }
  31456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31457. result, _ := json.Marshal(respJSON)
  31458. fmt.Println("log")
  31459. fmt.Println(string(result))
  31460. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31461. utils.ErrorLog("解析失败:%v", err)
  31462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31463. return
  31464. }
  31465. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31466. if reg_type == 11 && his.Insutype == "390" {
  31467. reg_type = 110104
  31468. }
  31469. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31470. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31471. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31472. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31473. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31474. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31475. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31476. resp, requestErr := http.Get(api)
  31477. if requestErr != nil {
  31478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31479. return
  31480. }
  31481. body, ioErr := ioutil.ReadAll(resp.Body)
  31482. if ioErr != nil {
  31483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31485. return
  31486. }
  31487. var respJSON map[string]interface{}
  31488. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31491. return
  31492. }
  31493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31494. result, _ := json.Marshal(respJSON)
  31495. fmt.Println("log")
  31496. fmt.Println(string(result))
  31497. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31498. utils.ErrorLog("解析失败:%v", err)
  31499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31500. return
  31501. }
  31502. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31503. if reg_type == 11 && his.Insutype == "390" {
  31504. reg_type = 110104
  31505. }
  31506. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31507. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31508. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31509. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31510. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31511. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31512. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31513. resp, requestErr := http.Get(api)
  31514. if requestErr != nil {
  31515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31516. return
  31517. }
  31518. body, ioErr := ioutil.ReadAll(resp.Body)
  31519. if ioErr != nil {
  31520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31522. return
  31523. }
  31524. var respJSON map[string]interface{}
  31525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31528. return
  31529. }
  31530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31531. result, _ := json.Marshal(respJSON)
  31532. fmt.Println("log")
  31533. fmt.Println(string(result))
  31534. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31535. utils.ErrorLog("解析失败:%v", err)
  31536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31537. return
  31538. }
  31539. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31540. if reg_type == 11 && his.Insutype == "390" {
  31541. reg_type = 110104
  31542. }
  31543. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31544. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31545. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31547. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31548. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31549. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31550. resp, requestErr := http.Get(api)
  31551. if requestErr != nil {
  31552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31553. return
  31554. }
  31555. body, ioErr := ioutil.ReadAll(resp.Body)
  31556. if ioErr != nil {
  31557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31559. return
  31560. }
  31561. var respJSON map[string]interface{}
  31562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31565. return
  31566. }
  31567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31568. result, _ := json.Marshal(respJSON)
  31569. fmt.Println("log")
  31570. fmt.Println(string(result))
  31571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31572. utils.ErrorLog("解析失败:%v", err)
  31573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31574. return
  31575. }
  31576. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31577. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31578. var result3101 Result3101
  31579. //utils.ErrorLog("解析失败:%v", result3101)
  31580. result3101.Infcode = "0"
  31581. if result3101.Infcode == "0" {
  31582. if len(result3101.Output.Result) > 0 {
  31583. var errMsgs []string
  31584. for _, item := range result3101.Output.Result {
  31585. errMsgs = append(errMsgs, item.VolaCont)
  31586. }
  31587. c.ServeSuccessJSON(map[string]interface{}{
  31588. "failed_code": -10,
  31589. "msg": errMsgs,
  31590. })
  31591. return
  31592. } else {
  31593. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31594. if his.IdCardType != 4 {
  31595. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31596. bas := strings.Split(psn_info.CardInfo, "|")
  31597. if his.IdCardType == 1 {
  31598. cert_no = bas[2]
  31599. } else {
  31600. cert_no = bas[1]
  31601. }
  31602. } else {
  31603. cert_no = his.Certno
  31604. }
  31605. //江苏地区国家医保医疗类别
  31606. //职工透析:医疗类别选特殊情况门诊9933
  31607. //居民血透门慢: 医疗类别选门诊慢病1402
  31608. //var med_type string
  31609. //if his.Insutype == "310" {
  31610. // if reg_type == 14 {
  31611. // med_type = "9933"
  31612. // } else if reg_type == 11 {
  31613. // med_type = "11"
  31614. //
  31615. // }
  31616. //} else if his.Insutype == "390" {
  31617. // if reg_type == 14 {
  31618. // med_type = "1402"
  31619. // } else if reg_type == 11 {
  31620. // med_type = "11"
  31621. // }
  31622. //}
  31623. var api string
  31624. if miConfig.MdtrtareaAdmvs == "320830" {
  31625. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31626. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31627. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31628. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31629. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31630. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31631. "&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
  31632. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31633. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31634. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31635. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31636. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31638. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31639. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31640. "&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
  31641. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31642. } else {
  31643. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31644. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31645. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31646. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31647. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31648. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31649. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31650. "&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
  31651. }
  31652. resp, requestErr := http.Get(api)
  31653. if requestErr != nil {
  31654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31655. return
  31656. }
  31657. body, ioErr := ioutil.ReadAll(resp.Body)
  31658. if ioErr != nil {
  31659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31661. return
  31662. }
  31663. var respJSON map[string]interface{}
  31664. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31667. return
  31668. }
  31669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31670. result, _ := json.Marshal(respJSON)
  31671. fmt.Println("log")
  31672. fmt.Println(string(result))
  31673. {
  31674. if miConfig.MdtrtareaAdmvs == "320830" {
  31675. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31676. fmt.Println("log")
  31677. fmt.Println(string(result))
  31678. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31679. utils.ErrorLog("解析失败:%v", err)
  31680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31681. return
  31682. }
  31683. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31684. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31685. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31686. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31687. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31688. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31689. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31690. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31691. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31692. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31693. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31694. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31695. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31696. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31697. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31698. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31699. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31700. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31701. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31702. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31703. //HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31704. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31705. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31706. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31707. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31708. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31709. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31710. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31711. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31712. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31713. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31714. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31715. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31716. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31717. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31718. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31719. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31720. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31721. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31722. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31723. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31724. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31725. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31726. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31727. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31728. res10633.Cainfo = resSeven10633Three.Cainfo
  31729. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31730. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31731. res10633.Infcode = infocode
  31732. } else {
  31733. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31734. utils.ErrorLog("解析失败:%v", err)
  31735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31736. return
  31737. }
  31738. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31739. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31740. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31741. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31742. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31743. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31744. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31745. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31746. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31747. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31748. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31749. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31750. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31751. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31752. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31753. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31754. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31755. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31756. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31757. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31758. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31759. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31760. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31761. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31762. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31763. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31764. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31765. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31766. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31767. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31768. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31769. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31770. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31771. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31772. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31773. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31774. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31775. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31776. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31777. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31778. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31779. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31780. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31781. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31782. res10633.Cainfo = resSeven10633Three.Cainfo
  31783. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31784. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31785. res10633.Infcode = infocode
  31786. }
  31787. } else {
  31788. fmt.Println("log")
  31789. //fmt.Println(string(result))
  31790. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31791. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31792. utils.ErrorLog("解析失败:%v", err)
  31793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31794. return
  31795. }
  31796. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31797. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31798. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31799. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31800. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31801. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31802. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31803. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31804. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31805. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31806. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31807. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31808. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31809. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31810. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31811. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31812. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31813. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31814. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31815. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31816. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31817. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31818. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31819. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31820. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31821. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31822. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31823. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31824. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31825. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31826. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31827. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31828. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31829. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31830. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31831. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31832. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31833. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31834. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31835. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31836. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31837. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31838. res10633.Cainfo = resSeven10633Three.Cainfo
  31839. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31840. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31841. res10633.Infcode = infocode
  31842. } else {
  31843. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31844. utils.ErrorLog("解析失败:%v", err)
  31845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31846. return
  31847. }
  31848. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31849. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31850. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPayv
  31851. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31852. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31853. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31854. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31855. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31856. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31857. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31858. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31859. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31860. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31861. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31862. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31863. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31864. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31865. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31866. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31867. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31868. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31869. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31870. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31871. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31872. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31873. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31874. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31875. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31876. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31877. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31878. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31879. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31880. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31881. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31882. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31883. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31884. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31885. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31886. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31887. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31888. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31889. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31890. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31891. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31892. res10633.Cainfo = resSeven10633Three.Cainfo
  31893. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31894. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31895. res10633.Infcode = infocode
  31896. }
  31897. }
  31898. }
  31899. }
  31900. }
  31901. } else if miConfig.MdtrtareaAdmvs == "150404" {
  31902. psn_info, _ := service.GetPsnByPatientId(id)
  31903. var verify_number string
  31904. if psn_info.IdCardType == 4 {
  31905. verify_number = psn_info.VerifyNumber
  31906. } else if psn_info.IdCardType == 1 {
  31907. bas := strings.Split(psn_info.CardInfo, "|")
  31908. cardNumber := bas[2]
  31909. verify_number = cardNumber
  31910. } else {
  31911. psn_info.IdCardType = 2
  31912. verify_number = psn_info.Certno
  31913. }
  31914. var api string
  31915. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31916. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31917. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31918. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31919. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31920. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31921. "&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
  31922. resp, requestErr := http.Get(api)
  31923. if requestErr != nil {
  31924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31925. return
  31926. }
  31927. body, ioErr := ioutil.ReadAll(resp.Body)
  31928. if ioErr != nil {
  31929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31931. return
  31932. }
  31933. var respJSON map[string]interface{}
  31934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31937. return
  31938. }
  31939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31940. result, _ := json.Marshal(respJSON)
  31941. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31942. utils.ErrorLog("解析失败:%v", err)
  31943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31944. return
  31945. }
  31946. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31947. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31948. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31949. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31950. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31951. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31952. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31953. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31954. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31955. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31956. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31957. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31958. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31959. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31960. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31961. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31962. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31963. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31964. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31965. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31966. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31967. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31968. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31969. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31970. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31971. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31972. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31973. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31974. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31975. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31976. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31977. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31978. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31979. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31980. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31981. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31982. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31983. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31984. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31985. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31986. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31987. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31988. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31989. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31990. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31991. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31992. res.ErrMsg = resSeven10265.ErrMsg
  31993. res.Cainfo = resSeven10265.Cainfo
  31994. res.WarnMsg = resSeven10265.WarnMsg
  31995. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31996. res.Infcode = infocode
  31997. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31998. acct_used_flag := "1"
  31999. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  32000. var result string
  32001. var request_log string
  32002. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  32003. 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)
  32004. } else {
  32005. 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)
  32006. }
  32007. var dat map[string]interface{}
  32008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32009. fmt.Println(dat)
  32010. } else {
  32011. fmt.Println(err)
  32012. }
  32013. saveLog(result, request_log, "2206", "预结算")
  32014. userJSONBytes, _ := json.Marshal(dat)
  32015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32016. utils.ErrorLog("解析失败:%v", err)
  32017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32018. return
  32019. }
  32020. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32021. var result string
  32022. var request_log string
  32023. if his.IdCardType == 2 {
  32024. insutype = strconv.FormatInt(his.SocialType, 10)
  32025. 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, "")
  32026. } else if his.IdCardType == 1 {
  32027. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32028. bas := strings.Split(psn_info.CardInfo, "|")
  32029. basNumber := bas[2]
  32030. card_sn := bas[3]
  32031. var rf []*ResultFive
  32032. json.Unmarshal([]byte(his.Iinfo), &rf)
  32033. var psn_type string
  32034. for _, item := range rf {
  32035. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32036. psn_type = item.PsnType
  32037. }
  32038. }
  32039. insutype = strconv.FormatInt(his.SocialType, 10)
  32040. 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)
  32041. } else {
  32042. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32043. //bas := strings.Split(psn_info.CardInfo, "|")
  32044. //basNumber := bas[2]
  32045. //card_sn := bas[3]
  32046. var rf []*ResultFive
  32047. json.Unmarshal([]byte(his.Iinfo), &rf)
  32048. var psn_type string
  32049. for _, item := range rf {
  32050. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32051. psn_type = item.PsnType
  32052. }
  32053. }
  32054. insutype = strconv.FormatInt(his.SocialType, 10)
  32055. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32056. 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)
  32057. }
  32058. var dat map[string]interface{}
  32059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32060. fmt.Println(dat)
  32061. } else {
  32062. fmt.Println(err)
  32063. }
  32064. saveLog(result, request_log, "2206", "预结算")
  32065. userJSONBytes, _ := json.Marshal(dat)
  32066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32067. utils.ErrorLog("解析失败:%v", err)
  32068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32069. return
  32070. }
  32071. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32072. var result string
  32073. var request_log string
  32074. if his.IdCardType == 2 {
  32075. insutype = strconv.FormatInt(his.SocialType, 10)
  32076. 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, "")
  32077. } else if his.IdCardType == 1 {
  32078. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32079. bas := strings.Split(psn_info.CardInfo, "|")
  32080. basNumber := bas[0]
  32081. card_sn := ""
  32082. var rf []*ResultFive
  32083. json.Unmarshal([]byte(his.Iinfo), &rf)
  32084. var psn_type string
  32085. for _, item := range rf {
  32086. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32087. psn_type = item.PsnType
  32088. }
  32089. }
  32090. insutype = strconv.FormatInt(his.SocialType, 10)
  32091. 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)
  32092. } else {
  32093. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32094. //bas := strings.Split(psn_info.CardInfo, "|")
  32095. //basNumber := bas[2]
  32096. //card_sn := bas[3]
  32097. var rf []*ResultFive
  32098. json.Unmarshal([]byte(his.Iinfo), &rf)
  32099. var psn_type string
  32100. for _, item := range rf {
  32101. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32102. psn_type = item.PsnType
  32103. }
  32104. }
  32105. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32106. 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)
  32107. }
  32108. var dat map[string]interface{}
  32109. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32110. fmt.Println(dat)
  32111. } else {
  32112. fmt.Println(err)
  32113. }
  32114. saveLog(result, request_log, "2206", "预结算")
  32115. userJSONBytes, _ := json.Marshal(dat)
  32116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32117. utils.ErrorLog("解析失败:%v", err)
  32118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32119. return
  32120. }
  32121. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32122. var result string
  32123. var request_log string
  32124. if his.IdCardType == 2 {
  32125. insutype = strconv.FormatInt(his.SocialType, 10)
  32126. 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, "")
  32127. } else if his.IdCardType == 1 {
  32128. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32129. bas := strings.Split(psn_info.CardInfo, "|")
  32130. basNumber := bas[0]
  32131. card_sn := ""
  32132. var rf []*ResultFive
  32133. json.Unmarshal([]byte(his.Iinfo), &rf)
  32134. var psn_type string
  32135. for _, item := range rf {
  32136. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32137. psn_type = item.PsnType
  32138. }
  32139. }
  32140. insutype = strconv.FormatInt(his.SocialType, 10)
  32141. 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)
  32142. } else {
  32143. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32144. //bas := strings.Split(psn_info.CardInfo, "|")
  32145. //basNumber := bas[2]
  32146. //card_sn := bas[3]
  32147. var rf []*ResultFive
  32148. json.Unmarshal([]byte(his.Iinfo), &rf)
  32149. var psn_type string
  32150. for _, item := range rf {
  32151. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32152. psn_type = item.PsnType
  32153. }
  32154. }
  32155. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32156. 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)
  32157. }
  32158. var dat map[string]interface{}
  32159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32160. fmt.Println(dat)
  32161. } else {
  32162. fmt.Println(err)
  32163. }
  32164. saveLog(result, request_log, "2206", "预结算")
  32165. userJSONBytes, _ := json.Marshal(dat)
  32166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32167. utils.ErrorLog("解析失败:%v", err)
  32168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32169. return
  32170. }
  32171. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32172. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32173. if his.IdCardType == 4 {
  32174. psn_info.VerifyNumber = psn_info.VerifyNumber
  32175. cert_no = psn_info.VerifyNumber
  32176. } else if his.IdCardType == 2 {
  32177. cert_no = psn_info.Certno
  32178. psn_info.VerifyNumber = psn_info.Certno
  32179. } else {
  32180. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32181. bas := strings.Split(psn_info.CardInfo, "|")
  32182. if his.IdCardType == 1 {
  32183. cert_no = bas[2]
  32184. } else {
  32185. cert_no = bas[1]
  32186. }
  32187. }
  32188. var api string
  32189. var med_type string
  32190. if his.Insutype == "390" {
  32191. if reg_type == 992102 {
  32192. med_type = "992102"
  32193. }
  32194. if reg_type == 140104 {
  32195. med_type = "140104"
  32196. }
  32197. if reg_type == 140201 {
  32198. med_type = "140201"
  32199. }
  32200. if reg_type == 14 {
  32201. med_type = "140104"
  32202. }
  32203. if reg_type == 1104 {
  32204. med_type = "1104"
  32205. }
  32206. } else if his.Insutype == "310" {
  32207. if reg_type == 1104 {
  32208. med_type = "1104"
  32209. }
  32210. if reg_type == 992102 {
  32211. med_type = "992102"
  32212. }
  32213. if reg_type == 140104 {
  32214. med_type = "140104"
  32215. }
  32216. if reg_type == 140201 {
  32217. med_type = "140201"
  32218. }
  32219. if reg_type == 14 {
  32220. med_type = "140104"
  32221. }
  32222. }
  32223. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32224. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32225. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32226. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32227. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32228. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32229. "&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
  32230. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32231. resp, requestErr := http.Get(api)
  32232. if requestErr != nil {
  32233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32234. return
  32235. }
  32236. body, ioErr := ioutil.ReadAll(resp.Body)
  32237. if ioErr != nil {
  32238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32240. return
  32241. }
  32242. var respJSON map[string]interface{}
  32243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32246. return
  32247. }
  32248. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32249. if status == "0" {
  32250. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32251. c.ServeSuccessJSON(map[string]interface{}{
  32252. "failed_code": -10,
  32253. "msg": err_msg,
  32254. })
  32255. return
  32256. }
  32257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32258. result, _ := json.Marshal(respJSON)
  32259. fmt.Println("log")
  32260. fmt.Println(string(result))
  32261. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32262. utils.ErrorLog("解析失败:%v", err)
  32263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32264. return
  32265. }
  32266. res.InfRefmsgid = ahres.InfRefmsgid
  32267. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32268. // 创建对应的Time类型
  32269. t := time.UnixMilli(timestamp)
  32270. // 格式化成指定的日期字符串
  32271. str := t.Format("2006-01-02 15:04:05")
  32272. res.Output.Setlinfo.SetlTime = str
  32273. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32274. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32275. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32276. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32277. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32278. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32279. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32280. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32281. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32282. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32283. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32284. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32285. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32286. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32287. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32288. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32289. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32290. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32291. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32292. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32293. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32294. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32295. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32296. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32297. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32298. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32299. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32300. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32301. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32302. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32303. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32304. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32305. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32306. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32307. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32308. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32309. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32310. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32311. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32312. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32313. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32314. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32315. //res.Output.Setldetail = ahres.Output.Setldetail
  32316. res.ErrMsg = ahres.ErrMsg
  32317. res.Cainfo = ahres.Cainfo
  32318. res.WarnMsg = ahres.WarnMsg
  32319. res.Infcode = ahres.Infcode
  32320. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32321. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32322. if his.IdCardType == 4 {
  32323. psn_info.VerifyNumber = psn_info.VerifyNumber
  32324. cert_no = psn_info.Certno
  32325. } else if his.IdCardType == 2 {
  32326. cert_no = psn_info.Certno
  32327. psn_info.VerifyNumber = psn_info.Certno
  32328. } else {
  32329. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32330. bas := strings.Split(psn_info.CardInfo, "|")
  32331. if his.IdCardType == 1 {
  32332. cert_no = bas[2]
  32333. } else {
  32334. cert_no = bas[1]
  32335. }
  32336. }
  32337. var api string
  32338. var med_type string
  32339. if his.Insutype == "390" {
  32340. if reg_type == 992102 {
  32341. med_type = "992102"
  32342. }
  32343. if reg_type == 140104 {
  32344. med_type = "140104"
  32345. }
  32346. if reg_type == 140201 {
  32347. med_type = "140201"
  32348. }
  32349. if reg_type == 14 {
  32350. med_type = "14"
  32351. }
  32352. } else if his.Insutype == "310" {
  32353. if reg_type == 992102 {
  32354. med_type = "992102"
  32355. }
  32356. if reg_type == 140104 {
  32357. med_type = "140104"
  32358. }
  32359. if reg_type == 140201 {
  32360. med_type = "140201"
  32361. }
  32362. if reg_type == 14 {
  32363. med_type = "14"
  32364. }
  32365. }
  32366. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32367. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32368. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32369. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32370. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32371. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32372. "&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
  32373. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32374. resp, requestErr := http.Get(api)
  32375. if requestErr != nil {
  32376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32377. return
  32378. }
  32379. body, ioErr := ioutil.ReadAll(resp.Body)
  32380. if ioErr != nil {
  32381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32383. return
  32384. }
  32385. var respJSON map[string]interface{}
  32386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32389. return
  32390. }
  32391. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32392. if status == "0" {
  32393. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32394. c.ServeSuccessJSON(map[string]interface{}{
  32395. "failed_code": -10,
  32396. "msg": err_msg,
  32397. })
  32398. return
  32399. }
  32400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32401. result, _ := json.Marshal(respJSON)
  32402. fmt.Println("log")
  32403. fmt.Println(string(result))
  32404. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32405. utils.ErrorLog("解析失败:%v", err)
  32406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32407. return
  32408. }
  32409. res.InfRefmsgid = ahres.InfRefmsgid
  32410. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32411. // 创建对应的Time类型
  32412. t := time.UnixMilli(timestamp)
  32413. // 格式化成指定的日期字符串
  32414. str := t.Format("2006-01-02 15:04:05")
  32415. res.Output.Setlinfo.SetlTime = str
  32416. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32417. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32418. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32419. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32420. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32421. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32422. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32423. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32424. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32425. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32426. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32427. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32428. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32429. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32430. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32431. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32432. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32433. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32434. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32435. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32436. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32437. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32438. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32439. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32440. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32441. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32442. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32443. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32444. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32445. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32446. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32447. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32448. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32449. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32450. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32451. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32452. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32453. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32454. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32455. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32456. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32457. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32458. //res.Output.Setldetail = ahres.Output.Setldetail
  32459. res.ErrMsg = ahres.ErrMsg
  32460. res.Cainfo = ahres.Cainfo
  32461. res.WarnMsg = ahres.WarnMsg
  32462. res.Infcode = ahres.Infcode
  32463. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32464. var result string
  32465. var request_log string
  32466. if his.IdCardType == 2 {
  32467. 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")
  32468. } else if his.IdCardType == 1 {
  32469. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32470. bas := strings.Split(psn_info.CardInfo, "|")
  32471. basNumber := bas[2]
  32472. card_sn := bas[3]
  32473. 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")
  32474. } else {
  32475. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32476. 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")
  32477. }
  32478. var dat map[string]interface{}
  32479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32480. fmt.Println(dat)
  32481. } else {
  32482. fmt.Println(err)
  32483. }
  32484. saveLog(result, request_log, "2206", "预结算")
  32485. userJSONBytes, _ := json.Marshal(dat)
  32486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32487. utils.ErrorLog("解析失败:%v", err)
  32488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32489. return
  32490. }
  32491. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32492. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32493. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32494. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32495. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32496. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32497. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32498. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32499. resp, requestErr := http.Get(api)
  32500. if requestErr != nil {
  32501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32502. return
  32503. }
  32504. body, ioErr := ioutil.ReadAll(resp.Body)
  32505. if ioErr != nil {
  32506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32508. return
  32509. }
  32510. var respJSON map[string]interface{}
  32511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32514. return
  32515. }
  32516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32517. result, _ := json.Marshal(respJSON)
  32518. fmt.Println("log")
  32519. fmt.Println(string(result))
  32520. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32521. utils.ErrorLog("解析失败:%v", err)
  32522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32523. return
  32524. }
  32525. } else {
  32526. if miConfig.MdtrtareaAdmvs == "441202" {
  32527. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32528. if result3101.Infcode == 0 {
  32529. if len(result3101.Output.Result) > 0 {
  32530. c.ServeSuccessJSON(map[string]interface{}{
  32531. "failed_code": -10,
  32532. "failed_type": 100,
  32533. "msg": result3101.Output.Result,
  32534. })
  32535. return
  32536. } else {
  32537. var result string
  32538. var request_log string
  32539. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32540. allTotal = fmt.Sprintf("%.2f", total_two)
  32541. if his.IdCardType == 4 {
  32542. 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, acct_used_flag)
  32543. } else {
  32544. 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, acct_used_flag)
  32545. }
  32546. var dat map[string]interface{}
  32547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32548. fmt.Println(dat)
  32549. } else {
  32550. fmt.Println(err)
  32551. }
  32552. saveLog(result, request_log, "2206", "预结算")
  32553. //userJSONBytes, _ := json.Marshal(dat)
  32554. //
  32555. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32556. // utils.ErrorLog("解析失败:%v", err)
  32557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32558. // return
  32559. //}
  32560. userJSONBytes, _ := json.Marshal(dat)
  32561. if miConfig.Code == "H15049901371" {
  32562. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32563. utils.ErrorLog("解析失败:%v", err)
  32564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32565. return
  32566. }
  32567. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32568. res.Output = resSeven10265.Output
  32569. res.ErrMsg = resSeven10265.ErrMsg
  32570. res.Cainfo = resSeven10265.Cainfo
  32571. res.WarnMsg = resSeven10265.WarnMsg
  32572. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32573. res.Infcode = infocode
  32574. } else {
  32575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32576. utils.ErrorLog("解析失败:%v", err)
  32577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32578. return
  32579. }
  32580. }
  32581. }
  32582. } else {
  32583. c.ServeSuccessJSON(map[string]interface{}{
  32584. "failed_code": -10,
  32585. "msg": result3101.ErrMsg,
  32586. })
  32587. return
  32588. }
  32589. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32590. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32591. if result3101.Infcode == 0 {
  32592. if len(result3101.Output.Result) > 0 {
  32593. var errMsgs []string
  32594. for _, item := range result3101.Output.Result {
  32595. errMsgs = append(errMsgs, item.VolaCont)
  32596. }
  32597. c.ServeSuccessJSON(map[string]interface{}{
  32598. "failed_code": -10,
  32599. "msg": errMsgs,
  32600. })
  32601. return
  32602. } else {
  32603. var result string
  32604. var request_log string
  32605. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32606. allTotal = fmt.Sprintf("%.2f", total_two)
  32607. if his.IdCardType == 4 {
  32608. 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, acct_used_flag)
  32609. } else {
  32610. 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, acct_used_flag)
  32611. }
  32612. var dat map[string]interface{}
  32613. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32614. fmt.Println(dat)
  32615. } else {
  32616. fmt.Println(err)
  32617. }
  32618. saveLog(result, request_log, "2206", "预结算")
  32619. //userJSONBytes, _ := json.Marshal(dat)
  32620. //
  32621. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32622. // utils.ErrorLog("解析失败:%v", err)
  32623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32624. // return
  32625. //}
  32626. userJSONBytes, _ := json.Marshal(dat)
  32627. if miConfig.Code == "H15049901371" {
  32628. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32629. utils.ErrorLog("解析失败:%v", err)
  32630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32631. return
  32632. }
  32633. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32634. res.Output = resSeven10265.Output
  32635. res.ErrMsg = resSeven10265.ErrMsg
  32636. res.Cainfo = resSeven10265.Cainfo
  32637. res.WarnMsg = resSeven10265.WarnMsg
  32638. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32639. res.Infcode = infocode
  32640. } else {
  32641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32642. utils.ErrorLog("解析失败:%v", err)
  32643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32644. return
  32645. }
  32646. }
  32647. }
  32648. } else {
  32649. c.ServeSuccessJSON(map[string]interface{}{
  32650. "failed_code": -10,
  32651. "msg": result3101.ErrMsg,
  32652. })
  32653. return
  32654. }
  32655. } else {
  32656. var result string
  32657. var request_log string
  32658. var dat map[string]interface{}
  32659. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32660. allTotal = fmt.Sprintf("%.2f", total_two)
  32661. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  32662. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32663. if result3101.Infcode == 0 {
  32664. if len(result3101.Output.Result) > 0 {
  32665. c.ServeSuccessJSON(map[string]interface{}{
  32666. "failed_code": -10,
  32667. "failed_type": 100,
  32668. "warm_type": 2,
  32669. "msg": result3101,
  32670. })
  32671. return
  32672. } else {
  32673. var result string
  32674. var request_log string
  32675. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32676. allTotal = fmt.Sprintf("%.2f", total_two)
  32677. if his.IdCardType == 4 {
  32678. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id, acct_used_flag)
  32679. } else {
  32680. if his.IdCardType == 2 {
  32681. cert_no = psn_info.Certno
  32682. psn_info.VerifyNumber = psn_info.Certno
  32683. } else {
  32684. bas := strings.Split(psn_info.CardInfo, "|")
  32685. cert_no = bas[2]
  32686. }
  32687. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id, acct_used_flag)
  32688. }
  32689. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32690. fmt.Println(dat)
  32691. } else {
  32692. fmt.Println(err)
  32693. }
  32694. saveLog(result, request_log, "2206", "预结算")
  32695. }
  32696. } else {
  32697. c.ServeSuccessJSON(map[string]interface{}{
  32698. "failed_code": -10,
  32699. "msg": result3101.ErrMsg,
  32700. })
  32701. return
  32702. }
  32703. } else {
  32704. if his.IdCardType == 4 {
  32705. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id, acct_used_flag)
  32706. } else {
  32707. if his.IdCardType == 2 {
  32708. cert_no = psn_info.Certno
  32709. psn_info.VerifyNumber = psn_info.Certno
  32710. } else {
  32711. bas := strings.Split(psn_info.CardInfo, "|")
  32712. cert_no = bas[2]
  32713. }
  32714. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id, acct_used_flag)
  32715. }
  32716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32717. fmt.Println(dat)
  32718. } else {
  32719. fmt.Println(err)
  32720. }
  32721. saveLog(result, request_log, "2206", "预结算")
  32722. }
  32723. //userJSONBytes, _ := json.Marshal(dat)
  32724. //
  32725. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32726. // utils.ErrorLog("解析失败:%v", err)
  32727. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32728. // return
  32729. //}
  32730. userJSONBytes, _ := json.Marshal(dat)
  32731. if miConfig.Code == "H15049901371" {
  32732. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32733. utils.ErrorLog("解析失败:%v", err)
  32734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32735. return
  32736. }
  32737. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32738. res.Output = resSeven10265.Output
  32739. res.ErrMsg = resSeven10265.ErrMsg
  32740. res.Cainfo = resSeven10265.Cainfo
  32741. res.WarnMsg = resSeven10265.WarnMsg
  32742. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32743. res.Infcode = infocode
  32744. } else {
  32745. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32746. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32747. utils.ErrorLog("解析失败:%v", err)
  32748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32749. return
  32750. }
  32751. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32752. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32753. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32754. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32755. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32756. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32757. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32758. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32759. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32760. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32761. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32762. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32763. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32764. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32765. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32766. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32767. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32768. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32769. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32770. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32771. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32772. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32773. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32774. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32775. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32776. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32777. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32778. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32779. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32780. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32781. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32782. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32783. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32784. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32785. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32786. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32787. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32788. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32789. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32790. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32791. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32792. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32793. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32794. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32795. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32796. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32797. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32798. res.Cainfo = gzresSeven10265Two.Cainfo
  32799. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32800. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32801. //res.Infcode = infocode
  32802. } else {
  32803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32804. utils.ErrorLog("解析失败:%v", err)
  32805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32806. return
  32807. }
  32808. }
  32809. }
  32810. }
  32811. }
  32812. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32813. if res10633.Infcode == -1 {
  32814. errlog := &models.HisOrderError{
  32815. UserOrgId: adminUser.CurrentOrgId,
  32816. Ctime: time.Now().Unix(),
  32817. Mtime: time.Now().Unix(),
  32818. Number: chrg_bchno,
  32819. ErrMsg: res10633.ErrMsg,
  32820. Status: 1,
  32821. PatientId: id,
  32822. RecordTime: recordDateTime,
  32823. Stage: 20,
  32824. }
  32825. service.CreateErrMsgLog(errlog)
  32826. c.ServeSuccessJSON(map[string]interface{}{
  32827. "failed_code": -10,
  32828. "msg": res10633.ErrMsg,
  32829. })
  32830. return
  32831. }
  32832. if res10633.Infcode != 0 {
  32833. errlog := &models.HisOrderError{
  32834. UserOrgId: adminUser.CurrentOrgId,
  32835. Ctime: time.Now().Unix(),
  32836. Mtime: time.Now().Unix(),
  32837. Number: chrg_bchno,
  32838. ErrMsg: res10633.ErrMsg,
  32839. Status: 1,
  32840. PatientId: id,
  32841. RecordTime: recordDateTime,
  32842. Stage: 20,
  32843. }
  32844. service.CreateErrMsgLog(errlog)
  32845. c.ServeSuccessJSON(map[string]interface{}{
  32846. "failed_code": -10,
  32847. "msg": res10633.ErrMsg,
  32848. })
  32849. return
  32850. } else {
  32851. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32852. order.OrderStatus = 1
  32853. order.IsPre = 1
  32854. order.Status = 1
  32855. order.MdtrtId = res10633.Output.Setlinfo.MdtrtID
  32856. order.SetlId = res10633.Output.Setlinfo.SetlID
  32857. order.PsnNo = res10633.Output.Setlinfo.PsnNo
  32858. order.PsnName = res10633.Output.Setlinfo.PsnName
  32859. order.PsnCertType = res10633.Output.Setlinfo.PsnCertType
  32860. order.Certno = res10633.Output.Setlinfo.Certno
  32861. order.Gend = res10633.Output.Setlinfo.Gend
  32862. order.Naty = res10633.Output.Setlinfo.Naty
  32863. order.Age = res10633.Output.Setlinfo.Age
  32864. order.Insutype = res10633.Output.Setlinfo.Insutype
  32865. order.PsnType = res10633.Output.Setlinfo.PsnType
  32866. order.CvlservFlag = res10633.Output.Setlinfo.CvlservFlag
  32867. order.SetlTime = res10633.Output.Setlinfo.SetlTime
  32868. order.AcctUsedFlag = acct_used_flag
  32869. order.MdtrtCertType = res10633.Output.Setlinfo.MdtrtCertType
  32870. if res10633.Output.Setlinfo.MedType == "140101" {
  32871. order.MedType = "14"
  32872. } else {
  32873. if res10633.Output.Setlinfo.MedType == "110104" {
  32874. order.MedType = "11"
  32875. } else {
  32876. order.MedType = res10633.Output.Setlinfo.MedType
  32877. }
  32878. }
  32879. if res10633.Output.Setlinfo.MedType == "992102" {
  32880. order.MedType = "992102"
  32881. }
  32882. if res10633.Output.Setlinfo.MedType == "140104" {
  32883. order.MedType = "140104"
  32884. }
  32885. if res10633.Output.Setlinfo.MedType == "1104" {
  32886. order.MedType = "1104"
  32887. }
  32888. if res10633.Output.Setlinfo.MedType == "140201" {
  32889. order.MedType = "140201"
  32890. }
  32891. if res10633.Output.Setlinfo.MedType == "14" {
  32892. order.MedType = "14"
  32893. }
  32894. if reg_type == 1112 {
  32895. order.MedType = "1112"
  32896. }
  32897. if reg_type == 1111 {
  32898. order.MedType = "1111"
  32899. }
  32900. order.ClrType = res10633.Output.Setlinfo.ClrType
  32901. if adminUser.CurrentOrgId == 10480 {
  32902. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32903. order.ClrType = "11"
  32904. } else {
  32905. order.ClrType = "9903"
  32906. }
  32907. }
  32908. order.MedfeeSumamt = res10633.Output.Setlinfo.MedfeeSumamt
  32909. order.FulamtOwnpayAmt = res10633.Output.Setlinfo.FulamtOwnpayAmt
  32910. order.OverlmtSelfPay = res10633.Output.Setlinfo.OverlmtSelfpay
  32911. order.PreselfpayAmt = res10633.Output.Setlinfo.PreselfpayAmt
  32912. order.InscpScpAmt = res10633.Output.Setlinfo.InscpScpAmt
  32913. order.ActPayDedc = res10633.Output.Setlinfo.ActPayDedc
  32914. order.HifpPay = res10633.Output.Setlinfo.HifpPay
  32915. order.CvlservPay = res10633.Output.Setlinfo.CvlservPay
  32916. order.HifesPay = res10633.Output.Setlinfo.HifesPay
  32917. order.HifobPay = res10633.Output.Setlinfo.HifobPay
  32918. order.MafPay = res10633.Output.Setlinfo.MafPay
  32919. order.HifmiPay = res10633.Output.Setlinfo.HifmiPay
  32920. order.OthPay = res10633.Output.Setlinfo.OthPay
  32921. order.FundPaySumamt = res10633.Output.Setlinfo.FundPaySumamt
  32922. order.PsnPartAmt = res10633.Output.Setlinfo.PsnPartAmt
  32923. order.AcctPay = res10633.Output.Setlinfo.AcctPay
  32924. order.PsnCashPay = res10633.Output.Setlinfo.PsnCashPay
  32925. order.Balc = res10633.Output.Setlinfo.Balc
  32926. order.MedinsSetlId = res10633.Output.Setlinfo.MedinsSetlID
  32927. order.ClrOptins = res10633.Output.Setlinfo.ClrOptins
  32928. order.ClrWay = res10633.Output.Setlinfo.ClrWay
  32929. order.Creator = order.Creator
  32930. order.Modify = roles.AdminUserId
  32931. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32932. //detailStr := string(setlDetail)
  32933. //order.SetlDetail = detailStr
  32934. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32935. err = service.UpDateOrder(order)
  32936. if err == nil {
  32937. c.ServeSuccessJSON(map[string]interface{}{
  32938. "msg": "预结算成功",
  32939. })
  32940. } else {
  32941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32942. return
  32943. }
  32944. }
  32945. } else {
  32946. if res.Infcode == -1 {
  32947. errlog := &models.HisOrderError{
  32948. UserOrgId: adminUser.CurrentOrgId,
  32949. Ctime: time.Now().Unix(),
  32950. Mtime: time.Now().Unix(),
  32951. Number: chrg_bchno,
  32952. ErrMsg: res.ErrMsg,
  32953. Status: 1,
  32954. PatientId: id,
  32955. RecordTime: recordDateTime,
  32956. Stage: 20,
  32957. }
  32958. service.CreateErrMsgLog(errlog)
  32959. c.ServeSuccessJSON(map[string]interface{}{
  32960. "failed_code": -10,
  32961. "msg": res.ErrMsg,
  32962. })
  32963. return
  32964. }
  32965. if res.Infcode != 0 {
  32966. errlog := &models.HisOrderError{
  32967. UserOrgId: adminUser.CurrentOrgId,
  32968. Ctime: time.Now().Unix(),
  32969. Mtime: time.Now().Unix(),
  32970. Number: chrg_bchno,
  32971. ErrMsg: res.ErrMsg,
  32972. Status: 1,
  32973. PatientId: id,
  32974. RecordTime: recordDateTime,
  32975. Stage: 20,
  32976. }
  32977. service.CreateErrMsgLog(errlog)
  32978. c.ServeSuccessJSON(map[string]interface{}{
  32979. "failed_code": -10,
  32980. "msg": res.ErrMsg,
  32981. })
  32982. return
  32983. } else {
  32984. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32985. order.OrderStatus = 1
  32986. order.IsPre = 1
  32987. order.Status = 1
  32988. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32989. order.SetlId = res.Output.Setlinfo.SetlID
  32990. order.PsnNo = res.Output.Setlinfo.PsnNo
  32991. order.PsnName = res.Output.Setlinfo.PsnName
  32992. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32993. order.Certno = res.Output.Setlinfo.Certno
  32994. order.Gend = res.Output.Setlinfo.Gend
  32995. order.Naty = res.Output.Setlinfo.Naty
  32996. order.Age = res.Output.Setlinfo.Age
  32997. order.Insutype = res.Output.Setlinfo.Insutype
  32998. order.PsnType = res.Output.Setlinfo.PsnType
  32999. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  33000. order.SetlTime = res.Output.Setlinfo.SetlTime
  33001. order.AcctUsedFlag = acct_used_flag
  33002. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  33003. if res.Output.Setlinfo.MedType == "140101" {
  33004. order.MedType = "14"
  33005. } else {
  33006. if res.Output.Setlinfo.MedType == "110104" {
  33007. order.MedType = "11"
  33008. } else {
  33009. order.MedType = res.Output.Setlinfo.MedType
  33010. }
  33011. }
  33012. if res.Output.Setlinfo.MedType == "992102" {
  33013. order.MedType = "992102"
  33014. }
  33015. if res.Output.Setlinfo.MedType == "140104" {
  33016. order.MedType = "140104"
  33017. }
  33018. if res.Output.Setlinfo.MedType == "1104" {
  33019. order.MedType = "1104"
  33020. }
  33021. if res.Output.Setlinfo.MedType == "140201" {
  33022. order.MedType = "140201"
  33023. }
  33024. if res.Output.Setlinfo.MedType == "14" {
  33025. order.MedType = "14"
  33026. }
  33027. if reg_type == 1112 {
  33028. order.MedType = "1112"
  33029. }
  33030. if reg_type == 1111 {
  33031. order.MedType = "1111"
  33032. }
  33033. order.ClrType = res.Output.Setlinfo.ClrType
  33034. if adminUser.CurrentOrgId == 10480 {
  33035. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  33036. order.ClrType = "11"
  33037. } else {
  33038. order.ClrType = "9903"
  33039. }
  33040. }
  33041. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  33042. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  33043. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  33044. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  33045. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  33046. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  33047. order.HifpPay = res.Output.Setlinfo.HifpPay
  33048. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  33049. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  33050. order.HifesPay = res.Output.Setlinfo.HifesPay
  33051. order.HifobPay = res.Output.Setlinfo.HifobPay
  33052. order.MafPay = res.Output.Setlinfo.MafPay
  33053. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  33054. order.OthPay = res.Output.Setlinfo.OthPay
  33055. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  33056. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  33057. order.AcctPay = res.Output.Setlinfo.AcctPay
  33058. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  33059. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  33060. order.Balc = res.Output.Setlinfo.Balc
  33061. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  33062. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  33063. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  33064. order.ClrWay = res.Output.Setlinfo.ClrWay
  33065. order.Creator = order.Creator
  33066. order.Modify = roles.AdminUserId
  33067. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  33068. //detailStr := string(setlDetail)
  33069. //order.SetlDetail = detailStr
  33070. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  33071. err = service.UpDateOrder(order)
  33072. if err == nil {
  33073. c.ServeSuccessJSON(map[string]interface{}{
  33074. "msg": "预结算成功",
  33075. })
  33076. } else {
  33077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  33078. return
  33079. }
  33080. }
  33081. }
  33082. } else {
  33083. adminUser := c.GetAdminUserInfo()
  33084. errlog := &models.HisOrderError{
  33085. UserOrgId: adminUser.CurrentOrgId,
  33086. Ctime: time.Now().Unix(),
  33087. Mtime: time.Now().Unix(),
  33088. ErrMsg: res.ErrMsg,
  33089. Status: 1,
  33090. PatientId: id,
  33091. RecordTime: recordDateTime,
  33092. Stage: 4,
  33093. }
  33094. service.CreateErrMsgLog(errlog)
  33095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  33096. return
  33097. }
  33098. } else {
  33099. if miConfig.MdtrtareaAdmvs == "150404" {
  33100. order := &models.HisOrder{
  33101. UserOrgId: adminUser.CurrentOrgId,
  33102. HisPatientId: his.ID,
  33103. PatientId: his.PatientId,
  33104. SettleAccountsDate: recordDateTime,
  33105. Ctime: time.Now().Unix(),
  33106. Mtime: time.Now().Unix(),
  33107. MdtrtId: his.Number,
  33108. PsnNo: his.PsnNo,
  33109. MedType: strconv.FormatInt(reg_type, 10),
  33110. Status: 1,
  33111. Number: chrg_bchno,
  33112. Infcode: res.Infcode,
  33113. WarnMsg: res.WarnMsg,
  33114. Cainfo: res.Cainfo,
  33115. ErrMsg: res.ErrMsg,
  33116. RespondTime: res.RefmsgTime,
  33117. InfRefmsgid: res.InfRefmsgid,
  33118. OrderStatus: 1,
  33119. IsMedicineInsurance: 1,
  33120. SettleType: settle_accounts_type,
  33121. SettleStartTime: start_time,
  33122. SettleEndTime: end_time,
  33123. Creator: roles.AdminUserId,
  33124. Modify: roles.AdminUserId,
  33125. PType: 2,
  33126. Diagnosis: diagnosis_id,
  33127. }
  33128. err = service.CreateOrder(order)
  33129. if err != nil {
  33130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  33131. return
  33132. }
  33133. }
  33134. adminUser := c.GetAdminUserInfo()
  33135. errlog := &models.HisOrderError{
  33136. UserOrgId: adminUser.CurrentOrgId,
  33137. Ctime: time.Now().Unix(),
  33138. Mtime: time.Now().Unix(),
  33139. ErrMsg: res.ErrMsg,
  33140. Status: 1,
  33141. PatientId: id,
  33142. RecordTime: recordDateTime,
  33143. Stage: 4,
  33144. }
  33145. service.CreateErrMsgLog(errlog)
  33146. c.ServeSuccessJSON(map[string]interface{}{
  33147. "failed_code": -10,
  33148. "msg": res.ErrMsg,
  33149. })
  33150. return
  33151. }
  33152. }
  33153. }
  33154. }
  33155. // 退款
  33156. func (c *HisApiController) Refund() {
  33157. order_id, _ := c.GetInt64("order_id")
  33158. admin_user_id, _ := c.GetInt64("admin_user_id")
  33159. adminUser := c.GetAdminUserInfo()
  33160. var order models.HisOrder
  33161. order, _ = service.GetHisOrderByID(order_id)
  33162. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  33163. if fapiao.ID > 0 {
  33164. c.ServeSuccessJSON(map[string]interface{}{
  33165. "failed_code": -10,
  33166. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  33167. })
  33168. return
  33169. }
  33170. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33171. if order.ID == 0 {
  33172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33173. return
  33174. }
  33175. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33177. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33178. if config.IsOpen == 1 { //对接了医保,走医保流程
  33179. var res ResultSixteen
  33180. var ahres ResultSevenAH
  33181. var resSixteen10265 ResultSixteen10265
  33182. var resSixteen10265Two ResultSixteen10265Two
  33183. var gz ResultgzSixteen10265Two
  33184. var src_resquest string
  33185. var result string
  33186. if miConfig.MdtrtareaAdmvs == "421300" {
  33187. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33188. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33189. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33190. resp3, requestErr3 := http.Get(api3)
  33191. if requestErr3 != nil {
  33192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33193. return
  33194. }
  33195. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33196. if ioErr3 != nil {
  33197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33199. return
  33200. }
  33201. var respJSON3 map[string]interface{}
  33202. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33205. return
  33206. }
  33207. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33208. userJSONBytes3, _ := json.Marshal(respJSON3)
  33209. fmt.Println("log")
  33210. fmt.Println(string(userJSONBytes3))
  33211. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33212. utils.ErrorLog("解析失败:%v", err)
  33213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33214. return
  33215. }
  33216. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33217. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33218. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33219. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33220. resp3, requestErr3 := http.Get(api3)
  33221. if requestErr3 != nil {
  33222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33223. return
  33224. }
  33225. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33226. if ioErr3 != nil {
  33227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33229. return
  33230. }
  33231. var respJSON3 map[string]interface{}
  33232. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33235. return
  33236. }
  33237. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33238. userJSONBytes3, _ := json.Marshal(respJSON3)
  33239. fmt.Println("log")
  33240. fmt.Println(string(userJSONBytes3))
  33241. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33242. utils.ErrorLog("解析失败:%v", err)
  33243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33244. return
  33245. }
  33246. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33247. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33248. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33249. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33250. resp3, requestErr3 := http.Get(api3)
  33251. if requestErr3 != nil {
  33252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33253. return
  33254. }
  33255. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33256. if ioErr3 != nil {
  33257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33259. return
  33260. }
  33261. var respJSON3 map[string]interface{}
  33262. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33265. return
  33266. }
  33267. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33268. userJSONBytes3, _ := json.Marshal(respJSON3)
  33269. fmt.Println("log")
  33270. fmt.Println(string(userJSONBytes3))
  33271. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33272. utils.ErrorLog("解析失败:%v", err)
  33273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33274. return
  33275. }
  33276. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33277. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33278. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33279. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33280. resp3, requestErr3 := http.Get(api3)
  33281. if requestErr3 != nil {
  33282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33283. return
  33284. }
  33285. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33286. if ioErr3 != nil {
  33287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33289. return
  33290. }
  33291. var respJSON3 map[string]interface{}
  33292. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33295. return
  33296. }
  33297. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33298. userJSONBytes3, _ := json.Marshal(respJSON3)
  33299. fmt.Println("log")
  33300. fmt.Println(string(userJSONBytes3))
  33301. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33302. utils.ErrorLog("解析失败:%v", err)
  33303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33304. return
  33305. }
  33306. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33307. var api3 string
  33308. if miConfig.MdtrtareaAdmvs == "320830" {
  33309. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  33310. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33311. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33312. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33313. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33314. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33315. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33316. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33317. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33318. } else {
  33319. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33320. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33321. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33322. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33323. }
  33324. resp3, requestErr3 := http.Get(api3)
  33325. if requestErr3 != nil {
  33326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33327. return
  33328. }
  33329. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33330. if ioErr3 != nil {
  33331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. return
  33334. }
  33335. var respJSON3 map[string]interface{}
  33336. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33339. return
  33340. }
  33341. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33342. userJSONBytes3, _ := json.Marshal(respJSON3)
  33343. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33344. utils.ErrorLog("解析失败:%v", err)
  33345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33346. return
  33347. }
  33348. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33349. res.Output = resSixteen10265.Output
  33350. res.ErrMsg = resSixteen10265.ErrMsg
  33351. res.Cainfo = resSixteen10265.Cainfo
  33352. res.WarnMsg = resSixteen10265.WarnMsg
  33353. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33354. res.Infcode = infocode
  33355. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33356. var api3 string
  33357. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33358. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33359. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33360. resp3, requestErr3 := http.Get(api3)
  33361. if requestErr3 != nil {
  33362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33363. return
  33364. }
  33365. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33366. if ioErr3 != nil {
  33367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33369. return
  33370. }
  33371. var respJSON3 map[string]interface{}
  33372. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33375. return
  33376. }
  33377. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33378. userJSONBytes3, _ := json.Marshal(respJSON3)
  33379. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33380. utils.ErrorLog("解析失败:%v", err)
  33381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33382. return
  33383. }
  33384. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33385. res.Output = resSixteen10265.Output
  33386. res.ErrMsg = resSixteen10265.ErrMsg
  33387. res.Cainfo = resSixteen10265.Cainfo
  33388. res.WarnMsg = resSixteen10265.WarnMsg
  33389. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33390. res.Infcode = infocode
  33391. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33392. 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)
  33393. var dat map[string]interface{}
  33394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33395. fmt.Println(dat)
  33396. } else {
  33397. fmt.Println(err)
  33398. }
  33399. saveLog(result, src_resquest, "2208", "退费")
  33400. userJSONBytes, _ := json.Marshal(dat)
  33401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33402. utils.ErrorLog("解析失败:%v", err)
  33403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33404. return
  33405. }
  33406. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33407. 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, "")
  33408. var dat map[string]interface{}
  33409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33410. fmt.Println(dat)
  33411. } else {
  33412. fmt.Println(err)
  33413. }
  33414. saveLog(result, src_resquest, "2208", "退费")
  33415. userJSONBytes, _ := json.Marshal(dat)
  33416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33417. utils.ErrorLog("解析失败:%v", err)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33422. 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, "")
  33423. var dat map[string]interface{}
  33424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33425. fmt.Println(dat)
  33426. } else {
  33427. fmt.Println(err)
  33428. }
  33429. saveLog(result, src_resquest, "2208", "退费")
  33430. userJSONBytes, _ := json.Marshal(dat)
  33431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33432. utils.ErrorLog("解析失败:%v", err)
  33433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33434. return
  33435. }
  33436. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33437. 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, "")
  33438. var dat map[string]interface{}
  33439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33440. fmt.Println(dat)
  33441. } else {
  33442. fmt.Println(err)
  33443. }
  33444. saveLog(result, src_resquest, "2208", "退费")
  33445. userJSONBytes, _ := json.Marshal(dat)
  33446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33447. utils.ErrorLog("解析失败:%v", err)
  33448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33449. return
  33450. }
  33451. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33452. var api3 string
  33453. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33454. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33455. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33456. resp3, requestErr3 := http.Get(api3)
  33457. if requestErr3 != nil {
  33458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33459. return
  33460. }
  33461. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33462. if ioErr3 != nil {
  33463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33465. return
  33466. }
  33467. var respJSON3 map[string]interface{}
  33468. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33471. return
  33472. }
  33473. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33474. if status == "0" {
  33475. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33476. c.ServeSuccessJSON(map[string]interface{}{
  33477. "failed_code": -10,
  33478. "msg": err_msg,
  33479. })
  33480. return
  33481. }
  33482. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33483. userJSONBytes3, _ := json.Marshal(respJSON3)
  33484. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33485. // utils.ErrorLog("解析失败:%v", err)
  33486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33487. // return
  33488. //}
  33489. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33490. utils.ErrorLog("解析失败:%v", err)
  33491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33492. return
  33493. }
  33494. res.InfRefmsgid = ahres.InfRefmsgid
  33495. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33496. // 创建对应的Time类型
  33497. t := time.UnixMilli(timestamp)
  33498. // 格式化成指定的日期字符串
  33499. str := t.Format("2006-01-02 15:04:05")
  33500. res.Output.Setlinfo.SetlTime = str
  33501. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33502. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33503. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33504. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33505. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33506. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33507. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33508. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33509. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33510. //
  33511. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33512. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33513. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33514. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33515. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33516. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33517. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33518. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33519. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33520. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33521. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33522. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33523. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33524. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33525. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33526. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33527. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33528. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33529. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33530. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33531. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33532. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33533. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33534. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33535. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33536. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33537. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33538. //res.Output.Setldetail = ahres.Output.Setldetail
  33539. res.ErrMsg = ahres.ErrMsg
  33540. res.Cainfo = ahres.Cainfo
  33541. res.WarnMsg = ahres.WarnMsg
  33542. res.Infcode = ahres.Infcode
  33543. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33544. var api3 string
  33545. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33546. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33547. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33548. resp3, requestErr3 := http.Get(api3)
  33549. if requestErr3 != nil {
  33550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33551. return
  33552. }
  33553. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33554. if ioErr3 != nil {
  33555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33557. return
  33558. }
  33559. var respJSON3 map[string]interface{}
  33560. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33563. return
  33564. }
  33565. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33566. if status == "0" {
  33567. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33568. c.ServeSuccessJSON(map[string]interface{}{
  33569. "failed_code": -10,
  33570. "msg": err_msg,
  33571. })
  33572. return
  33573. }
  33574. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33575. userJSONBytes3, _ := json.Marshal(respJSON3)
  33576. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33577. // utils.ErrorLog("解析失败:%v", err)
  33578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33579. // return
  33580. //}
  33581. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33582. utils.ErrorLog("解析失败:%v", err)
  33583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33584. return
  33585. }
  33586. res.InfRefmsgid = ahres.InfRefmsgid
  33587. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33588. // 创建对应的Time类型
  33589. t := time.UnixMilli(timestamp)
  33590. // 格式化成指定的日期字符串
  33591. str := t.Format("2006-01-02 15:04:05")
  33592. res.Output.Setlinfo.SetlTime = str
  33593. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33594. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33595. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33596. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33597. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33598. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33599. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33600. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33601. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33602. //
  33603. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33604. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33605. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33606. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33607. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33608. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33609. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33610. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33611. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33612. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33613. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33614. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33615. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33616. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33617. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33618. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33619. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33620. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33621. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33622. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33623. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33624. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33625. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33626. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33627. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33628. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33629. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33630. //res.Output.Setldetail = ahres.Output.Setldetail
  33631. res.ErrMsg = ahres.ErrMsg
  33632. res.Cainfo = ahres.Cainfo
  33633. res.WarnMsg = ahres.WarnMsg
  33634. res.Infcode = ahres.Infcode
  33635. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33636. 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, "")
  33637. var dat map[string]interface{}
  33638. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33639. fmt.Println(dat)
  33640. } else {
  33641. fmt.Println(err)
  33642. }
  33643. saveLog(result, src_resquest, "2208", "退费")
  33644. userJSONBytes, _ := json.Marshal(dat)
  33645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33646. utils.ErrorLog("解析失败:%v", err)
  33647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33648. return
  33649. }
  33650. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33651. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33652. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33653. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33654. resp3, requestErr3 := http.Get(api3)
  33655. if requestErr3 != nil {
  33656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33657. return
  33658. }
  33659. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33660. if ioErr3 != nil {
  33661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33663. return
  33664. }
  33665. var respJSON3 map[string]interface{}
  33666. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33669. return
  33670. }
  33671. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33672. userJSONBytes3, _ := json.Marshal(respJSON3)
  33673. fmt.Println("log")
  33674. fmt.Println(string(userJSONBytes3))
  33675. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33676. utils.ErrorLog("解析失败:%v", err)
  33677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33678. return
  33679. }
  33680. } else {
  33681. if miConfig.Code == "H15049901371" {
  33682. 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)
  33683. var dat map[string]interface{}
  33684. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33685. fmt.Println(dat)
  33686. } else {
  33687. fmt.Println(err)
  33688. }
  33689. saveLog(result, src_resquest, "2208", "退费")
  33690. if strings.Contains(result, "Post") {
  33691. res.Infcode = -1
  33692. res.ErrMsg = result
  33693. }
  33694. userJSONBytes, _ := json.Marshal(dat)
  33695. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33696. utils.ErrorLog("解析失败:%v", err)
  33697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33698. return
  33699. }
  33700. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33701. res.Output = resSixteen10265.Output
  33702. res.ErrMsg = resSixteen10265.ErrMsg
  33703. res.Cainfo = resSixteen10265.Cainfo
  33704. res.WarnMsg = resSixteen10265.WarnMsg
  33705. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33706. res.Infcode = infocode
  33707. } else {
  33708. 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)
  33709. var dat map[string]interface{}
  33710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33711. fmt.Println(dat)
  33712. } else {
  33713. fmt.Println(err)
  33714. }
  33715. saveLog(result, src_resquest, "2208", "退费")
  33716. userJSONBytes, _ := json.Marshal(dat)
  33717. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33718. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33719. utils.ErrorLog("解析失败:%v", err)
  33720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33721. return
  33722. }
  33723. res.Infcode = gz.Infcode
  33724. } else {
  33725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33726. utils.ErrorLog("解析失败:%v", err)
  33727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33728. return
  33729. }
  33730. }
  33731. if strings.Contains(result, "Post") {
  33732. res.Infcode = -1
  33733. res.ErrMsg = result
  33734. }
  33735. }
  33736. }
  33737. if res.Infcode == -1 {
  33738. c.ServeSuccessJSON(map[string]interface{}{
  33739. "failed_code": -10,
  33740. "msg": res.ErrMsg,
  33741. })
  33742. return
  33743. }
  33744. if res.Infcode != -1 {
  33745. var res2 ResultSix
  33746. var resSix10265 ResultSix10265
  33747. if miConfig.MdtrtareaAdmvs == "421300" {
  33748. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33749. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33750. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33751. resp3, requestErr3 := http.Get(api3)
  33752. if requestErr3 != nil {
  33753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33754. return
  33755. }
  33756. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33757. if ioErr3 != nil {
  33758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33760. return
  33761. }
  33762. var respJSON3 map[string]interface{}
  33763. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33766. return
  33767. }
  33768. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33769. userJSONBytes3, _ := json.Marshal(respJSON3)
  33770. fmt.Println("log")
  33771. fmt.Println(string(userJSONBytes3))
  33772. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33773. utils.ErrorLog("解析失败:%v", err)
  33774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33775. return
  33776. }
  33777. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33778. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33779. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33781. resp3, requestErr3 := http.Get(api3)
  33782. if requestErr3 != nil {
  33783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33784. return
  33785. }
  33786. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33787. if ioErr3 != nil {
  33788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33790. return
  33791. }
  33792. var respJSON3 map[string]interface{}
  33793. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33796. return
  33797. }
  33798. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33799. userJSONBytes3, _ := json.Marshal(respJSON3)
  33800. fmt.Println("log")
  33801. fmt.Println(string(userJSONBytes3))
  33802. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33803. utils.ErrorLog("解析失败:%v", err)
  33804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33805. return
  33806. }
  33807. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33808. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33809. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33810. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33811. resp3, requestErr3 := http.Get(api3)
  33812. if requestErr3 != nil {
  33813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33814. return
  33815. }
  33816. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33817. if ioErr3 != nil {
  33818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33820. return
  33821. }
  33822. var respJSON3 map[string]interface{}
  33823. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33826. return
  33827. }
  33828. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33829. userJSONBytes3, _ := json.Marshal(respJSON3)
  33830. fmt.Println("log")
  33831. fmt.Println(string(userJSONBytes3))
  33832. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33833. utils.ErrorLog("解析失败:%v", err)
  33834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33835. return
  33836. }
  33837. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33838. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33839. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33841. resp3, requestErr3 := http.Get(api3)
  33842. if requestErr3 != nil {
  33843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33844. return
  33845. }
  33846. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33847. if ioErr3 != nil {
  33848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. return
  33851. }
  33852. var respJSON3 map[string]interface{}
  33853. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33856. return
  33857. }
  33858. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33859. userJSONBytes3, _ := json.Marshal(respJSON3)
  33860. fmt.Println("log")
  33861. fmt.Println(string(userJSONBytes3))
  33862. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33863. utils.ErrorLog("解析失败:%v", err)
  33864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33865. return
  33866. }
  33867. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33868. var api3 string
  33869. if miConfig.MdtrtareaAdmvs == "320830" {
  33870. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33871. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33872. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33873. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33874. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33875. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33876. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33878. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33879. } else {
  33880. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33881. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33882. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33883. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33884. }
  33885. resp3, requestErr3 := http.Get(api3)
  33886. if requestErr3 != nil {
  33887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33888. return
  33889. }
  33890. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33891. if ioErr3 != nil {
  33892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33894. return
  33895. }
  33896. var respJSON3 map[string]interface{}
  33897. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33900. return
  33901. }
  33902. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33903. userJSONBytes3, _ := json.Marshal(respJSON3)
  33904. fmt.Println("log")
  33905. fmt.Println(string(userJSONBytes3))
  33906. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33907. utils.ErrorLog("解析失败:%v", err)
  33908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33909. return
  33910. }
  33911. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33912. res2.Output = resSix10265.Output
  33913. res2.ErrMsg = resSix10265.ErrMsg
  33914. res2.Cainfo = resSix10265.Cainfo
  33915. res2.WarnMsg = resSix10265.WarnMsg
  33916. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33917. res2.Infcode = infocode
  33918. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33919. var api3 string
  33920. new_chrg_bchno := order.Number
  33921. if adminUser.CurrentOrgId == 10265 {
  33922. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33923. new_chrg_bchno = "0000"
  33924. }
  33925. }
  33926. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33927. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33928. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33929. resp3, requestErr3 := http.Get(api3)
  33930. if requestErr3 != nil {
  33931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33932. return
  33933. }
  33934. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33935. if ioErr3 != nil {
  33936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33938. return
  33939. }
  33940. var respJSON3 map[string]interface{}
  33941. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33944. return
  33945. }
  33946. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33947. userJSONBytes3, _ := json.Marshal(respJSON3)
  33948. fmt.Println("log")
  33949. fmt.Println(string(userJSONBytes3))
  33950. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33951. utils.ErrorLog("解析失败:%v", err)
  33952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33953. return
  33954. }
  33955. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33956. res2.Output = resSix10265.Output
  33957. res2.ErrMsg = resSix10265.ErrMsg
  33958. res2.Cainfo = resSix10265.Cainfo
  33959. res2.WarnMsg = resSix10265.WarnMsg
  33960. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33961. res2.Infcode = infocode
  33962. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33963. 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)
  33964. var dat map[string]interface{}
  33965. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33966. fmt.Println(dat)
  33967. } else {
  33968. fmt.Println(err)
  33969. }
  33970. saveLog(result2, src_request, "2205", "撤销明细")
  33971. userJSONBytes, _ := json.Marshal(dat)
  33972. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33973. utils.ErrorLog("解析失败:%v", err)
  33974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33975. return
  33976. }
  33977. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33978. 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, "")
  33979. var dat map[string]interface{}
  33980. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33981. fmt.Println(dat)
  33982. } else {
  33983. fmt.Println(err)
  33984. }
  33985. saveLog(result2, src_request, "2205", "撤销明细")
  33986. userJSONBytes, _ := json.Marshal(dat)
  33987. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33988. utils.ErrorLog("解析失败:%v", err)
  33989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33990. return
  33991. }
  33992. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33993. 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, "")
  33994. var dat map[string]interface{}
  33995. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33996. fmt.Println(dat)
  33997. } else {
  33998. fmt.Println(err)
  33999. }
  34000. saveLog(result2, src_request, "2205", "撤销明细")
  34001. userJSONBytes, _ := json.Marshal(dat)
  34002. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34003. utils.ErrorLog("解析失败:%v", err)
  34004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34005. return
  34006. }
  34007. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34008. 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, "")
  34009. var dat map[string]interface{}
  34010. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34011. fmt.Println(dat)
  34012. } else {
  34013. fmt.Println(err)
  34014. }
  34015. saveLog(result2, src_request, "2205", "撤销明细")
  34016. userJSONBytes, _ := json.Marshal(dat)
  34017. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34018. utils.ErrorLog("解析失败:%v", err)
  34019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34020. return
  34021. }
  34022. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34023. var api3 string
  34024. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34025. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34026. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34027. resp3, requestErr3 := http.Get(api3)
  34028. if requestErr3 != nil {
  34029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34030. return
  34031. }
  34032. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34033. if ioErr3 != nil {
  34034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34036. return
  34037. }
  34038. var respJSON3 map[string]interface{}
  34039. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34042. return
  34043. }
  34044. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34045. if status == "0" {
  34046. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34047. c.ServeSuccessJSON(map[string]interface{}{
  34048. "failed_code": -10,
  34049. "msg": err_msg,
  34050. })
  34051. return
  34052. }
  34053. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34054. userJSONBytes3, _ := json.Marshal(respJSON3)
  34055. fmt.Println("log")
  34056. fmt.Println(string(userJSONBytes3))
  34057. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34058. utils.ErrorLog("解析失败:%v", err)
  34059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34060. return
  34061. }
  34062. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34063. 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, "")
  34064. var dat map[string]interface{}
  34065. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34066. fmt.Println(dat)
  34067. } else {
  34068. fmt.Println(err)
  34069. }
  34070. saveLog(result2, src_request, "2205", "撤销明细")
  34071. userJSONBytes, _ := json.Marshal(dat)
  34072. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34073. utils.ErrorLog("解析失败:%v", err)
  34074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34075. return
  34076. }
  34077. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34078. 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, "")
  34079. var dat map[string]interface{}
  34080. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34081. fmt.Println(dat)
  34082. } else {
  34083. fmt.Println(err)
  34084. }
  34085. saveLog(result2, src_request, "2205", "撤销明细")
  34086. userJSONBytes, _ := json.Marshal(dat)
  34087. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34088. utils.ErrorLog("解析失败:%v", err)
  34089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34090. return
  34091. }
  34092. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34093. 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, "")
  34094. var dat map[string]interface{}
  34095. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34096. fmt.Println(dat)
  34097. } else {
  34098. fmt.Println(err)
  34099. }
  34100. saveLog(result2, src_request, "2205", "撤销明细")
  34101. userJSONBytes, _ := json.Marshal(dat)
  34102. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34103. utils.ErrorLog("解析失败:%v", err)
  34104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34105. return
  34106. }
  34107. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34108. var api3 string
  34109. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34110. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34111. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34112. resp3, requestErr3 := http.Get(api3)
  34113. if requestErr3 != nil {
  34114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34115. return
  34116. }
  34117. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34118. if ioErr3 != nil {
  34119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34121. return
  34122. }
  34123. var respJSON3 map[string]interface{}
  34124. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34127. return
  34128. }
  34129. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34130. if status == "0" {
  34131. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34132. c.ServeSuccessJSON(map[string]interface{}{
  34133. "failed_code": -10,
  34134. "msg": err_msg,
  34135. })
  34136. return
  34137. }
  34138. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34139. userJSONBytes3, _ := json.Marshal(respJSON3)
  34140. fmt.Println("log")
  34141. fmt.Println(string(userJSONBytes3))
  34142. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34143. utils.ErrorLog("解析失败:%v", err)
  34144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34145. return
  34146. }
  34147. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34148. 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, "")
  34149. var dat map[string]interface{}
  34150. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34151. fmt.Println(dat)
  34152. } else {
  34153. fmt.Println(err)
  34154. }
  34155. saveLog(result2, src_request, "2205", "撤销明细")
  34156. userJSONBytes, _ := json.Marshal(dat)
  34157. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34158. utils.ErrorLog("解析失败:%v", err)
  34159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34160. return
  34161. }
  34162. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34163. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  34164. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34165. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34166. resp3, requestErr3 := http.Get(api3)
  34167. if requestErr3 != nil {
  34168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34169. return
  34170. }
  34171. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34172. if ioErr3 != nil {
  34173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34175. return
  34176. }
  34177. var respJSON3 map[string]interface{}
  34178. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34181. return
  34182. }
  34183. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34184. userJSONBytes3, _ := json.Marshal(respJSON3)
  34185. fmt.Println("log")
  34186. fmt.Println(string(userJSONBytes3))
  34187. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34188. utils.ErrorLog("解析失败:%v", err)
  34189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34190. return
  34191. }
  34192. } else {
  34193. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34194. res2.Infcode = 0
  34195. } else {
  34196. 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)
  34197. var dat map[string]interface{}
  34198. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34199. fmt.Println(dat)
  34200. } else {
  34201. fmt.Println(err)
  34202. }
  34203. saveLog(result2, src_request, "2205", "撤销明细")
  34204. userJSONBytes, _ := json.Marshal(dat)
  34205. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34206. utils.ErrorLog("解析失败:%v", err)
  34207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34208. return
  34209. }
  34210. }
  34211. }
  34212. if res2.Infcode == -1 {
  34213. c.ServeSuccessJSON(map[string]interface{}{
  34214. "failed_code": -10,
  34215. "msg": res2.ErrMsg,
  34216. })
  34217. return
  34218. }
  34219. if res2.Infcode == 0 {
  34220. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  34221. if err == nil {
  34222. //当押金不为零时产生退费记录
  34223. if order.Decimal != 0 {
  34224. tmp := strconv.FormatInt(order.ID, 10)
  34225. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  34226. if err != nil {
  34227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34228. return
  34229. }
  34230. }
  34231. c.ServeSuccessJSON(map[string]interface{}{
  34232. "msg": "退费成功",
  34233. })
  34234. } else {
  34235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34236. return
  34237. }
  34238. } else {
  34239. c.ServeSuccessJSON(map[string]interface{}{
  34240. "failed_code": -10,
  34241. "msg": res2.ErrMsg,
  34242. })
  34243. }
  34244. } else {
  34245. c.ServeSuccessJSON(map[string]interface{}{
  34246. "failed_code": -10,
  34247. "msg": res.ErrMsg,
  34248. })
  34249. }
  34250. }
  34251. }
  34252. func (c *HisApiController) RefundNumber() {
  34253. record_time := c.GetString("record_time")
  34254. //patient_id, _ := c.GetInt64("patient_id")
  34255. admin_user_id, _ := c.GetInt64("admin_user_id")
  34256. his_patient_id, _ := c.GetInt64("id")
  34257. timeLayout := "2006-01-02"
  34258. loc, _ := time.LoadLocation("Local")
  34259. adminUser := c.GetAdminUserInfo()
  34260. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34261. fmt.Println(err)
  34262. if err != nil {
  34263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34264. return
  34265. }
  34266. recordDateTime := theTime.Unix()
  34267. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34268. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  34269. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34270. //order, _ := service.GetHisOrderByID(order_id)
  34271. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34272. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34273. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34274. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  34275. if count > 0 {
  34276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  34277. return
  34278. }
  34279. if config.IsOpen == 1 { //对接了医保,走医保流程
  34280. var res2 ResultSix
  34281. var res3 GZResultSix
  34282. var resSix10265 ResultSix10265
  34283. if miConfig.MdtrtareaAdmvs == "421300" {
  34284. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34285. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34286. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34287. resp3, requestErr3 := http.Get(api3)
  34288. if requestErr3 != nil {
  34289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34290. return
  34291. }
  34292. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34293. if ioErr3 != nil {
  34294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34296. return
  34297. }
  34298. var respJSON3 map[string]interface{}
  34299. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34302. return
  34303. }
  34304. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34305. userJSONBytes3, _ := json.Marshal(respJSON3)
  34306. fmt.Println("log")
  34307. fmt.Println(string(userJSONBytes3))
  34308. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34309. utils.ErrorLog("解析失败:%v", err)
  34310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34311. return
  34312. }
  34313. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34314. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34315. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34316. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34317. resp3, requestErr3 := http.Get(api3)
  34318. if requestErr3 != nil {
  34319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34320. return
  34321. }
  34322. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34323. if ioErr3 != nil {
  34324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34326. return
  34327. }
  34328. var respJSON3 map[string]interface{}
  34329. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34332. return
  34333. }
  34334. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34335. userJSONBytes3, _ := json.Marshal(respJSON3)
  34336. fmt.Println("log")
  34337. fmt.Println(string(userJSONBytes3))
  34338. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34339. utils.ErrorLog("解析失败:%v", err)
  34340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34341. return
  34342. }
  34343. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34344. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34345. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34346. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34347. resp3, requestErr3 := http.Get(api3)
  34348. if requestErr3 != nil {
  34349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34350. return
  34351. }
  34352. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34353. if ioErr3 != nil {
  34354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34356. return
  34357. }
  34358. var respJSON3 map[string]interface{}
  34359. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34362. return
  34363. }
  34364. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34365. userJSONBytes3, _ := json.Marshal(respJSON3)
  34366. fmt.Println("log")
  34367. fmt.Println(string(userJSONBytes3))
  34368. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34369. utils.ErrorLog("解析失败:%v", err)
  34370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34371. return
  34372. }
  34373. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34374. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34375. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34376. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34377. resp3, requestErr3 := http.Get(api3)
  34378. if requestErr3 != nil {
  34379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34380. return
  34381. }
  34382. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34383. if ioErr3 != nil {
  34384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34386. return
  34387. }
  34388. var respJSON3 map[string]interface{}
  34389. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34392. return
  34393. }
  34394. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34395. userJSONBytes3, _ := json.Marshal(respJSON3)
  34396. fmt.Println("log")
  34397. fmt.Println(string(userJSONBytes3))
  34398. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34399. utils.ErrorLog("解析失败:%v", err)
  34400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34401. return
  34402. }
  34403. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34404. var api3 string
  34405. if miConfig.MdtrtareaAdmvs == "320830" {
  34406. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34407. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34408. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34409. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34410. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34411. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34412. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34414. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34415. } else {
  34416. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34417. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34418. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34419. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34420. }
  34421. resp3, requestErr3 := http.Get(api3)
  34422. if requestErr3 != nil {
  34423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34424. return
  34425. }
  34426. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34427. if ioErr3 != nil {
  34428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34430. return
  34431. }
  34432. var respJSON3 map[string]interface{}
  34433. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34436. return
  34437. }
  34438. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34439. userJSONBytes3, _ := json.Marshal(respJSON3)
  34440. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34441. utils.ErrorLog("解析失败:%v", err)
  34442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34443. return
  34444. }
  34445. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34446. res2.Output = resSix10265.Output
  34447. res2.ErrMsg = resSix10265.ErrMsg
  34448. res2.Cainfo = resSix10265.Cainfo
  34449. res2.WarnMsg = resSix10265.WarnMsg
  34450. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34451. res2.Infcode = infocode
  34452. } else if miConfig.MdtrtareaAdmvs == "150404" {
  34453. var api3 string
  34454. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34455. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34456. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34457. resp3, requestErr3 := http.Get(api3)
  34458. if requestErr3 != nil {
  34459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34460. return
  34461. }
  34462. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34463. if ioErr3 != nil {
  34464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34466. return
  34467. }
  34468. var respJSON3 map[string]interface{}
  34469. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34472. return
  34473. }
  34474. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34475. userJSONBytes3, _ := json.Marshal(respJSON3)
  34476. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34477. utils.ErrorLog("解析失败:%v", err)
  34478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34479. return
  34480. }
  34481. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34482. res2.Output = resSix10265.Output
  34483. res2.ErrMsg = resSix10265.ErrMsg
  34484. res2.Cainfo = resSix10265.Cainfo
  34485. res2.WarnMsg = resSix10265.WarnMsg
  34486. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34487. res2.Infcode = infocode
  34488. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34489. 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)
  34490. var dat map[string]interface{}
  34491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34492. fmt.Println(dat)
  34493. } else {
  34494. fmt.Println(err)
  34495. }
  34496. saveLog(result, request, "2202", "退号")
  34497. userJSONBytes, _ := json.Marshal(dat)
  34498. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34499. utils.ErrorLog("解析失败:%v", err)
  34500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34501. return
  34502. }
  34503. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34504. 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, "")
  34505. var dat map[string]interface{}
  34506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34507. fmt.Println(dat)
  34508. } else {
  34509. fmt.Println(err)
  34510. }
  34511. saveLog(result, request, "2202", "退号")
  34512. userJSONBytes, _ := json.Marshal(dat)
  34513. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34514. utils.ErrorLog("解析失败:%v", err)
  34515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34516. return
  34517. }
  34518. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34519. 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, "")
  34520. var dat map[string]interface{}
  34521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34522. fmt.Println(dat)
  34523. } else {
  34524. fmt.Println(err)
  34525. }
  34526. saveLog(result, request, "2202", "退号")
  34527. userJSONBytes, _ := json.Marshal(dat)
  34528. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34529. utils.ErrorLog("解析失败:%v", err)
  34530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34531. return
  34532. }
  34533. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34534. 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, "")
  34535. var dat map[string]interface{}
  34536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34537. fmt.Println(dat)
  34538. } else {
  34539. fmt.Println(err)
  34540. }
  34541. saveLog(result, request, "2202", "退号")
  34542. userJSONBytes, _ := json.Marshal(dat)
  34543. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34544. utils.ErrorLog("解析失败:%v", err)
  34545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34546. return
  34547. }
  34548. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34549. var api3 string
  34550. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34551. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34553. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34554. resp3, requestErr3 := http.Get(api3)
  34555. if requestErr3 != nil {
  34556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34557. return
  34558. }
  34559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34560. if ioErr3 != nil {
  34561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34563. return
  34564. }
  34565. var respJSON3 map[string]interface{}
  34566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34569. return
  34570. }
  34571. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34572. if status == "0" {
  34573. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34574. c.ServeSuccessJSON(map[string]interface{}{
  34575. "failed_code": -10,
  34576. "msg": err_msg,
  34577. })
  34578. return
  34579. }
  34580. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34581. userJSONBytes3, _ := json.Marshal(respJSON3)
  34582. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34583. utils.ErrorLog("解析失败:%v", err)
  34584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34585. return
  34586. }
  34587. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34588. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34589. var api3 string
  34590. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34591. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34592. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34593. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34594. resp3, requestErr3 := http.Get(api3)
  34595. if requestErr3 != nil {
  34596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34597. return
  34598. }
  34599. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34600. if ioErr3 != nil {
  34601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34603. return
  34604. }
  34605. var respJSON3 map[string]interface{}
  34606. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34609. return
  34610. }
  34611. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34612. if status == "0" {
  34613. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34614. c.ServeSuccessJSON(map[string]interface{}{
  34615. "failed_code": -10,
  34616. "msg": err_msg,
  34617. })
  34618. return
  34619. }
  34620. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34621. userJSONBytes3, _ := json.Marshal(respJSON3)
  34622. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34623. utils.ErrorLog("解析失败:%v", err)
  34624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34625. return
  34626. }
  34627. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34628. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34629. 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, "")
  34630. var dat map[string]interface{}
  34631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34632. fmt.Println(dat)
  34633. } else {
  34634. fmt.Println(err)
  34635. }
  34636. saveLog(result, request, "2202", "退号")
  34637. userJSONBytes, _ := json.Marshal(dat)
  34638. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34639. utils.ErrorLog("解析失败:%v", err)
  34640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34641. return
  34642. }
  34643. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34644. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34645. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34647. resp3, requestErr3 := http.Get(api3)
  34648. if requestErr3 != nil {
  34649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34650. return
  34651. }
  34652. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34653. if ioErr3 != nil {
  34654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34656. return
  34657. }
  34658. var respJSON3 map[string]interface{}
  34659. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34662. return
  34663. }
  34664. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34665. userJSONBytes3, _ := json.Marshal(respJSON3)
  34666. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34667. utils.ErrorLog("解析失败:%v", err)
  34668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34669. return
  34670. }
  34671. } else {
  34672. var api3 string
  34673. if miConfig.Code == "H15049901371" {
  34674. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34675. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34677. } else {
  34678. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34679. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34681. }
  34682. resp3, requestErr3 := http.Get(api3)
  34683. if requestErr3 != nil {
  34684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34685. return
  34686. }
  34687. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34688. if ioErr3 != nil {
  34689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34691. return
  34692. }
  34693. var respJSON3 map[string]interface{}
  34694. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34697. return
  34698. }
  34699. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34700. userJSONBytes3, _ := json.Marshal(respJSON3)
  34701. if miConfig.Code == "H15049901371" {
  34702. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34703. utils.ErrorLog("解析失败:%v", err)
  34704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34705. return
  34706. }
  34707. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34708. res2.Output = resSix10265.Output
  34709. res2.ErrMsg = resSix10265.ErrMsg
  34710. res2.Cainfo = resSix10265.Cainfo
  34711. res2.WarnMsg = resSix10265.WarnMsg
  34712. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34713. res2.Infcode = infocode
  34714. } else {
  34715. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34716. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34717. utils.ErrorLog("解析失败:%v", err)
  34718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34719. return
  34720. }
  34721. res2.Infcode = res3.Infcode
  34722. } else {
  34723. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34724. utils.ErrorLog("解析失败:%v", err)
  34725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34726. return
  34727. }
  34728. }
  34729. }
  34730. }
  34731. if res2.Infcode == -1 {
  34732. c.ServeSuccessJSON(map[string]interface{}{
  34733. "failed_code": -10,
  34734. "msg": res2.ErrMsg,
  34735. })
  34736. return
  34737. }
  34738. if res2.Infcode == 0 {
  34739. if err == nil {
  34740. c.ServeSuccessJSON(map[string]interface{}{
  34741. "msg": "退号成功",
  34742. })
  34743. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34744. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34745. } else {
  34746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34747. return
  34748. }
  34749. }
  34750. } else {
  34751. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34752. //if err == nil {
  34753. // c.ServeSuccessJSON(map[string]interface{}{
  34754. // "msg": "退费成功",
  34755. // })
  34756. //} else {
  34757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34758. // return
  34759. //}
  34760. }
  34761. }
  34762. func (c *HisApiController) RefundDetail() {
  34763. order_id, _ := c.GetInt64("order_id")
  34764. admin_user_id, _ := c.GetInt64("admin_user_id")
  34765. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34766. number := c.GetString("number")
  34767. record_time := c.GetString("record_time")
  34768. patient_id, _ := c.GetInt64("patient_id")
  34769. //med_type, _ := c.GetInt64("med_type")
  34770. timeLayout := "2006-01-02"
  34771. loc, _ := time.LoadLocation("Local")
  34772. adminUser := c.GetAdminUserInfo()
  34773. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34774. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34775. fmt.Println(err)
  34776. if err != nil {
  34777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34778. return
  34779. }
  34780. recordDateTime := theTime.Unix()
  34781. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34782. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34784. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34785. var order models.HisOrder
  34786. order, _ = service.GetHisOrderByID(order_id)
  34787. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34788. if config.IsOpen == 1 { //对接了医保,走医保流程
  34789. var res2 ResultSix
  34790. if miConfig.MdtrtareaAdmvs == "421300" {
  34791. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34792. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34793. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34794. resp3, requestErr3 := http.Get(api3)
  34795. if requestErr3 != nil {
  34796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34797. return
  34798. }
  34799. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34800. if ioErr3 != nil {
  34801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34803. return
  34804. }
  34805. var respJSON3 map[string]interface{}
  34806. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34809. return
  34810. }
  34811. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34812. userJSONBytes3, _ := json.Marshal(respJSON3)
  34813. fmt.Println("log")
  34814. fmt.Println(string(userJSONBytes3))
  34815. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34816. utils.ErrorLog("解析失败:%v", err)
  34817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34818. return
  34819. }
  34820. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34821. if err == nil {
  34822. c.ServeSuccessJSON(map[string]interface{}{
  34823. "msg": "撤销明细成功",
  34824. })
  34825. return
  34826. } else {
  34827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34828. return
  34829. }
  34830. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34831. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34832. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34833. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34834. resp3, requestErr3 := http.Get(api3)
  34835. if requestErr3 != nil {
  34836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34837. return
  34838. }
  34839. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34840. if ioErr3 != nil {
  34841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34843. return
  34844. }
  34845. var respJSON3 map[string]interface{}
  34846. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34849. return
  34850. }
  34851. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34852. userJSONBytes3, _ := json.Marshal(respJSON3)
  34853. fmt.Println("log")
  34854. fmt.Println(string(userJSONBytes3))
  34855. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34856. utils.ErrorLog("解析失败:%v", err)
  34857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34858. return
  34859. }
  34860. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34861. if err == nil {
  34862. c.ServeSuccessJSON(map[string]interface{}{
  34863. "msg": "撤销明细成功",
  34864. })
  34865. return
  34866. } else {
  34867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34868. return
  34869. }
  34870. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34871. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34872. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34873. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34874. resp3, requestErr3 := http.Get(api3)
  34875. if requestErr3 != nil {
  34876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34877. return
  34878. }
  34879. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34880. if ioErr3 != nil {
  34881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34883. return
  34884. }
  34885. var respJSON3 map[string]interface{}
  34886. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34889. return
  34890. }
  34891. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34892. userJSONBytes3, _ := json.Marshal(respJSON3)
  34893. fmt.Println("log")
  34894. fmt.Println(string(userJSONBytes3))
  34895. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34896. utils.ErrorLog("解析失败:%v", err)
  34897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34898. return
  34899. }
  34900. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34901. if err == nil {
  34902. c.ServeSuccessJSON(map[string]interface{}{
  34903. "msg": "撤销明细成功",
  34904. })
  34905. return
  34906. } else {
  34907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34908. return
  34909. }
  34910. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34911. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34912. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34913. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34914. resp3, requestErr3 := http.Get(api3)
  34915. if requestErr3 != nil {
  34916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34917. return
  34918. }
  34919. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34920. if ioErr3 != nil {
  34921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34923. return
  34924. }
  34925. var respJSON3 map[string]interface{}
  34926. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34929. return
  34930. }
  34931. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34932. userJSONBytes3, _ := json.Marshal(respJSON3)
  34933. fmt.Println("log")
  34934. fmt.Println(string(userJSONBytes3))
  34935. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34936. utils.ErrorLog("解析失败:%v", err)
  34937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34938. return
  34939. }
  34940. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34941. if err == nil {
  34942. c.ServeSuccessJSON(map[string]interface{}{
  34943. "msg": "撤销明细成功",
  34944. })
  34945. return
  34946. } else {
  34947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34948. return
  34949. }
  34950. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34951. var resSix10265 ResultSix10265
  34952. var api3 string
  34953. if miConfig.MdtrtareaAdmvs == "320830" {
  34954. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34955. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34957. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34958. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34959. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34960. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34962. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34963. } else {
  34964. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34965. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34966. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34967. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34968. }
  34969. resp3, requestErr3 := http.Get(api3)
  34970. utils.ErrorLog("接口: %v", requestErr3)
  34971. if requestErr3 != nil {
  34972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34973. return
  34974. }
  34975. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34976. if ioErr3 != nil {
  34977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34979. return
  34980. }
  34981. var respJSON3 map[string]interface{}
  34982. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34985. return
  34986. }
  34987. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34988. userJSONBytes3, _ := json.Marshal(respJSON3)
  34989. fmt.Println("log")
  34990. fmt.Println(string(userJSONBytes3))
  34991. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34992. utils.ErrorLog("解析失败:%v", err)
  34993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34994. return
  34995. }
  34996. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34997. res2.Output = resSix10265.Output
  34998. res2.ErrMsg = resSix10265.ErrMsg
  34999. res2.Cainfo = resSix10265.Cainfo
  35000. res2.WarnMsg = resSix10265.WarnMsg
  35001. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35002. res2.Infcode = infocode
  35003. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35004. if err == nil {
  35005. c.ServeSuccessJSON(map[string]interface{}{
  35006. "msg": "撤销明细成功",
  35007. })
  35008. return
  35009. } else {
  35010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35011. return
  35012. }
  35013. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35014. var api3 string
  35015. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  35016. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35018. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35019. resp3, requestErr3 := http.Get(api3)
  35020. utils.ErrorLog("接口: %v", requestErr3)
  35021. if requestErr3 != nil {
  35022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35023. return
  35024. }
  35025. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35026. if ioErr3 != nil {
  35027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35029. return
  35030. }
  35031. var respJSON3 map[string]interface{}
  35032. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35035. return
  35036. }
  35037. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  35038. if status == "0" {
  35039. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  35040. c.ServeSuccessJSON(map[string]interface{}{
  35041. "failed_code": -10,
  35042. "msg": err_msg,
  35043. })
  35044. return
  35045. }
  35046. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35047. userJSONBytes3, _ := json.Marshal(respJSON3)
  35048. fmt.Println("log")
  35049. fmt.Println(string(userJSONBytes3))
  35050. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35051. utils.ErrorLog("解析失败:%v", err)
  35052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35053. return
  35054. }
  35055. fmt.Println(res2.Infcode)
  35056. if res2.Infcode == -1 {
  35057. c.ServeSuccessJSON(map[string]interface{}{
  35058. "failed_code": -10,
  35059. "msg": res2.ErrMsg,
  35060. })
  35061. return
  35062. }
  35063. if res2.Infcode == 0 {
  35064. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35065. if err == nil {
  35066. c.ServeSuccessJSON(map[string]interface{}{
  35067. "msg": "撤销明细成功",
  35068. })
  35069. return
  35070. } else {
  35071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35072. return
  35073. }
  35074. } else {
  35075. c.ServeSuccessJSON(map[string]interface{}{
  35076. "failed_code": -10,
  35077. "msg": res2.ErrMsg,
  35078. })
  35079. }
  35080. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35081. if err == nil {
  35082. c.ServeSuccessJSON(map[string]interface{}{
  35083. "msg": "撤销明细成功",
  35084. })
  35085. return
  35086. } else {
  35087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35088. return
  35089. }
  35090. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35091. var api3 string
  35092. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  35093. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35094. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35095. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35096. resp3, requestErr3 := http.Get(api3)
  35097. utils.ErrorLog("接口: %v", requestErr3)
  35098. if requestErr3 != nil {
  35099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35100. return
  35101. }
  35102. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35103. if ioErr3 != nil {
  35104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35106. return
  35107. }
  35108. var respJSON3 map[string]interface{}
  35109. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35112. return
  35113. }
  35114. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  35115. if status == "0" {
  35116. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  35117. c.ServeSuccessJSON(map[string]interface{}{
  35118. "failed_code": -10,
  35119. "msg": err_msg,
  35120. })
  35121. return
  35122. }
  35123. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35124. userJSONBytes3, _ := json.Marshal(respJSON3)
  35125. fmt.Println("log")
  35126. fmt.Println(string(userJSONBytes3))
  35127. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35128. utils.ErrorLog("解析失败:%v", err)
  35129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35130. return
  35131. }
  35132. fmt.Println(res2.Infcode)
  35133. if res2.Infcode == -1 {
  35134. c.ServeSuccessJSON(map[string]interface{}{
  35135. "failed_code": -10,
  35136. "msg": res2.ErrMsg,
  35137. })
  35138. return
  35139. }
  35140. if res2.Infcode == 0 {
  35141. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35142. if err == nil {
  35143. c.ServeSuccessJSON(map[string]interface{}{
  35144. "msg": "撤销明细成功",
  35145. })
  35146. return
  35147. } else {
  35148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35149. return
  35150. }
  35151. } else {
  35152. c.ServeSuccessJSON(map[string]interface{}{
  35153. "failed_code": -10,
  35154. "msg": res2.ErrMsg,
  35155. })
  35156. }
  35157. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35158. if err == nil {
  35159. c.ServeSuccessJSON(map[string]interface{}{
  35160. "msg": "撤销明细成功",
  35161. })
  35162. return
  35163. } else {
  35164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35165. return
  35166. }
  35167. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35168. var resSix10265 ResultSix10265
  35169. new_chrg_bchno := order.Number
  35170. if adminUser.CurrentOrgId == 10265 {
  35171. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  35172. new_chrg_bchno = "0000"
  35173. }
  35174. }
  35175. var api3 string
  35176. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  35177. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35179. resp3, requestErr3 := http.Get(api3)
  35180. if requestErr3 != nil {
  35181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35182. return
  35183. }
  35184. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35185. if ioErr3 != nil {
  35186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35188. return
  35189. }
  35190. var respJSON3 map[string]interface{}
  35191. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35194. return
  35195. }
  35196. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35197. userJSONBytes3, _ := json.Marshal(respJSON3)
  35198. fmt.Println("log")
  35199. fmt.Println(string(userJSONBytes3))
  35200. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  35201. utils.ErrorLog("解析失败:%v", err)
  35202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35203. return
  35204. }
  35205. res2.InfRefmsgid = resSix10265.InfRefmsgid
  35206. res2.Output = resSix10265.Output
  35207. res2.ErrMsg = resSix10265.ErrMsg
  35208. res2.Cainfo = resSix10265.Cainfo
  35209. res2.WarnMsg = resSix10265.WarnMsg
  35210. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35211. res2.Infcode = infocode
  35212. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35213. if err == nil {
  35214. c.ServeSuccessJSON(map[string]interface{}{
  35215. "msg": "撤销明细成功",
  35216. })
  35217. return
  35218. } else {
  35219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35220. return
  35221. }
  35222. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35223. 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)
  35224. var dat map[string]interface{}
  35225. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35226. fmt.Println(dat)
  35227. } else {
  35228. fmt.Println(err)
  35229. }
  35230. saveLog(result2, src_request, "2205", "撤销明细")
  35231. userJSONBytes, _ := json.Marshal(dat)
  35232. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35233. utils.ErrorLog("解析失败:%v", err)
  35234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35235. return
  35236. }
  35237. if res2.Infcode == 0 {
  35238. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35239. if err == nil {
  35240. c.ServeSuccessJSON(map[string]interface{}{
  35241. "msg": "撤销明细成功",
  35242. })
  35243. return
  35244. } else {
  35245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35246. return
  35247. }
  35248. } else {
  35249. c.ServeSuccessJSON(map[string]interface{}{
  35250. "failed_code": -10,
  35251. "msg": res2.ErrMsg,
  35252. })
  35253. }
  35254. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35255. 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, "")
  35256. var dat map[string]interface{}
  35257. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35258. fmt.Println(dat)
  35259. } else {
  35260. fmt.Println(err)
  35261. }
  35262. saveLog(result2, src_request, "2205", "撤销明细")
  35263. userJSONBytes, _ := json.Marshal(dat)
  35264. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35265. utils.ErrorLog("解析失败:%v", err)
  35266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35267. return
  35268. }
  35269. if res2.Infcode == 0 {
  35270. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35271. if err == nil {
  35272. c.ServeSuccessJSON(map[string]interface{}{
  35273. "msg": "撤销明细成功",
  35274. })
  35275. return
  35276. } else {
  35277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35278. return
  35279. }
  35280. } else {
  35281. c.ServeSuccessJSON(map[string]interface{}{
  35282. "failed_code": -10,
  35283. "msg": res2.ErrMsg,
  35284. })
  35285. }
  35286. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35287. 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, "")
  35288. var dat map[string]interface{}
  35289. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35290. fmt.Println(dat)
  35291. } else {
  35292. fmt.Println(err)
  35293. }
  35294. saveLog(result2, src_request, "2205", "撤销明细")
  35295. userJSONBytes, _ := json.Marshal(dat)
  35296. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35297. utils.ErrorLog("解析失败:%v", err)
  35298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35299. return
  35300. }
  35301. if res2.Infcode == 0 {
  35302. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35303. if err == nil {
  35304. c.ServeSuccessJSON(map[string]interface{}{
  35305. "msg": "撤销明细成功",
  35306. })
  35307. return
  35308. } else {
  35309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35310. return
  35311. }
  35312. } else {
  35313. c.ServeSuccessJSON(map[string]interface{}{
  35314. "failed_code": -10,
  35315. "msg": res2.ErrMsg,
  35316. })
  35317. }
  35318. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35319. 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, "")
  35320. var dat map[string]interface{}
  35321. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35322. fmt.Println(dat)
  35323. } else {
  35324. fmt.Println(err)
  35325. }
  35326. saveLog(result2, src_request, "2205", "撤销明细")
  35327. userJSONBytes, _ := json.Marshal(dat)
  35328. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35329. utils.ErrorLog("解析失败:%v", err)
  35330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35331. return
  35332. }
  35333. if res2.Infcode == 0 {
  35334. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35335. if err == nil {
  35336. c.ServeSuccessJSON(map[string]interface{}{
  35337. "msg": "撤销明细成功",
  35338. })
  35339. return
  35340. } else {
  35341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35342. return
  35343. }
  35344. } else {
  35345. c.ServeSuccessJSON(map[string]interface{}{
  35346. "failed_code": -10,
  35347. "msg": res2.ErrMsg,
  35348. })
  35349. }
  35350. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35351. 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, "")
  35352. var dat map[string]interface{}
  35353. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35354. fmt.Println(dat)
  35355. } else {
  35356. fmt.Println(err)
  35357. }
  35358. saveLog(result2, src_request, "2205", "撤销明细")
  35359. userJSONBytes, _ := json.Marshal(dat)
  35360. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35361. utils.ErrorLog("解析失败:%v", err)
  35362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35363. return
  35364. }
  35365. if res2.Infcode == 0 {
  35366. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35367. if err == nil {
  35368. c.ServeSuccessJSON(map[string]interface{}{
  35369. "msg": "撤销明细成功",
  35370. })
  35371. return
  35372. } else {
  35373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35374. return
  35375. }
  35376. } else {
  35377. c.ServeSuccessJSON(map[string]interface{}{
  35378. "failed_code": -10,
  35379. "msg": res2.ErrMsg,
  35380. })
  35381. }
  35382. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35383. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35384. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35385. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35386. resp2, requestErr2 := http.Get(api2)
  35387. if requestErr2 != nil {
  35388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35389. return
  35390. }
  35391. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35392. if ioErr2 != nil {
  35393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35395. return
  35396. }
  35397. var respJSON2 map[string]interface{}
  35398. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35401. return
  35402. }
  35403. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35404. userJSONBytes3, _ := json.Marshal(respJSON2)
  35405. fmt.Println("log")
  35406. fmt.Println(string(userJSONBytes3))
  35407. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35408. utils.ErrorLog("解析失败:%v", err)
  35409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35410. return
  35411. }
  35412. if res2.Infcode == 0 {
  35413. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35414. if err == nil {
  35415. c.ServeSuccessJSON(map[string]interface{}{
  35416. "msg": "撤销明细成功",
  35417. })
  35418. return
  35419. } else {
  35420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35421. return
  35422. }
  35423. } else {
  35424. c.ServeSuccessJSON(map[string]interface{}{
  35425. "failed_code": -10,
  35426. "msg": res2.ErrMsg,
  35427. })
  35428. }
  35429. } else {
  35430. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35431. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35433. resp2, requestErr2 := http.Get(api2)
  35434. if requestErr2 != nil {
  35435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35436. return
  35437. }
  35438. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35439. if ioErr2 != nil {
  35440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35442. return
  35443. }
  35444. var respJSON2 map[string]interface{}
  35445. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35448. return
  35449. }
  35450. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35451. userJSONBytes3, _ := json.Marshal(respJSON2)
  35452. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35453. utils.ErrorLog("解析失败:%v", err)
  35454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35455. return
  35456. }
  35457. if res2.Infcode == -1 {
  35458. c.ServeSuccessJSON(map[string]interface{}{
  35459. "failed_code": -10,
  35460. "msg": res2.ErrMsg,
  35461. })
  35462. return
  35463. } else {
  35464. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35465. if err == nil {
  35466. c.ServeSuccessJSON(map[string]interface{}{
  35467. "msg": "撤销明细成功",
  35468. })
  35469. return
  35470. } else {
  35471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35472. return
  35473. }
  35474. }
  35475. }
  35476. } else {
  35477. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35478. if err == nil {
  35479. c.ServeSuccessJSON(map[string]interface{}{
  35480. "msg": "退费成功",
  35481. })
  35482. } else {
  35483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35484. return
  35485. }
  35486. }
  35487. }
  35488. // 对账
  35489. func (c *HisApiController) GetCheckAccount() {
  35490. start_time := c.GetString("start_time")
  35491. end_time := c.GetString("end_time")
  35492. insutype := c.GetString("insutype")
  35493. clr_type := c.GetString("clr_type")
  35494. clr_org := c.GetString("clr_optins")
  35495. admin_user_id, _ := c.GetInt64("admin_user_id")
  35496. adminUser := c.GetAdminUserInfo()
  35497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35498. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35499. if len(clr_org) == 0 {
  35500. clr_org = miConfig.InsuplcAdmdvs
  35501. }
  35502. timeLayout := "2006-01-02"
  35503. loc, _ := time.LoadLocation("Local")
  35504. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35505. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35506. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35507. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35508. fixmedins_setl_cnt := int64(len(orders))
  35509. var medfee_sumamt float64
  35510. var acct_pay float64
  35511. var fund_pay_sumamt float64
  35512. for _, item := range orders {
  35513. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35514. acct_pay = acct_pay + item.AcctPay
  35515. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35516. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35517. } else {
  35518. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35519. }
  35520. }
  35521. var user_name string
  35522. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35523. if role.ID == 0 {
  35524. user_name = "xxx"
  35525. } else {
  35526. user_name = role.UserName
  35527. }
  35528. var res ResultEight
  35529. var res10188 ResultEightFor10188
  35530. if config.IsOpen == 1 {
  35531. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35532. api := miConfig.AppSecret + "jsyb/3201?" +
  35533. "insutype=" + insutype +
  35534. "&clr_type=" + clr_type +
  35535. "&setl_optins=" + clr_org +
  35536. "&stmt_begndate=" + start_time +
  35537. "&stm_enddate=" + end_time +
  35538. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35539. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35540. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35541. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35542. "&fixmedins_code=" + miConfig.Code +
  35543. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35544. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35545. "&secret_key=" + miConfig.SecretKey +
  35546. "&org_name=" + miConfig.OrgName +
  35547. "&doctor=" + user_name +
  35548. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35549. fmt.Println(api)
  35550. resp, requestErr := http.Get(api)
  35551. if requestErr != nil {
  35552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35553. return
  35554. }
  35555. body, ioErr := ioutil.ReadAll(resp.Body)
  35556. fmt.Println(body)
  35557. if ioErr != nil {
  35558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35560. return
  35561. }
  35562. var respJSON map[string]interface{}
  35563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35566. return
  35567. }
  35568. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35569. userJSONBytes, _ := json.Marshal(respJSON)
  35570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35571. utils.ErrorLog("解析失败:%v", err)
  35572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35573. return
  35574. }
  35575. res.InfRefmsgid = res10188.InfRefmsgid
  35576. res.Output = res10188.Output
  35577. res.ErrMsg = res10188.ErrMsg
  35578. res.Cainfo = res10188.Cainfo
  35579. res.WarnMsg = res10188.WarnMsg
  35580. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35581. res.Infcode = infocode
  35582. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35583. if clr_type != "9903" {
  35584. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35585. }
  35586. if clr_type == "9903" {
  35587. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35588. }
  35589. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35590. "insutype=" + insutype +
  35591. "&clr_type=" + clr_type +
  35592. "&setl_optins=" + clr_org +
  35593. "&stmt_begndate=" + start_time +
  35594. "&stm_enddate=" + end_time +
  35595. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35596. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35597. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35598. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35599. "&fixmedins_code=" + miConfig.Code +
  35600. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35601. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35602. "&secret_key=" + miConfig.SecretKey +
  35603. "&org_name=" + miConfig.OrgName +
  35604. "&doctor=" + user_name
  35605. resp, requestErr := http.Get(api)
  35606. if requestErr != nil {
  35607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35608. return
  35609. }
  35610. body, ioErr := ioutil.ReadAll(resp.Body)
  35611. if ioErr != nil {
  35612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35614. return
  35615. }
  35616. var respJSON map[string]interface{}
  35617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35620. return
  35621. }
  35622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35623. result, _ := json.Marshal(respJSON)
  35624. fmt.Println("log")
  35625. fmt.Println(string(result))
  35626. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35627. utils.ErrorLog("解析失败:%v", err)
  35628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35629. return
  35630. }
  35631. res.InfRefmsgid = res10188.InfRefmsgid
  35632. res.Output = res10188.Output
  35633. res.ErrMsg = res10188.ErrMsg
  35634. res.Cainfo = res10188.Cainfo
  35635. res.WarnMsg = res10188.WarnMsg
  35636. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35637. res.Infcode = infocode
  35638. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35639. var baseParams models.BaseParams
  35640. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35641. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35642. baseParams.SecretKey = miConfig.SecretKey
  35643. baseParams.OrgName = miConfig.OrgName
  35644. baseParams.FixmedinsCode = miConfig.Code
  35645. baseParams.EncKey = miConfig.EncKey
  35646. baseParams.AppSecret = miConfig.AppSecret
  35647. baseParams.SignKey = miConfig.SignKey
  35648. baseParams.AppID = miConfig.Code
  35649. baseParams.Doctor = role.UserName
  35650. baseParams.RequestUrl = miConfig.Url
  35651. businessParams := models.BusinessParams{
  35652. Insutype: insutype,
  35653. ClrType: clr_type,
  35654. SetlOptins: clr_org,
  35655. StmtBegndate: start_time,
  35656. StmtEnddate: end_time,
  35657. MedfeeSumamt: medfee_sumamt,
  35658. FundPaySumamt: fund_pay_sumamt,
  35659. AcctPay: acct_pay,
  35660. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35661. }
  35662. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35663. fmt.Println(requestLog)
  35664. fmt.Println(result)
  35665. fmt.Println(err_msg)
  35666. var dat map[string]interface{}
  35667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35668. fmt.Println(dat)
  35669. } else {
  35670. fmt.Println(err)
  35671. }
  35672. userJSONBytes, _ := json.Marshal(dat)
  35673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35674. utils.ErrorLog("解析失败:%v", err)
  35675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35676. return
  35677. }
  35678. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35679. var baseParams models.BaseParams
  35680. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35681. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35682. baseParams.SecretKey = miConfig.SecretKey
  35683. baseParams.OrgName = miConfig.OrgName
  35684. baseParams.FixmedinsCode = miConfig.Code
  35685. baseParams.EncKey = miConfig.EncKey
  35686. baseParams.AppSecret = miConfig.AppSecret
  35687. baseParams.SignKey = miConfig.SignKey
  35688. baseParams.AppID = miConfig.Code
  35689. baseParams.Doctor = role.UserName
  35690. baseParams.RequestUrl = miConfig.Url
  35691. baseParams.AccessKey = miConfig.AccessKey
  35692. businessParams := models.BusinessParams{
  35693. Insutype: insutype,
  35694. ClrType: clr_type,
  35695. SetlOptins: "430822",
  35696. StmtBegndate: start_time,
  35697. StmtEnddate: end_time,
  35698. MedfeeSumamt: medfee_sumamt,
  35699. FundPaySumamt: fund_pay_sumamt,
  35700. AcctPay: acct_pay,
  35701. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35702. }
  35703. 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)
  35704. fmt.Println(requestLog)
  35705. fmt.Println(result)
  35706. var dat map[string]interface{}
  35707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35708. fmt.Println(dat)
  35709. } else {
  35710. fmt.Println(err)
  35711. }
  35712. userJSONBytes, _ := json.Marshal(dat)
  35713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35714. utils.ErrorLog("解析失败:%v", err)
  35715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35716. return
  35717. }
  35718. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35719. var baseParams models.BaseParams
  35720. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35721. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35722. baseParams.SecretKey = miConfig.SecretKey
  35723. baseParams.OrgName = miConfig.OrgName
  35724. baseParams.FixmedinsCode = miConfig.Code
  35725. baseParams.EncKey = miConfig.EncKey
  35726. baseParams.AppSecret = miConfig.AppSecret
  35727. baseParams.SignKey = miConfig.SignKey
  35728. baseParams.AppID = miConfig.Code
  35729. baseParams.Doctor = role.UserName
  35730. baseParams.RequestUrl = miConfig.Url
  35731. businessParams := models.BusinessParams{
  35732. Insutype: insutype,
  35733. ClrType: clr_type,
  35734. SetlOptins: clr_org,
  35735. StmtBegndate: start_time,
  35736. StmtEnddate: end_time,
  35737. MedfeeSumamt: medfee_sumamt,
  35738. FundPaySumamt: fund_pay_sumamt,
  35739. AcctPay: acct_pay,
  35740. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35741. }
  35742. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35743. fmt.Println(requestLog)
  35744. fmt.Println(result)
  35745. fmt.Println(err_msg)
  35746. var dat map[string]interface{}
  35747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35748. fmt.Println(dat)
  35749. } else {
  35750. fmt.Println(err)
  35751. }
  35752. userJSONBytes, _ := json.Marshal(dat)
  35753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35754. utils.ErrorLog("解析失败:%v", err)
  35755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35756. return
  35757. }
  35758. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35759. if len(clr_type) == 0 {
  35760. clr_type = "11"
  35761. }
  35762. api := miConfig.Url + "gdyb/ten?" +
  35763. "insutype=" + insutype +
  35764. "&clr_type=" + clr_type +
  35765. "&setl_optins=" + clr_org +
  35766. "&stmt_begndate=" + start_time +
  35767. "&stm_enddate=" + end_time +
  35768. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35769. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35770. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35771. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35772. "&fixmedins_code=" + miConfig.Code +
  35773. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35774. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35775. "&secret_key=" + miConfig.SecretKey +
  35776. "&org_name=" + miConfig.OrgName +
  35777. "&doctor=" + user_name
  35778. fmt.Println(api)
  35779. resp, requestErr := http.Get(api)
  35780. if requestErr != nil {
  35781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35782. return
  35783. }
  35784. body, ioErr := ioutil.ReadAll(resp.Body)
  35785. fmt.Println(body)
  35786. if ioErr != nil {
  35787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35789. return
  35790. }
  35791. var respJSON map[string]interface{}
  35792. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35795. return
  35796. }
  35797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35798. userJSONBytes, _ := json.Marshal(respJSON)
  35799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35800. utils.ErrorLog("解析失败:%v", err)
  35801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35802. return
  35803. }
  35804. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35805. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35806. //fixmedins_setl_cnt := int64(len(orders_two))
  35807. //var medfee_sumamt float64
  35808. //var acct_pay float64
  35809. //var fund_pay_sumamt float64
  35810. //for _, item := range orders_two {
  35811. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35812. // acct_pay = acct_pay + item.AcctPay
  35813. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35814. //}
  35815. var baseParams models.BaseParams
  35816. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35817. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35818. baseParams.SecretKey = miConfig.SecretKey
  35819. baseParams.OrgName = miConfig.OrgName
  35820. baseParams.FixmedinsCode = miConfig.Code
  35821. baseParams.EncKey = miConfig.EncKey
  35822. baseParams.AppSecret = miConfig.AppSecret
  35823. baseParams.SignKey = miConfig.SignKey
  35824. baseParams.AppID = miConfig.Code
  35825. baseParams.Doctor = role.UserName
  35826. baseParams.RequestUrl = miConfig.Url
  35827. businessParams := models.BusinessParams{
  35828. Insutype: insutype,
  35829. ClrType: clr_type,
  35830. SetlOptins: "360102",
  35831. StmtBegndate: start_time,
  35832. StmtEnddate: end_time,
  35833. MedfeeSumamt: 0,
  35834. FundPaySumamt: 0,
  35835. AcctPay: 0,
  35836. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35837. }
  35838. 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))
  35839. fmt.Println(requestLog)
  35840. fmt.Println(result)
  35841. var dat map[string]interface{}
  35842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35843. fmt.Println(dat)
  35844. } else {
  35845. fmt.Println(err)
  35846. }
  35847. userJSONBytes, _ := json.Marshal(dat)
  35848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35849. utils.ErrorLog("解析失败:%v", err)
  35850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35851. return
  35852. }
  35853. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35854. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35855. //fixmedins_setl_cnt := int64(len(orders_two))
  35856. //var medfee_sumamt float64
  35857. //var acct_pay float64
  35858. //var fund_pay_sumamt float64
  35859. //for _, item := range orders_two {
  35860. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35861. // acct_pay = acct_pay + item.AcctPay
  35862. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35863. //}
  35864. var baseParams models.BaseParams
  35865. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35866. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35867. baseParams.SecretKey = miConfig.SecretKey
  35868. baseParams.OrgName = miConfig.OrgName
  35869. baseParams.FixmedinsCode = miConfig.Code
  35870. baseParams.EncKey = miConfig.EncKey
  35871. baseParams.AppSecret = miConfig.AppSecret
  35872. baseParams.SignKey = miConfig.SignKey
  35873. baseParams.AppID = miConfig.Code
  35874. baseParams.Doctor = role.UserName
  35875. baseParams.RequestUrl = miConfig.Url
  35876. if clr_type == "9903" {
  35877. clr_type = "9994"
  35878. }
  35879. businessParams := models.BusinessParams{
  35880. Insutype: insutype,
  35881. ClrType: clr_type,
  35882. SetlOptins: "361025",
  35883. StmtBegndate: start_time,
  35884. StmtEnddate: end_time,
  35885. MedfeeSumamt: 0,
  35886. FundPaySumamt: 0,
  35887. AcctPay: 0,
  35888. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35889. }
  35890. 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))
  35891. fmt.Println(requestLog)
  35892. fmt.Println(result)
  35893. var dat map[string]interface{}
  35894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35895. fmt.Println(dat)
  35896. } else {
  35897. fmt.Println(err)
  35898. }
  35899. userJSONBytes, _ := json.Marshal(dat)
  35900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35901. utils.ErrorLog("解析失败:%v", err)
  35902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35903. return
  35904. }
  35905. } else if miConfig.MdtrtareaAdmvs == "360106" {
  35906. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35907. //fixmedins_setl_cnt := int64(len(orders_two))
  35908. //var medfee_sumamt float64
  35909. //var acct_pay float64
  35910. //var fund_pay_sumamt float64
  35911. //for _, item := range orders_two {
  35912. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35913. // acct_pay = acct_pay + item.AcctPay
  35914. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35915. //}
  35916. var baseParams models.BaseParams
  35917. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35918. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35919. baseParams.SecretKey = miConfig.SecretKey
  35920. baseParams.OrgName = miConfig.OrgName
  35921. baseParams.FixmedinsCode = miConfig.Code
  35922. baseParams.EncKey = miConfig.EncKey
  35923. baseParams.AppSecret = miConfig.AppSecret
  35924. baseParams.SignKey = miConfig.SignKey
  35925. baseParams.AppID = miConfig.Code
  35926. baseParams.Doctor = role.UserName
  35927. baseParams.RequestUrl = miConfig.Url
  35928. if clr_type == "9903" {
  35929. clr_type = "9994"
  35930. }
  35931. businessParams := models.BusinessParams{
  35932. Insutype: insutype,
  35933. ClrType: clr_type,
  35934. SetlOptins: "360102",
  35935. StmtBegndate: start_time,
  35936. StmtEnddate: end_time,
  35937. MedfeeSumamt: 0,
  35938. FundPaySumamt: 0,
  35939. AcctPay: 0,
  35940. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35941. }
  35942. 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))
  35943. fmt.Println(requestLog)
  35944. fmt.Println(result)
  35945. var dat map[string]interface{}
  35946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35947. fmt.Println(dat)
  35948. } else {
  35949. fmt.Println(err)
  35950. }
  35951. userJSONBytes, _ := json.Marshal(dat)
  35952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35953. utils.ErrorLog("解析失败:%v", err)
  35954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35955. return
  35956. }
  35957. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35958. var api string
  35959. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35960. "&clr_type=" + clr_type +
  35961. "&setl_optins=" + clr_org +
  35962. "&stmt_begndate=" + start_time +
  35963. "&stm_enddate=" + end_time +
  35964. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35965. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35966. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35967. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35968. "&fixmedins_code=" + miConfig.Code +
  35969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35970. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35971. "&secret_key=" + miConfig.SecretKey +
  35972. "&org_name=" + miConfig.OrgName +
  35973. "&doctor=" + user_name + "&url=" + miConfig.Url
  35974. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35975. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35976. resp, requestErr := http.Get(api)
  35977. if requestErr != nil {
  35978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35979. return
  35980. }
  35981. body, ioErr := ioutil.ReadAll(resp.Body)
  35982. if ioErr != nil {
  35983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35985. return
  35986. }
  35987. var respJSON map[string]interface{}
  35988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35991. return
  35992. }
  35993. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35994. if status == "0" {
  35995. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35996. c.ServeSuccessJSON(map[string]interface{}{
  35997. "failed_code": -10,
  35998. "msg": err_msg,
  35999. })
  36000. return
  36001. }
  36002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36003. userJSONBytes, _ := json.Marshal(respJSON)
  36004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36005. utils.ErrorLog("解析失败:%v", err)
  36006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36007. return
  36008. }
  36009. } else if miConfig.MdtrtareaAdmvs == "340699" {
  36010. var api string
  36011. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  36012. "&clr_type=" + clr_type +
  36013. "&setl_optins=" + clr_org +
  36014. "&stmt_begndate=" + start_time +
  36015. "&stm_enddate=" + end_time +
  36016. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36017. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36018. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  36019. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  36020. "&fixmedins_code=" + miConfig.Code +
  36021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36022. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36023. "&secret_key=" + miConfig.SecretKey +
  36024. "&org_name=" + miConfig.OrgName +
  36025. "&doctor=" + user_name + "&url=" + miConfig.Url
  36026. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36027. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36028. resp, requestErr := http.Get(api)
  36029. if requestErr != nil {
  36030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36031. return
  36032. }
  36033. body, ioErr := ioutil.ReadAll(resp.Body)
  36034. if ioErr != nil {
  36035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36037. return
  36038. }
  36039. var respJSON map[string]interface{}
  36040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36043. return
  36044. }
  36045. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36046. if status == "0" {
  36047. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36048. c.ServeSuccessJSON(map[string]interface{}{
  36049. "failed_code": -10,
  36050. "msg": err_msg,
  36051. })
  36052. return
  36053. }
  36054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36055. userJSONBytes, _ := json.Marshal(respJSON)
  36056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36057. utils.ErrorLog("解析失败:%v", err)
  36058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36059. return
  36060. }
  36061. } else {
  36062. if len(clr_type) == 0 {
  36063. clr_type = "11"
  36064. }
  36065. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36066. "insutype=" + insutype +
  36067. "&clr_type=" + clr_type +
  36068. "&setl_optins=" + clr_org +
  36069. "&stmt_begndate=" + start_time +
  36070. "&stm_enddate=" + end_time +
  36071. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36072. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36073. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  36074. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36075. "&fixmedins_code=" + miConfig.Code +
  36076. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36077. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36078. "&secret_key=" + miConfig.SecretKey +
  36079. "&org_name=" + miConfig.OrgName +
  36080. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  36081. fmt.Println(api)
  36082. resp, requestErr := http.Get(api)
  36083. if requestErr != nil {
  36084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36085. return
  36086. }
  36087. body, ioErr := ioutil.ReadAll(resp.Body)
  36088. fmt.Println(body)
  36089. if ioErr != nil {
  36090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36092. return
  36093. }
  36094. var respJSON map[string]interface{}
  36095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36098. return
  36099. }
  36100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36101. userJSONBytes, _ := json.Marshal(respJSON)
  36102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36103. utils.ErrorLog("解析失败:%v", err)
  36104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36105. return
  36106. }
  36107. }
  36108. if res.Infcode == 0 {
  36109. if res.Output.Stmtinfo.StmtRslt == "0" {
  36110. micc := &models.MedicalInsuranceCostCompare{
  36111. StartTime: startime.Unix(),
  36112. EndTime: endtime.Unix(),
  36113. Insutype: insutype,
  36114. CheckType: 1,
  36115. Num: fixmedins_setl_cnt,
  36116. Mtime: time.Now().Unix(),
  36117. Status: 1,
  36118. UserOrgId: adminUser.CurrentOrgId,
  36119. CostTotal: medfee_sumamt,
  36120. FuncTotal: fund_pay_sumamt,
  36121. PsnPay: acct_pay,
  36122. Creator: admin_user_id,
  36123. Ctime: time.Now().Unix(),
  36124. ClrType: clr_type,
  36125. }
  36126. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  36127. if err == nil {
  36128. c.ServeSuccessJSON(map[string]interface{}{
  36129. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36130. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36131. })
  36132. } else {
  36133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36134. }
  36135. } else {
  36136. c.ServeSuccessJSON(map[string]interface{}{
  36137. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36138. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36139. })
  36140. }
  36141. } else {
  36142. c.ServeSuccessJSON(map[string]interface{}{
  36143. "failed_code": -10,
  36144. "msg": res.ErrMsg,
  36145. })
  36146. }
  36147. }
  36148. }
  36149. func (c *HisApiController) Check310() {
  36150. adminUser := c.GetAdminUserInfo()
  36151. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36152. var user_name string
  36153. user_name = "高慧裕"
  36154. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36155. "insutype=" + "310" +
  36156. "&clr_type=" + "" +
  36157. "&setl_optins=" + "441202" +
  36158. "&stmt_begndate=" + "2022-03-01" +
  36159. "&stm_enddate=" + "2022-03-31" +
  36160. "&medfee_sumamt=" + "194930.12" +
  36161. "&fund_pay_sumamt=" + "188741.46" +
  36162. "&acct_pay=" + "0" +
  36163. "&fixmedins_setl_cnt=" + "452" +
  36164. "&fixmedins_code=" + miConfig.Code +
  36165. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36166. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36167. "&secret_key=" + miConfig.SecretKey +
  36168. "&org_name=" + miConfig.OrgName +
  36169. "&doctor=" + user_name
  36170. fmt.Println(api)
  36171. resp, requestErr := http.Get(api)
  36172. if requestErr != nil {
  36173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36174. return
  36175. }
  36176. body, ioErr := ioutil.ReadAll(resp.Body)
  36177. fmt.Println(body)
  36178. if ioErr != nil {
  36179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36181. return
  36182. }
  36183. var respJSON map[string]interface{}
  36184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36187. return
  36188. }
  36189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36190. userJSONBytes, _ := json.Marshal(respJSON)
  36191. var res ResultEight
  36192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36193. utils.ErrorLog("解析失败:%v", err)
  36194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36195. return
  36196. }
  36197. }
  36198. func (c *HisApiController) Check390() {
  36199. adminUser := c.GetAdminUserInfo()
  36200. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36201. var user_name string
  36202. user_name = "高慧裕"
  36203. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36204. "insutype=" + "390" +
  36205. "&clr_type=" + "" +
  36206. "&setl_optins=" + "441202" +
  36207. "&stmt_begndate=" + "2022-03-01" +
  36208. "&stm_enddate=" + "2022-03-31" +
  36209. "&medfee_sumamt=" + "1068448.89" +
  36210. "&fund_pay_sumamt=" + "1014677.62" +
  36211. "&acct_pay=" + "0" +
  36212. "&fixmedins_setl_cnt=" + "1950" +
  36213. "&fixmedins_code=" + miConfig.Code +
  36214. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36215. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36216. "&secret_key=" + miConfig.SecretKey +
  36217. "&org_name=" + miConfig.OrgName +
  36218. "&doctor=" + user_name
  36219. fmt.Println(api)
  36220. resp, requestErr := http.Get(api)
  36221. if requestErr != nil {
  36222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36223. return
  36224. }
  36225. body, ioErr := ioutil.ReadAll(resp.Body)
  36226. fmt.Println(body)
  36227. if ioErr != nil {
  36228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36230. return
  36231. }
  36232. var respJSON map[string]interface{}
  36233. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36236. return
  36237. }
  36238. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36239. userJSONBytes, _ := json.Marshal(respJSON)
  36240. var res ResultEight
  36241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36242. utils.ErrorLog("解析失败:%v", err)
  36243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36244. return
  36245. }
  36246. }
  36247. // 对账明细
  36248. func (c *HisApiController) GetCheckDetailAccount() {
  36249. start_time := c.GetString("start_time")
  36250. end_time := c.GetString("end_time")
  36251. admin_user_id, _ := c.GetInt64("admin_user_id")
  36252. adminUser := c.GetAdminUserInfo()
  36253. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36254. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36255. timeLayout := "2006-01-02"
  36256. loc, _ := time.LoadLocation("Local")
  36257. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36258. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36259. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36260. rand.Seed(time.Now().UnixNano())
  36261. num := rand.Intn(30000)
  36262. Mkdir(miConfig.OrgName)
  36263. file := strconv.FormatInt(int64(num), 10)
  36264. file_name := file + ".txt"
  36265. zip_name := file + ".zip"
  36266. zip_path := miConfig.OrgName + "/" + zip_name
  36267. file_path := miConfig.OrgName + "/" + file_name
  36268. decimal.DivisionPrecision = 2
  36269. var medfee_sumamt float64
  36270. var psn_cash_pay float64
  36271. var fund_pay_sumamt float64
  36272. fixmedins_setl_cnt := int64(len(orders))
  36273. for _, item := range orders {
  36274. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36275. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  36276. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36277. }
  36278. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  36279. defer f.Close()
  36280. if err != nil {
  36281. fmt.Println(err.Error())
  36282. } else {
  36283. for _, item := range orders {
  36284. var refd_setl_flag string
  36285. if item.OrderStatus == 2 {
  36286. refd_setl_flag = "0"
  36287. var str string
  36288. str = item.SetlId + " " +
  36289. item.MdtrtId + " " +
  36290. item.PsnNo + " " +
  36291. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36292. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36293. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  36294. _, err = f.Write([]byte(str))
  36295. }
  36296. if item.OrderStatus == 3 {
  36297. var str string
  36298. str = item.SetlId + " " +
  36299. item.MdtrtId + " " +
  36300. item.PsnNo + " " +
  36301. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36302. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36303. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  36304. _, err = f.Write([]byte(str))
  36305. var str2 string
  36306. str2 = item.SetlId + " " +
  36307. item.MdtrtId + " " +
  36308. item.PsnNo + " " +
  36309. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  36310. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  36311. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  36312. _, err = f.Write([]byte(str2))
  36313. }
  36314. }
  36315. }
  36316. Zip(file_path, zip_path)
  36317. fmt.Println(ReadFile(zip_path))
  36318. fmt.Println(string(ReadFile(zip_path)))
  36319. if config.IsOpen == 1 {
  36320. var user_name string
  36321. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36322. if role.ID == 0 {
  36323. user_name = "管理员"
  36324. } else {
  36325. user_name = role.UserName
  36326. }
  36327. baseParams := models.BaseParams{
  36328. SecretKey: miConfig.SecretKey,
  36329. FixmedinsCode: miConfig.Code,
  36330. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36331. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36332. OrgName: miConfig.OrgName,
  36333. Doctor: user_name,
  36334. }
  36335. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36336. var dat map[string]interface{}
  36337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36338. fmt.Println(dat)
  36339. } else {
  36340. fmt.Println(err)
  36341. }
  36342. userJSONBytes, _ := json.Marshal(dat)
  36343. var res ResultNine
  36344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36345. utils.ErrorLog("解析失败:%v", err)
  36346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36347. return
  36348. }
  36349. if res.Infcode == 0 {
  36350. fileNo := res.Output.FileQuryNo
  36351. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36352. "file_qury_no=" + fileNo +
  36353. "&setl_optins=" + "定点医保中心" +
  36354. "&stmt_begndate=" + start_time +
  36355. "&stm_enddate=" + end_time +
  36356. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36357. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36358. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36359. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36360. "&fixmedins_code=" + miConfig.Code +
  36361. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36362. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36363. "&secret_key=" + miConfig.SecretKey +
  36364. "&org_name=" + miConfig.OrgName +
  36365. "&doctor=" + user_name
  36366. resp, requestErr := http.Get(api)
  36367. if requestErr != nil {
  36368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36369. return
  36370. }
  36371. body, ioErr := ioutil.ReadAll(resp.Body)
  36372. if ioErr != nil {
  36373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36375. return
  36376. }
  36377. var respJSON map[string]interface{}
  36378. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36381. return
  36382. }
  36383. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36384. userJSONBytes, _ := json.Marshal(respJSON)
  36385. var res ResultTen
  36386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36387. utils.ErrorLog("解析失败:%v", err)
  36388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36389. return
  36390. }
  36391. if res.Infcode == 0 {
  36392. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36393. micc := &models.MedicalInsuranceCostCompare{
  36394. StartTime: startime.Unix(),
  36395. EndTime: endtime.Unix(),
  36396. Insutype: "0",
  36397. CheckType: 2,
  36398. Num: fixmedins_setl_cnt,
  36399. Mtime: time.Now().Unix(),
  36400. Status: 1,
  36401. UserOrgId: adminUser.CurrentOrgId,
  36402. CostTotal: medfee_sumamt,
  36403. FuncTotal: fund_pay_sumamt,
  36404. PsnPay: psn_cash_pay,
  36405. Creator: admin_user_id,
  36406. Ctime: time.Now().Unix(),
  36407. }
  36408. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36409. c.ServeSuccessJSON(map[string]interface{}{
  36410. "msg": "明细对账成功",
  36411. })
  36412. }
  36413. } else {
  36414. }
  36415. }
  36416. }
  36417. type CustomOrderInfo struct {
  36418. Name string
  36419. Spec string
  36420. Unit string
  36421. Count float64
  36422. Price float64
  36423. Total float64
  36424. }
  36425. func (c *HisApiController) GetBatchSettleAccounts() {
  36426. admin_user_id, _ := c.GetInt64("admin_user_id")
  36427. order_ids := c.GetString("order_ids")
  36428. order_ids_arr := strings.Split(order_ids, ",")
  36429. data3 := []map[string]interface{}{}
  36430. for _, item := range order_ids_arr {
  36431. id, _ := strconv.ParseInt(item, 10, 64)
  36432. order_id := id
  36433. adminUser := c.GetAdminUserInfo()
  36434. order, _ := service.GetHisOrderByID(order_id)
  36435. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36436. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36437. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36438. orderInfos = append(orderInfos, orderInfos_two...)
  36439. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36440. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36441. var diagnosis_ids []string
  36442. if his.ID > 0 {
  36443. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36444. } else {
  36445. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36446. }
  36447. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36448. var dia_config []*models.HisXtDiagnoseConfig
  36449. var name string
  36450. for _, item := range diagnosis_ids {
  36451. id, _ := strconv.ParseInt(item, 10, 64)
  36452. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36453. dia_config = append(dia_config, &diagnosisConfig)
  36454. if len(name) == 0 {
  36455. name = diagnosisConfig.ClassName
  36456. }
  36457. //} else {
  36458. // name = name + "," + diagnosisConfig.ClassName
  36459. //}
  36460. }
  36461. var bedCostTotal float64 = 0 //床位总费
  36462. var bedCostSelfTotal float64 = 0 //床位自费
  36463. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36464. var bedSelfTotal float64 = 0 //床位部分项目自费
  36465. var bedInscpTotal float64 = 0 //床位部分项目自费
  36466. var operationCostTotal float64 = 0 //手术费
  36467. var operationCostSelfTotal float64 = 0 //手术费
  36468. var operationCostPartSelfTotal float64 = 0 //手术费
  36469. var operationSelfTotal float64 = 0 //床位部分项目自费
  36470. var operationInscpTotal float64 = 0 //床位部分项目自费
  36471. var otherCostTotal float64 = 0 //其他费用
  36472. var otherCostSelfTotal float64 = 0 //其他费用
  36473. var otherCostPartSelfTotal float64 = 0 //其他费用
  36474. var otherSelfTotal float64 = 0 //床位部分项目自费
  36475. var otherInscpTotal float64 = 0 //床位部分项目自费
  36476. var materialCostTotal float64 = 0 //材料费
  36477. var materialCostSelfTotal float64 = 0 //材料费
  36478. var materialCostPartSelfTotal float64 = 0 //材料费
  36479. var materialSelfTotal float64 = 0 //床位部分项目自费
  36480. var materialInscpTotal float64 = 0 //床位部分项目自费
  36481. var westernMedicineCostTotal float64 = 0 //西药费
  36482. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36483. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36484. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36485. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36486. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36487. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36488. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36489. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36490. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36491. var checkCostTotal float64 = 0 //检查费
  36492. var checkCostSelfTotal float64 = 0 //检查费
  36493. var checkCostPartSelfTotal float64 = 0 //检查费
  36494. var checkSelfTotal float64 = 0 //床位部分项目自费
  36495. var checkInscpTotal float64 = 0 //床位部分项目自费
  36496. var laboratoryCostTotal float64 = 0 //化验费
  36497. var laboratoryCostSelfTotal float64 = 0 //化验费
  36498. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36499. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36500. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36501. var treatCostTotal float64 = 0 //治疗费用
  36502. var treatCostSelfTotal float64 = 0 //治疗费用
  36503. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36504. var treatSelfTotal float64 = 0 //床位部分项目自费
  36505. var treatInscpTotal float64 = 0 //床位部分项目自费
  36506. decimal.DivisionPrecision = 2
  36507. for _, item := range orderInfos {
  36508. if item.MedChrgitmType == "01" { //床位费
  36509. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36510. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36511. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36512. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36513. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36514. }
  36515. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36516. if item.MedChrgitmType == "03" { //检查费
  36517. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36518. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36519. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36520. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36521. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36522. }
  36523. } else {
  36524. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36525. fmt.Println("------------")
  36526. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36527. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36528. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36529. }
  36530. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36531. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36532. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36533. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36534. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36535. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36536. }
  36537. }
  36538. if item.MedChrgitmType == "04" { //化验费
  36539. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36540. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36541. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36542. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36543. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36544. }
  36545. if item.MedChrgitmType == "05" { //治疗费
  36546. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36547. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36548. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36549. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36550. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36551. }
  36552. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36553. fmt.Println("------------")
  36554. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36555. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36556. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36557. }
  36558. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36559. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36560. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36561. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36562. }
  36563. //if item.MedChrgitmType == "06" { //手术费
  36564. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36565. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36566. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36567. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36568. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36569. //
  36570. //}
  36571. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36572. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36573. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36574. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36575. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36576. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36577. }
  36578. if item.MedChrgitmType == "09" { //西药费
  36579. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36580. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36581. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36582. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36583. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36584. }
  36585. if item.MedChrgitmType == "11" { //中成费
  36586. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36587. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36588. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36589. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36590. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36591. }
  36592. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36593. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36594. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36595. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36596. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36597. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36598. }
  36599. }
  36600. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36601. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36602. var user_name string
  36603. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36604. if role.ID == 0 {
  36605. user_name = "管理员"
  36606. } else {
  36607. user_name = role.UserName
  36608. }
  36609. baseParams := models.BaseParams{
  36610. SecretKey: miConfig.SecretKey,
  36611. FixmedinsCode: miConfig.Code,
  36612. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36613. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36614. OrgName: miConfig.OrgName,
  36615. Doctor: user_name,
  36616. RequestUrl: miConfig.Url,
  36617. AccessKey: miConfig.AccessKey,
  36618. }
  36619. businessParams := models.BusinessParams{
  36620. PsnNo: order.PsnNo,
  36621. MdtrtId: order.MdtrtId,
  36622. SetlId: order.SetlId,
  36623. }
  36624. var res ResultEleven
  36625. var resEleven10265 ResultEleven10265
  36626. if config.IsOpen == 1 {
  36627. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36628. result := service.Gdyb5203(baseParams, businessParams)
  36629. service.Gdyb5204(baseParams, businessParams)
  36630. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36631. var dat map[string]interface{}
  36632. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36633. fmt.Println(dat)
  36634. } else {
  36635. fmt.Println(err)
  36636. }
  36637. userJSONBytes, _ := json.Marshal(dat)
  36638. if miConfig.Code == "H15049901371" {
  36639. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36640. utils.ErrorLog("解析失败:%v", err)
  36641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36642. return
  36643. }
  36644. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36645. res.Output = resEleven10265.Output
  36646. res.ErrMsg = resEleven10265.ErrMsg
  36647. res.Cainfo = resEleven10265.Cainfo
  36648. res.WarnMsg = resEleven10265.WarnMsg
  36649. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36650. res.Infcode = infocode
  36651. } else {
  36652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36653. utils.ErrorLog("解析失败:%v", err)
  36654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36655. return
  36656. }
  36657. }
  36658. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36659. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36660. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36661. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36662. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36663. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36664. var doctor_name string
  36665. if roles.ID == 0 {
  36666. doctor_name = "管理员"
  36667. } else {
  36668. doctor_name = roles.UserName
  36669. }
  36670. yiliao_leibie := ""
  36671. switch order.MedType {
  36672. case "11":
  36673. yiliao_leibie = "普通门诊"
  36674. break
  36675. case "12":
  36676. yiliao_leibie = "门诊挂号"
  36677. break
  36678. case "13":
  36679. yiliao_leibie = "急诊"
  36680. break
  36681. case "14":
  36682. yiliao_leibie = "门诊特殊病"
  36683. break
  36684. case "15":
  36685. yiliao_leibie = "门诊统筹"
  36686. break
  36687. case "16":
  36688. yiliao_leibie = "门诊慢性病"
  36689. break
  36690. case "21":
  36691. yiliao_leibie = "普通住院"
  36692. break
  36693. }
  36694. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36695. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36696. if res.Infcode == 0 {
  36697. data2 := map[string]interface{}{
  36698. "diagnosis": name,
  36699. "order_infos": orderInfos,
  36700. "number": order.MdtrtId,
  36701. "date": order.SettleAccountsDate,
  36702. "charge_admin": charge_admin,
  36703. "printor_admin": printor_admin,
  36704. "info": res.Output.Setlinfo,
  36705. "order": order,
  36706. "bedCostTotal": bedCostTotal,
  36707. "bedCostSelfTotal": bedCostSelfTotal,
  36708. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36709. "bedSelfTotal": bedSelfTotal,
  36710. "bedInscpTotal": bedInscpTotal,
  36711. "operationCostTotal": operationCostTotal,
  36712. "operationCostSelfTotal": operationCostSelfTotal,
  36713. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36714. "operationSelfTotal": operationSelfTotal,
  36715. "operationInscpTotal": operationInscpTotal,
  36716. "otherCostTotal": otherCostTotal,
  36717. "otherCostSelfTotal": otherCostSelfTotal,
  36718. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36719. "otherSelfTotal": otherSelfTotal,
  36720. "otherInscpTotal": otherInscpTotal,
  36721. "materialCostTotal": materialCostTotal,
  36722. "materialCostSelfTotal": materialCostSelfTotal,
  36723. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36724. "materialSelfTotal": materialSelfTotal,
  36725. "materialInscpTotal": materialInscpTotal,
  36726. "westernMedicineCostTotal": westernMedicineCostTotal,
  36727. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36728. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36729. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36730. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36731. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36732. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36733. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36734. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36735. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36736. "checkCostTotal": checkCostTotal,
  36737. "checkCostSelfTotal": checkCostSelfTotal,
  36738. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36739. "checkSelfTotal": checkSelfTotal,
  36740. "checkInscpTotal": checkInscpTotal,
  36741. "laboratoryCostTotal": laboratoryCostTotal,
  36742. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36743. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36744. "laboratorySelfTotal": laboratorySelfTotal,
  36745. "laboratoryInscpTotal": laboratoryInscpTotal,
  36746. "treatCostTotal": treatCostTotal,
  36747. "treatCostSelfTotal": treatCostSelfTotal,
  36748. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36749. "treatSelfTotal": treatSelfTotal,
  36750. "treatInscpTotal": treatInscpTotal,
  36751. "doctor_info": doctor_info,
  36752. "doctor_code": adminRole_two.DoctorCode,
  36753. "doctor_name": doctor_name,
  36754. "health_card_no": order.PsnNo,
  36755. "department": departments.Name,
  36756. "yiliao_leibie": yiliao_leibie,
  36757. "after_money": order.AccountPrice,
  36758. "patient": patient,
  36759. "org_name": miConfig.OrgName,
  36760. "org_code": miConfig.Code,
  36761. "order_number": order.Number,
  36762. "his_hospital": his_hospital,
  36763. "his": his,
  36764. "dia_config": dia_config,
  36765. "psn_cash_pay": order.PsnCashPay,
  36766. //"check_order_info": cus_slice,
  36767. }
  36768. data3 = append(data3, data2)
  36769. }
  36770. }
  36771. }
  36772. c.ServeSuccessJSON(map[string]interface{}{
  36773. "infos": data3,
  36774. })
  36775. }
  36776. func (c *HisApiController) GetSettleAccounts() {
  36777. //id, _ := c.GetInt64("id")
  36778. //record_time := c.GetString("record_time")
  36779. order_id, _ := c.GetInt64("order_id")
  36780. admin_user_id, _ := c.GetInt64("admin_user_id")
  36781. //timeLayout := "2006-01-02"
  36782. //loc, _ := time.LoadLocation("Local")
  36783. //
  36784. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36785. //if err != nil {
  36786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36787. // return
  36788. //}Hbyb5203
  36789. //recordDateTime := theTime.Unix()
  36790. adminUser := c.GetAdminUserInfo()
  36791. order, _ := service.GetHisOrderByID(order_id)
  36792. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36793. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36794. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36795. orderInfos = append(orderInfos, orderInfos_two...)
  36796. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36797. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36798. var diagnosis_ids []string
  36799. if his.ID > 0 {
  36800. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36801. } else {
  36802. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36803. }
  36804. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36805. var dia_config []*models.HisXtDiagnoseConfig
  36806. var name string
  36807. for _, item := range diagnosis_ids {
  36808. id, _ := strconv.ParseInt(item, 10, 64)
  36809. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36810. dia_config = append(dia_config, &diagnosisConfig)
  36811. if len(name) == 0 {
  36812. name = diagnosisConfig.ClassName
  36813. } else {
  36814. name = name + "," + diagnosisConfig.ClassName
  36815. }
  36816. }
  36817. if patient.UserOrgId == 10215 {
  36818. name = "慢性肾功能不全(血透治疗)"
  36819. }
  36820. var bedCostTotal float64 = 0 //床位总费
  36821. var bedCostSelfTotal float64 = 0 //床位自费
  36822. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36823. var bedSelfTotal float64 = 0 //床位部分项目自费
  36824. var bedInscpTotal float64 = 0 //床位部分项目自费
  36825. var operationCostTotal float64 = 0 //手术费
  36826. var operationCostSelfTotal float64 = 0 //手术费
  36827. var operationCostPartSelfTotal float64 = 0 //手术费
  36828. var operationSelfTotal float64 = 0 //床位部分项目自费
  36829. var operationInscpTotal float64 = 0 //床位部分项目自费
  36830. var otherCostTotal float64 = 0 //其他费用
  36831. var otherCostSelfTotal float64 = 0 //其他费用
  36832. var otherCostPartSelfTotal float64 = 0 //其他费用
  36833. var otherSelfTotal float64 = 0 //床位部分项目自费
  36834. var otherInscpTotal float64 = 0 //床位部分项目自费
  36835. var materialCostTotal float64 = 0 //材料费
  36836. var materialCostSelfTotal float64 = 0 //材料费
  36837. var materialCostPartSelfTotal float64 = 0 //材料费
  36838. var materialSelfTotal float64 = 0 //床位部分项目自费
  36839. var materialInscpTotal float64 = 0 //床位部分项目自费
  36840. var westernMedicineCostTotal float64 = 0 //西药费
  36841. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36842. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36843. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36844. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36845. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36846. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36847. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36848. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36849. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36850. var checkCostTotal float64 = 0 //检查费
  36851. var checkCostSelfTotal float64 = 0 //检查费
  36852. var checkCostPartSelfTotal float64 = 0 //检查费
  36853. var checkSelfTotal float64 = 0 //床位部分项目自费
  36854. var checkInscpTotal float64 = 0 //床位部分项目自费
  36855. var laboratoryCostTotal float64 = 0 //化验费
  36856. var laboratoryCostSelfTotal float64 = 0 //化验费
  36857. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36858. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36859. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36860. var treatCostTotal float64 = 0 //治疗费用
  36861. var treatCostSelfTotal float64 = 0 //治疗费用
  36862. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36863. var treatSelfTotal float64 = 0 //床位部分项目自费
  36864. var treatInscpTotal float64 = 0 //床位部分项目自费
  36865. var zcCostTotal float64 = 0 //治疗费用
  36866. var zcCostSelfTotal float64 = 0 //治疗费用
  36867. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36868. var zcSelfTotal float64 = 0 //床位部分项目自费
  36869. var zcInscpTotal float64 = 0 //床位部分项目自费
  36870. var huliCostTotal float64 = 0 //治疗费用
  36871. var huliCostSelfTotal float64 = 0 //治疗费用
  36872. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36873. var huliSelfTotal float64 = 0 //床位部分项目自费
  36874. var huliInscpTotal float64 = 0 //床位部分项目自费
  36875. decimal.DivisionPrecision = 2
  36876. for _, item := range orderInfos {
  36877. if item.MedChrgitmType == "01" { //床位费
  36878. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36879. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36880. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36881. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36882. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36883. }
  36884. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36885. if item.MedChrgitmType == "03" { //检查费
  36886. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36887. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36888. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36889. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36890. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36891. }
  36892. } else {
  36893. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36894. fmt.Println("------------")
  36895. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36896. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36897. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36898. }
  36899. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36900. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36901. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36902. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36903. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36904. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36905. }
  36906. }
  36907. if item.MedChrgitmType == "04" { //化验费
  36908. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36909. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36910. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36911. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36912. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36913. }
  36914. if item.MedChrgitmType == "05" { //治疗费
  36915. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36916. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36917. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36918. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36919. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36920. }
  36921. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36922. fmt.Println("------------")
  36923. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36924. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36925. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36926. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36927. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36928. }
  36929. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36930. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36931. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36932. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36933. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36934. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36935. }
  36936. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36937. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36938. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36939. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36940. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36941. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36942. }
  36943. if item.MedChrgitmType == "09" { //西药费
  36944. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36945. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36946. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36947. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36948. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36949. }
  36950. if item.MedChrgitmType == "11" { //中成费
  36951. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36952. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36953. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36954. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36955. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36956. }
  36957. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36958. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36959. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36960. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36961. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36962. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36963. }
  36964. if item.MedChrgitmType == "02" { //其他费
  36965. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36966. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36967. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36968. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36969. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36970. }
  36971. if item.MedChrgitmType == "07" { //其他费
  36972. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36973. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36974. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36975. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36976. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36977. }
  36978. }
  36979. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36980. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36981. var user_name string
  36982. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36983. if role.ID == 0 {
  36984. user_name = "管理员"
  36985. } else {
  36986. user_name = role.UserName
  36987. }
  36988. baseParams := models.BaseParams{
  36989. SecretKey: miConfig.SecretKey,
  36990. FixmedinsCode: miConfig.Code,
  36991. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36992. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36993. OrgName: miConfig.OrgName,
  36994. Doctor: user_name,
  36995. RequestUrl: miConfig.Url,
  36996. AccessKey: miConfig.AccessKey,
  36997. }
  36998. businessParams := models.BusinessParams{
  36999. PsnNo: order.PsnNo,
  37000. MdtrtId: order.MdtrtId,
  37001. SetlId: order.SetlId,
  37002. }
  37003. var res ResultEleven
  37004. var resah ResultElevenah
  37005. var resEleven10265 ResultEleven10265
  37006. if config.IsOpen == 1 {
  37007. if miConfig.MdtrtareaAdmvs == "421300" {
  37008. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37009. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37010. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37011. resp, requestErr := http.Get(api)
  37012. if requestErr != nil {
  37013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37014. return
  37015. }
  37016. body, ioErr := ioutil.ReadAll(resp.Body)
  37017. if ioErr != nil {
  37018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37020. return
  37021. }
  37022. var respJSON map[string]interface{}
  37023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37026. return
  37027. }
  37028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37029. result, _ := json.Marshal(respJSON)
  37030. fmt.Println("log")
  37031. fmt.Println(string(result))
  37032. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37033. utils.ErrorLog("解析失败:%v", err)
  37034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37035. return
  37036. }
  37037. } else if miConfig.MdtrtareaAdmvs == "420200" {
  37038. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37039. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37040. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37041. resp, requestErr := http.Get(api)
  37042. if requestErr != nil {
  37043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37044. return
  37045. }
  37046. body, ioErr := ioutil.ReadAll(resp.Body)
  37047. if ioErr != nil {
  37048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37050. return
  37051. }
  37052. var respJSON map[string]interface{}
  37053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37056. return
  37057. }
  37058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37059. result, _ := json.Marshal(respJSON)
  37060. fmt.Println("log")
  37061. fmt.Println(string(result))
  37062. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37063. utils.ErrorLog("解析失败:%v", err)
  37064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37065. return
  37066. }
  37067. } else if miConfig.MdtrtareaAdmvs == "420902" {
  37068. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37069. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37070. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37071. resp, requestErr := http.Get(api)
  37072. if requestErr != nil {
  37073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37074. return
  37075. }
  37076. body, ioErr := ioutil.ReadAll(resp.Body)
  37077. if ioErr != nil {
  37078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37080. return
  37081. }
  37082. var respJSON map[string]interface{}
  37083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37086. return
  37087. }
  37088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37089. result, _ := json.Marshal(respJSON)
  37090. fmt.Println("log")
  37091. fmt.Println(string(result))
  37092. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37093. utils.ErrorLog("解析失败:%v", err)
  37094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37095. return
  37096. }
  37097. } else if miConfig.MdtrtareaAdmvs == "421182" {
  37098. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37099. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37100. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  37101. resp, requestErr := http.Get(api)
  37102. if requestErr != nil {
  37103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37104. return
  37105. }
  37106. body, ioErr := ioutil.ReadAll(resp.Body)
  37107. if ioErr != nil {
  37108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37110. return
  37111. }
  37112. var respJSON map[string]interface{}
  37113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37116. return
  37117. }
  37118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37119. result, _ := json.Marshal(respJSON)
  37120. fmt.Println("log")
  37121. fmt.Println(string(result))
  37122. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37123. utils.ErrorLog("解析失败:%v", err)
  37124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37125. return
  37126. }
  37127. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  37128. var api string
  37129. if miConfig.MdtrtareaAdmvs == "320830" {
  37130. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37131. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37132. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37133. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37134. } else if miConfig.MdtrtareaAdmvs == "320921" {
  37135. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37136. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37137. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37138. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37139. } else {
  37140. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37141. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37142. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37143. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37144. }
  37145. resp, requestErr := http.Get(api)
  37146. if requestErr != nil {
  37147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37148. return
  37149. }
  37150. body, ioErr := ioutil.ReadAll(resp.Body)
  37151. if ioErr != nil {
  37152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37154. return
  37155. }
  37156. var respJSON map[string]interface{}
  37157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37160. return
  37161. }
  37162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37163. result, _ := json.Marshal(respJSON)
  37164. fmt.Println("log")
  37165. fmt.Println(string(result))
  37166. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37167. utils.ErrorLog("解析失败:%v", err)
  37168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37169. return
  37170. }
  37171. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37172. res.Output = resEleven10265.Output
  37173. res.ErrMsg = resEleven10265.ErrMsg
  37174. res.Cainfo = resEleven10265.Cainfo
  37175. res.WarnMsg = resEleven10265.WarnMsg
  37176. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37177. res.Infcode = infocode
  37178. } else if miConfig.MdtrtareaAdmvs == "350500" {
  37179. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  37180. saveLog(result, requestLog, "5203", "结算单")
  37181. var dat map[string]interface{}
  37182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37183. fmt.Println(dat)
  37184. } else {
  37185. fmt.Println(err)
  37186. }
  37187. userJSONBytes, _ := json.Marshal(dat)
  37188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37189. utils.ErrorLog("解析失败:%v", err)
  37190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37191. return
  37192. }
  37193. } else if miConfig.MdtrtareaAdmvs == "360302" {
  37194. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37195. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37196. saveLog(result, requestLog, "5203", "结算单")
  37197. var dat map[string]interface{}
  37198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37199. fmt.Println(dat)
  37200. } else {
  37201. fmt.Println(err)
  37202. }
  37203. userJSONBytes, _ := json.Marshal(dat)
  37204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37205. utils.ErrorLog("解析失败:%v", err)
  37206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37207. return
  37208. }
  37209. } else if miConfig.MdtrtareaAdmvs == "361025" {
  37210. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37211. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37212. saveLog(result, requestLog, "5203", "结算单")
  37213. var dat map[string]interface{}
  37214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37215. fmt.Println(dat)
  37216. } else {
  37217. fmt.Println(err)
  37218. }
  37219. userJSONBytes, _ := json.Marshal(dat)
  37220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37221. utils.ErrorLog("解析失败:%v", err)
  37222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37223. return
  37224. }
  37225. } else if miConfig.MdtrtareaAdmvs == "360100" {
  37226. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37227. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37228. saveLog(result, requestLog, "5203", "结算单")
  37229. var dat map[string]interface{}
  37230. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37231. fmt.Println(dat)
  37232. } else {
  37233. fmt.Println(err)
  37234. }
  37235. userJSONBytes, _ := json.Marshal(dat)
  37236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37237. utils.ErrorLog("解析失败:%v", err)
  37238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37239. return
  37240. }
  37241. } else if miConfig.MdtrtareaAdmvs == "341203" {
  37242. var api string
  37243. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37244. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37245. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37246. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37247. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37248. resp, requestErr := http.Get(api)
  37249. if requestErr != nil {
  37250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37251. return
  37252. }
  37253. body, ioErr := ioutil.ReadAll(resp.Body)
  37254. if ioErr != nil {
  37255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37257. return
  37258. }
  37259. var respJSON map[string]interface{}
  37260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37263. return
  37264. }
  37265. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37266. if status == "0" {
  37267. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37268. c.ServeSuccessJSON(map[string]interface{}{
  37269. "failed_code": -10,
  37270. "msg": err_msg,
  37271. })
  37272. return
  37273. }
  37274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37275. result, _ := json.Marshal(respJSON)
  37276. fmt.Println("log")
  37277. fmt.Println(string(result))
  37278. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37279. utils.ErrorLog("解析失败:%v", err)
  37280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37281. return
  37282. }
  37283. res.InfRefmsgid = resah.InfRefmsgid
  37284. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37285. // 创建对应的Time类型
  37286. t := time.UnixMilli(timestamp)
  37287. // 格式化成指定的日期字符串
  37288. str := t.Format("2006-01-02 15:04:05")
  37289. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37290. // 创建对应的Time类型
  37291. t3 := time.UnixMilli(timestamp2)
  37292. // 格式化成指定的日期字符串
  37293. str2 := t3.Format("2006-01-02 15:04:05")
  37294. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37295. // 创建对应的Time类型
  37296. t4 := time.UnixMilli(timestamp3)
  37297. // 格式化成指定的日期字符串
  37298. str3 := t4.Format("2006-01-02 15:04:05")
  37299. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37300. // 创建对应的Time类型
  37301. t5 := time.UnixMilli(timestamp4)
  37302. // 格式化成指定的日期字符串
  37303. str5 := t5.Format("2006-01-02 15:04:05")
  37304. res.Output.Setlinfo.Brdy = str2
  37305. res.Output.Setlinfo.SetlTime = str
  37306. res.Output.Setlinfo.Begndate = str3
  37307. res.Output.Setlinfo.Enddate = str5
  37308. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37309. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37310. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37311. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37312. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37313. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37314. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37315. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37316. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37317. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37318. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37319. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37320. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37321. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37322. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37323. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37324. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37325. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37326. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37327. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37328. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37329. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37330. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37331. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37332. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37333. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37334. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37335. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37336. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37337. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37338. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37339. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37340. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37341. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37342. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37343. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37344. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37345. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37346. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37347. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37348. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37349. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37350. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37351. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37352. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37353. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37354. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37355. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37356. //res.Output.Setldetail = resah.Output.Setldetail
  37357. res.ErrMsg = resah.ErrMsg
  37358. res.Cainfo = resah.Cainfo
  37359. res.WarnMsg = resah.WarnMsg
  37360. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37361. var api string
  37362. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37363. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37364. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37365. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37366. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37367. resp, requestErr := http.Get(api)
  37368. if requestErr != nil {
  37369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37370. return
  37371. }
  37372. body, ioErr := ioutil.ReadAll(resp.Body)
  37373. if ioErr != nil {
  37374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37376. return
  37377. }
  37378. var respJSON map[string]interface{}
  37379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37382. return
  37383. }
  37384. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37385. if status == "0" {
  37386. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37387. c.ServeSuccessJSON(map[string]interface{}{
  37388. "failed_code": -10,
  37389. "msg": err_msg,
  37390. })
  37391. return
  37392. }
  37393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37394. result, _ := json.Marshal(respJSON)
  37395. fmt.Println("log")
  37396. fmt.Println(string(result))
  37397. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37398. utils.ErrorLog("解析失败:%v", err)
  37399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37400. return
  37401. }
  37402. res.InfRefmsgid = resah.InfRefmsgid
  37403. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37404. // 创建对应的Time类型
  37405. t := time.UnixMilli(timestamp)
  37406. // 格式化成指定的日期字符串
  37407. str := t.Format("2006-01-02 15:04:05")
  37408. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37409. // 创建对应的Time类型
  37410. t3 := time.UnixMilli(timestamp2)
  37411. // 格式化成指定的日期字符串
  37412. str2 := t3.Format("2006-01-02 15:04:05")
  37413. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37414. // 创建对应的Time类型
  37415. t4 := time.UnixMilli(timestamp3)
  37416. // 格式化成指定的日期字符串
  37417. str3 := t4.Format("2006-01-02 15:04:05")
  37418. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37419. // 创建对应的Time类型
  37420. t5 := time.UnixMilli(timestamp4)
  37421. // 格式化成指定的日期字符串
  37422. str5 := t5.Format("2006-01-02 15:04:05")
  37423. res.Output.Setlinfo.Brdy = str2
  37424. res.Output.Setlinfo.SetlTime = str
  37425. res.Output.Setlinfo.Begndate = str3
  37426. res.Output.Setlinfo.Enddate = str5
  37427. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37428. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37429. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37430. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37431. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37432. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37433. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37434. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37435. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37436. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37437. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37438. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37439. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37440. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37441. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37442. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37443. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37444. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37445. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37446. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37447. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37448. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37449. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37450. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37451. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37452. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37453. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37454. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37455. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37456. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37457. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37458. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37459. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37460. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37461. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37462. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37463. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37464. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37465. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37466. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37467. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37468. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37469. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37470. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37471. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37472. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37473. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37474. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37475. //res.Output.Setldetail = resah.Output.Setldetail
  37476. res.ErrMsg = resah.ErrMsg
  37477. res.Cainfo = resah.Cainfo
  37478. res.WarnMsg = resah.WarnMsg
  37479. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37480. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37481. saveLog(result, requestLog, "5203", "结算单")
  37482. var dat map[string]interface{}
  37483. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37484. fmt.Println(dat)
  37485. } else {
  37486. fmt.Println(err)
  37487. }
  37488. userJSONBytes, _ := json.Marshal(dat)
  37489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37490. utils.ErrorLog("解析失败:%v", err)
  37491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37492. return
  37493. }
  37494. } else if miConfig.MdtrtareaAdmvs == "150404" {
  37495. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37496. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37497. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37498. resp, requestErr := http.Get(api)
  37499. if requestErr != nil {
  37500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37501. return
  37502. }
  37503. body, ioErr := ioutil.ReadAll(resp.Body)
  37504. if ioErr != nil {
  37505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37507. return
  37508. }
  37509. var respJSON map[string]interface{}
  37510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37513. return
  37514. }
  37515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37516. result, _ := json.Marshal(respJSON)
  37517. fmt.Println("log")
  37518. fmt.Println(string(result))
  37519. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37520. utils.ErrorLog("解析失败:%v", err)
  37521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37522. return
  37523. }
  37524. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37525. res.Output = resEleven10265.Output
  37526. res.ErrMsg = resEleven10265.ErrMsg
  37527. res.Cainfo = resEleven10265.Cainfo
  37528. res.WarnMsg = resEleven10265.WarnMsg
  37529. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37530. res.Infcode = infocode
  37531. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37532. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37533. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37535. resp, requestErr := http.Get(api)
  37536. if requestErr != nil {
  37537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37538. return
  37539. }
  37540. body, ioErr := ioutil.ReadAll(resp.Body)
  37541. if ioErr != nil {
  37542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37544. return
  37545. }
  37546. var respJSON map[string]interface{}
  37547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37550. return
  37551. }
  37552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37553. result, _ := json.Marshal(respJSON)
  37554. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37555. utils.ErrorLog("解析失败:%v", err)
  37556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37557. return
  37558. }
  37559. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37560. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37561. //return
  37562. } else {
  37563. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37564. if len(his.InsuplcAdmdvs) == 0 {
  37565. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37566. } else {
  37567. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37568. }
  37569. result := service.Gdyb5203(baseParams, businessParams)
  37570. //service.Gdyb5204(baseParams, businessParams)
  37571. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37572. var dat map[string]interface{}
  37573. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37574. fmt.Println(dat)
  37575. } else {
  37576. fmt.Println(err)
  37577. }
  37578. userJSONBytes, _ := json.Marshal(dat)
  37579. if miConfig.Code == "H15049901371" {
  37580. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37581. utils.ErrorLog("解析失败:%v", err)
  37582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37583. return
  37584. }
  37585. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37586. res.Output = resEleven10265.Output
  37587. res.ErrMsg = resEleven10265.ErrMsg
  37588. res.Cainfo = resEleven10265.Cainfo
  37589. res.WarnMsg = resEleven10265.WarnMsg
  37590. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37591. res.Infcode = infocode
  37592. } else {
  37593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37594. utils.ErrorLog("解析失败:%v", err)
  37595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37596. return
  37597. }
  37598. }
  37599. }
  37600. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37601. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37602. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37603. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37604. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37605. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37606. var doctor_name string
  37607. if roles.ID == 0 {
  37608. doctor_name = "管理员"
  37609. } else {
  37610. doctor_name = roles.UserName
  37611. }
  37612. yiliao_leibie := ""
  37613. switch order.MedType {
  37614. case "11":
  37615. yiliao_leibie = "普通门诊"
  37616. break
  37617. case "12":
  37618. yiliao_leibie = "门诊挂号"
  37619. break
  37620. case "13":
  37621. yiliao_leibie = "急诊"
  37622. break
  37623. case "14":
  37624. yiliao_leibie = "门诊特殊病"
  37625. break
  37626. case "15":
  37627. yiliao_leibie = "门诊统筹"
  37628. break
  37629. case "16":
  37630. yiliao_leibie = "门诊慢性病"
  37631. break
  37632. case "21":
  37633. yiliao_leibie = "普通住院"
  37634. break
  37635. }
  37636. //var rf []CustomFundPay
  37637. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37638. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37639. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37640. if res.Infcode == 0 {
  37641. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 || adminUser.CurrentOrgId == 10210 || adminUser.CurrentOrgId == 10571 || adminUser.CurrentOrgId == 10752 {
  37642. c.ServeSuccessJSON(map[string]interface{}{
  37643. "diagnosis": name,
  37644. "order_infos": orderInfos,
  37645. "number": order.MdtrtId,
  37646. "date": order.SettleAccountsDate,
  37647. "charge_admin": charge_admin,
  37648. "printor_admin": printor_admin,
  37649. "info": res.Output.Setlinfo,
  37650. "order": order,
  37651. "bedCostTotal": bedCostTotal,
  37652. "bedCostSelfTotal": bedCostSelfTotal,
  37653. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37654. "bedSelfTotal": bedSelfTotal,
  37655. "bedInscpTotal": bedInscpTotal,
  37656. "operationCostTotal": operationCostTotal,
  37657. "operationCostSelfTotal": operationCostSelfTotal,
  37658. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37659. "operationSelfTotal": operationSelfTotal,
  37660. "operationInscpTotal": operationInscpTotal,
  37661. "otherCostTotal": otherCostTotal,
  37662. "otherCostSelfTotal": otherCostSelfTotal,
  37663. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37664. "otherSelfTotal": otherSelfTotal,
  37665. "otherInscpTotal": otherInscpTotal,
  37666. "materialCostTotal": materialCostTotal,
  37667. "materialCostSelfTotal": materialCostSelfTotal,
  37668. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37669. "materialSelfTotal": materialSelfTotal,
  37670. "materialInscpTotal": materialInscpTotal,
  37671. "westernMedicineCostTotal": westernMedicineCostTotal,
  37672. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37673. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37674. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37675. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37676. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37677. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37678. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37679. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37680. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37681. "checkCostTotal": checkCostTotal,
  37682. "checkCostSelfTotal": checkCostSelfTotal,
  37683. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37684. "checkSelfTotal": checkSelfTotal,
  37685. "checkInscpTotal": checkInscpTotal,
  37686. "laboratoryCostTotal": laboratoryCostTotal,
  37687. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37688. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37689. "laboratorySelfTotal": laboratorySelfTotal,
  37690. "laboratoryInscpTotal": laboratoryInscpTotal,
  37691. "treatCostTotal": treatCostTotal,
  37692. "treatCostSelfTotal": treatCostSelfTotal,
  37693. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37694. "treatSelfTotal": treatSelfTotal,
  37695. "treatInscpTotal": treatInscpTotal,
  37696. "doctor_info": doctor_info,
  37697. "doctor_code": adminRole_two.DoctorCode,
  37698. "doctor_name": doctor_name,
  37699. "health_card_no": order.PsnNo,
  37700. "department": departments.Name,
  37701. "yiliao_leibie": yiliao_leibie,
  37702. "after_money": order.AccountPrice,
  37703. "patient": patient,
  37704. "org_name": miConfig.OrgName,
  37705. "org_code": miConfig.Code,
  37706. "order_number": order.Number,
  37707. "his_hospital": his_hospital,
  37708. "his": his,
  37709. "dia_config": dia_config,
  37710. "psn_cash_pay": order.PsnCashPay,
  37711. "zcCostTotal": zcCostTotal,
  37712. "zcCostSelfTotal": zcCostSelfTotal,
  37713. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37714. "zcSelfTotal": zcSelfTotal,
  37715. "zcInscpTotal": zcInscpTotal,
  37716. "huliCostTotal": huliCostTotal,
  37717. "huliCostSelfTotal": huliCostSelfTotal,
  37718. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37719. "huliSelfTotal": huliSelfTotal,
  37720. "huliInscpTotal": huliInscpTotal,
  37721. //"funds": rf,
  37722. //"check_order_info": cus_slice,
  37723. })
  37724. } else {
  37725. c.ServeSuccessJSON(map[string]interface{}{
  37726. "diagnosis": name,
  37727. "order_infos": orderInfos,
  37728. "number": order.MdtrtId,
  37729. "date": order.SettleAccountsDate,
  37730. "charge_admin": charge_admin,
  37731. "printor_admin": printor_admin,
  37732. "info": order,
  37733. "order": order,
  37734. "bedCostTotal": bedCostTotal,
  37735. "bedCostSelfTotal": bedCostSelfTotal,
  37736. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37737. "bedSelfTotal": bedSelfTotal,
  37738. "bedInscpTotal": bedInscpTotal,
  37739. "operationCostTotal": operationCostTotal,
  37740. "operationCostSelfTotal": operationCostSelfTotal,
  37741. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37742. "operationSelfTotal": operationSelfTotal,
  37743. "operationInscpTotal": operationInscpTotal,
  37744. "otherCostTotal": otherCostTotal,
  37745. "otherCostSelfTotal": otherCostSelfTotal,
  37746. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37747. "otherSelfTotal": otherSelfTotal,
  37748. "otherInscpTotal": otherInscpTotal,
  37749. "materialCostTotal": materialCostTotal,
  37750. "materialCostSelfTotal": materialCostSelfTotal,
  37751. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37752. "materialSelfTotal": materialSelfTotal,
  37753. "materialInscpTotal": materialInscpTotal,
  37754. "westernMedicineCostTotal": westernMedicineCostTotal,
  37755. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37756. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37757. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37758. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37759. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37760. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37761. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37762. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37763. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37764. "checkCostTotal": checkCostTotal,
  37765. "checkCostSelfTotal": checkCostSelfTotal,
  37766. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37767. "checkSelfTotal": checkSelfTotal,
  37768. "checkInscpTotal": checkInscpTotal,
  37769. "laboratoryCostTotal": laboratoryCostTotal,
  37770. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37771. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37772. "laboratorySelfTotal": laboratorySelfTotal,
  37773. "laboratoryInscpTotal": laboratoryInscpTotal,
  37774. "treatCostTotal": treatCostTotal,
  37775. "treatCostSelfTotal": treatCostSelfTotal,
  37776. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37777. "treatSelfTotal": treatSelfTotal,
  37778. "treatInscpTotal": treatInscpTotal,
  37779. "doctor_info": doctor_info,
  37780. "doctor_code": adminRole_two.DoctorCode,
  37781. "doctor_name": doctor_name,
  37782. "health_card_no": order.PsnNo,
  37783. "department": departments.Name,
  37784. "yiliao_leibie": yiliao_leibie,
  37785. "after_money": order.AccountPrice,
  37786. "patient": patient,
  37787. "org_name": miConfig.OrgName,
  37788. "org_code": miConfig.Code,
  37789. "order_number": order.Number,
  37790. "his_hospital": his_hospital,
  37791. "his": his,
  37792. "dia_config": dia_config,
  37793. "psn_cash_pay": order.PsnCashPay,
  37794. "zcCostTotal": zcCostTotal,
  37795. "zcCostSelfTotal": zcCostSelfTotal,
  37796. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37797. "zcSelfTotal": zcSelfTotal,
  37798. "zcInscpTotal": zcInscpTotal,
  37799. "huliCostTotal": huliCostTotal,
  37800. "huliCostSelfTotal": huliCostSelfTotal,
  37801. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37802. "huliSelfTotal": huliSelfTotal,
  37803. "huliInscpTotal": huliInscpTotal,
  37804. //"funds": rf,
  37805. //"check_order_info": cus_slice,
  37806. })
  37807. }
  37808. }
  37809. }
  37810. }
  37811. //func (c *HisApiController) CheckTreatment() {
  37812. // patient_id, _ := c.GetInt64("patient_id")
  37813. // id_card_no := c.GetString("id_card_no")
  37814. // insutype := c.GetString("insutype")
  37815. // med_type := c.GetString("med_type")
  37816. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37817. //
  37818. // adminUser := c.GetAdminUserInfo()
  37819. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37820. //
  37821. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37822. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37823. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37824. //
  37825. // if miConfig.MdtrtareaAdmvs == "421300" {
  37826. // var res ResultTwo
  37827. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37828. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37829. // "&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)
  37830. // resp, requestErr := http.Get(api)
  37831. // if requestErr != nil {
  37832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37833. // return
  37834. // }
  37835. //
  37836. // body, ioErr := ioutil.ReadAll(resp.Body)
  37837. // if ioErr != nil {
  37838. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37840. // return
  37841. // }
  37842. // var respJSON map[string]interface{}
  37843. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37844. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37846. // return
  37847. // }
  37848. //
  37849. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37850. // result, _ := json.Marshal(respJSON)
  37851. //
  37852. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37853. // utils.ErrorLog("解析失败:%v", err)
  37854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37855. // return
  37856. // }
  37857. //
  37858. // if res.Infcode == 0 {
  37859. //
  37860. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37861. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37862. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37863. // resp, requestErr := http.Get(api)
  37864. // if requestErr != nil {
  37865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37866. // return
  37867. // }
  37868. //
  37869. // body, ioErr := ioutil.ReadAll(resp.Body)
  37870. // if ioErr != nil {
  37871. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37873. // return
  37874. // }
  37875. // var respJSON map[string]interface{}
  37876. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37877. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37878. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37879. // return
  37880. // }
  37881. // var res Result2001
  37882. //
  37883. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37884. // result2, _ := json.Marshal(respJSON)
  37885. //
  37886. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37887. // utils.ErrorLog("解析失败:%v", err)
  37888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37889. // return
  37890. // }
  37891. //
  37892. // if res.Infcode == 0 {
  37893. // c.ServeSuccessJSON(map[string]interface{}{
  37894. // "msg": res.Output.Trtinfo,
  37895. // })
  37896. // }
  37897. //
  37898. // } else {
  37899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37900. // return
  37901. // }
  37902. //
  37903. // } else {
  37904. //
  37905. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37906. // var dat map[string]interface{}
  37907. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37908. // fmt.Println(dat)
  37909. // } else {
  37910. // fmt.Println(err)
  37911. // }
  37912. // userJSONBytes, _ := json.Marshal(dat)
  37913. // var res ResultTwo
  37914. // var res10265 ResultTwo10265
  37915. // if miConfig.Code == "H15049901371" {
  37916. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37917. // utils.ErrorLog("解析失败:%v", err)
  37918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37919. // return
  37920. // }
  37921. // res.ErrMsg = res10265.ErrMsg
  37922. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37923. // res.Infcode = infocode
  37924. // res.Output = res10265.Output
  37925. // res.InfRefmsgid = res10265.InfRefmsgid
  37926. // } else {
  37927. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37928. // utils.ErrorLog("解析失败:%v", err)
  37929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37930. // return
  37931. // }
  37932. // }
  37933. //
  37934. // var user_name string
  37935. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37936. // if role.ID == 0 {
  37937. // user_name = "xxx"
  37938. // } else {
  37939. // user_name = role.UserName
  37940. // }
  37941. //
  37942. // baseParams := models.BaseParams{
  37943. // SecretKey: miConfig.SecretKey,
  37944. // FixmedinsCode: miConfig.Code,
  37945. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37946. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37947. // OrgName: miConfig.OrgName,
  37948. // Doctor: user_name,
  37949. // }
  37950. //
  37951. // if config.IsOpen == 1 {
  37952. // if miConfig.Code == "H15049901371" {
  37953. // if med_type == "14" {
  37954. // if insutype == "390" {
  37955. // med_type = "9933"
  37956. // } else if insutype == "310" {
  37957. // med_type = "990502"
  37958. // }
  37959. // } else if med_type == "11" {
  37960. // med_type = "11"
  37961. // }
  37962. // }
  37963. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37964. // var dat map[string]interface{}
  37965. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37966. // fmt.Println(dat)
  37967. // } else {
  37968. // fmt.Println(err)
  37969. // }
  37970. // var res Result2001
  37971. // var res10265 Result2001Org10265
  37972. // if miConfig.Code == "H15049901371" {
  37973. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37974. // utils.ErrorLog("解析失败:%v", err)
  37975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37976. // return
  37977. // }
  37978. // res.ErrMsg = res10265.ErrMsg
  37979. // res.Output = res10265.Output
  37980. // res.InfRefmsgid = res10265.InfRefmsgid
  37981. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37982. // res.Infcode = infocode
  37983. // } else {
  37984. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37985. // utils.ErrorLog("解析失败:%v", err)
  37986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37987. // return
  37988. // }
  37989. // }
  37990. // if res.Infcode == 0 {
  37991. // c.ServeSuccessJSON(map[string]interface{}{
  37992. // "msg": res.Output.Trtinfo,
  37993. // })
  37994. // }
  37995. // }
  37996. // }
  37997. //}
  37998. //func (c *HisApiController) PutRecord() {
  37999. // id, _ := c.GetInt64("id")
  38000. // record_time := c.GetString("record_time")
  38001. // timeLayout := "2006-01-02"
  38002. // loc, _ := time.LoadLocation("Local")
  38003. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  38004. // if err != nil {
  38005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  38006. // return
  38007. // }
  38008. // recordDateTime := theTime.Unix()
  38009. //
  38010. // adminInfo := c.GetAdminUserInfo()
  38011. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  38012. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38013. //
  38014. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  38015. //
  38016. // fmt.Println(miConfig.SecretKey)
  38017. //
  38018. // if patient == nil {
  38019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38020. // return
  38021. // }
  38022. // if len(patient.IdCardNo) == 0 {
  38023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  38024. // return
  38025. // }
  38026. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  38027. // if config.IsOpen == 1 {
  38028. // 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
  38029. // resp, requestErr := http.Get(api)
  38030. // if requestErr != nil {
  38031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38032. // return
  38033. // }
  38034. // defer resp.Body.Close()
  38035. // body, ioErr := ioutil.ReadAll(resp.Body)
  38036. // if ioErr != nil {
  38037. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38039. // return
  38040. // }
  38041. // var respJSON map[string]interface{}
  38042. //
  38043. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38044. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38045. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38046. // return
  38047. // }
  38048. //
  38049. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38050. // userJSONBytes, _ := json.Marshal(userJSON)
  38051. // var res ResultTwo
  38052. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38053. // utils.ErrorLog("解析失败:%v", err)
  38054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38055. // return
  38056. // }
  38057. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38058. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38059. // infoStr := string(Iinfos)
  38060. // idetinfoStr := string(Idetinfos)
  38061. //
  38062. // if res.Infcode == 0 {
  38063. // his := models.VMHisPatient{
  38064. // Status: 1,
  38065. // Ctime: time.Now().Unix(),
  38066. // Mtime: time.Now().Unix(),
  38067. // PsnNo: res.Output.Baseinfo.PsnNo,
  38068. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  38069. // Certno: res.Output.Baseinfo.Certno,
  38070. // PsnName: res.Output.Baseinfo.PsnName,
  38071. // Gend: res.Output.Baseinfo.Gend,
  38072. // Naty: res.Output.Baseinfo.Naty,
  38073. // Brdy: res.Output.Baseinfo.Brdy,
  38074. // Age: res.Output.Baseinfo.Age,
  38075. // Iinfo: infoStr,
  38076. // Idetinfo: idetinfoStr,
  38077. // PatientId: patient.ID,
  38078. // RecordDate: theTime.Unix(),
  38079. // UserOrgId: adminInfo.CurrentOrgId,
  38080. // AdminUserId: adminInfo.AdminUser.Id,
  38081. // IsReturn: 1,
  38082. // }
  38083. //
  38084. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  38085. // //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")
  38086. // //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")
  38087. //
  38088. // //var dat map[string]interface{}
  38089. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38090. // // fmt.Println(dat)
  38091. // //} else {
  38092. // // fmt.Println(err)
  38093. // //}
  38094. //
  38095. // var dat2 map[string]interface{}
  38096. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38097. // fmt.Println(dat2)
  38098. // } else {
  38099. // fmt.Println(err)
  38100. // }
  38101. //
  38102. // } else {
  38103. // adminUser := c.GetAdminUserInfo()
  38104. // errlog := &models.HisOrderError{
  38105. // UserOrgId: adminUser.CurrentOrgId,
  38106. // Ctime: time.Now().Unix(),
  38107. // Mtime: time.Now().Unix(),
  38108. // ErrMsg: res.ErrMsg,
  38109. // Status: 1,
  38110. // PatientId: id,
  38111. // RecordTime: recordDateTime,
  38112. // Stage: 1,
  38113. // }
  38114. // service.CreateErrMsgLog(errlog)
  38115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  38116. // return
  38117. // }
  38118. // }
  38119. //
  38120. //}
  38121. //func (c *HisApiController) GetUploadDiag() {
  38122. // id, _ := c.GetInt64("id")
  38123. // record_time := c.GetString("record_time")
  38124. //
  38125. // diagnosis_id, _ := c.GetInt64("diagnosis")
  38126. // sick_type, _ := c.GetInt64("sick_type")
  38127. // reg_type, _ := c.GetInt64("reg_type")
  38128. //
  38129. // timeLayout := "2006-01-02"
  38130. // loc, _ := time.LoadLocation("Local")
  38131. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  38132. // if err != nil {
  38133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  38134. // return
  38135. // }
  38136. //
  38137. // var patientPrescription models.HisPrescriptionInfo
  38138. // recordDateTime := theTime.Unix()
  38139. // adminInfo := c.GetAdminUserInfo()
  38140. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38141. //
  38142. // if patientPrescription.ID == 0 {
  38143. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38144. // }
  38145. //
  38146. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  38147. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  38148. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38149. // sickConfig, _ := service.FindSickById(sick_type)
  38150. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  38151. //
  38152. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  38153. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  38154. // "&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 +
  38155. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  38156. // resp2, requestErr2 := http.Get(api2)
  38157. // if requestErr2 != nil {
  38158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38159. // return
  38160. // }
  38161. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  38162. // if ioErr2 != nil {
  38163. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  38164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38165. // return
  38166. // }
  38167. // var respJSON2 map[string]interface{}
  38168. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  38169. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38171. // return
  38172. // }
  38173. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38174. // userJSONBytes2, _ := json.Marshal(respJSON2)
  38175. //
  38176. // var res2 ResultSix
  38177. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38178. // utils.ErrorLog("解析失败:%v", err)
  38179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38180. // return
  38181. // }
  38182. // if res2.Infcode != 0 {
  38183. // adminUser := c.GetAdminUserInfo()
  38184. // errlog := &models.HisOrderError{
  38185. // UserOrgId: adminUser.CurrentOrgId,
  38186. // Ctime: time.Now().Unix(),
  38187. // Mtime: time.Now().Unix(),
  38188. // ErrMsg: res2.ErrMsg,
  38189. // Status: 1,
  38190. // PatientId: id,
  38191. // RecordTime: recordDateTime,
  38192. // Stage: 3,
  38193. // }
  38194. // service.CreateErrMsgLog(errlog)
  38195. //
  38196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  38197. // return
  38198. // }
  38199. //
  38200. // c.ServeSuccessJSON(map[string]interface{}{
  38201. // "msg": "上传成功",
  38202. // })
  38203. //
  38204. //}
  38205. type QueryResult struct {
  38206. ID int64
  38207. Name string
  38208. Code string
  38209. List_type_code string
  38210. }
  38211. func (c *HisApiController) GetCheckCode() {
  38212. ids_str := c.GetString("ids")
  38213. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38214. ids_arr := strings.Split(ids_str, ",")
  38215. var queryResult []QueryResult
  38216. ids := make([]int64, 0)
  38217. for _, item := range ids_arr {
  38218. id, _ := strconv.ParseInt(item, 10, 64)
  38219. ids = append(ids, id)
  38220. }
  38221. if record_type == 1 {
  38222. drugs, _ := service.GetBatchDrugList(ids)
  38223. for _, item := range drugs {
  38224. result := QueryResult{
  38225. ID: item.ID,
  38226. Name: item.DrugName,
  38227. Code: item.MedicalInsuranceNumber,
  38228. List_type_code: "101",
  38229. }
  38230. queryResult = append(queryResult, result)
  38231. }
  38232. } else if record_type == 2 {
  38233. goods, _ := service.GetBatchGoodInformationList(ids)
  38234. fmt.Println(goods)
  38235. for _, item := range goods {
  38236. result := QueryResult{
  38237. ID: item.ID,
  38238. Name: item.GoodName,
  38239. Code: item.SocialSecurityDirectoryCode,
  38240. List_type_code: "301",
  38241. }
  38242. queryResult = append(queryResult, result)
  38243. }
  38244. } else if record_type == 3 {
  38245. projects, _ := service.GetBathchMyPorjecgList(ids)
  38246. for _, item := range projects {
  38247. result := QueryResult{
  38248. ID: item.ID,
  38249. Name: item.ProjectName,
  38250. Code: item.MedicalCode,
  38251. List_type_code: "201",
  38252. }
  38253. queryResult = append(queryResult, result)
  38254. }
  38255. }
  38256. admin_user_id, _ := c.GetInt64("admin_user_id")
  38257. adminUser := c.GetAdminUserInfo()
  38258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38259. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38260. var user_name string
  38261. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38262. if role.ID == 0 {
  38263. user_name = "管理员"
  38264. } else {
  38265. user_name = role.UserName
  38266. }
  38267. baseParams := models.BaseParams{
  38268. SecretKey: miConfig.SecretKey,
  38269. FixmedinsCode: miConfig.Code,
  38270. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38271. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38272. OrgName: miConfig.OrgName,
  38273. Doctor: user_name,
  38274. }
  38275. var result string
  38276. if miConfig.MdtrtareaAdmvs == "430800" {
  38277. for _, item := range queryResult {
  38278. if record_type == 1 {
  38279. 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)
  38280. } else if record_type == 2 {
  38281. fmt.Println(item.Code)
  38282. 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)
  38283. } else if record_type == 3 {
  38284. 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)
  38285. }
  38286. var dat map[string]interface{}
  38287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38288. fmt.Println(dat)
  38289. } else {
  38290. fmt.Println(err)
  38291. }
  38292. userJSONBytes, _ := json.Marshal(dat)
  38293. var res ResultSix
  38294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38295. utils.ErrorLog("解析失败:%v", err)
  38296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38297. return
  38298. }
  38299. if res.Infcode == 0 {
  38300. if record_type == 1 {
  38301. service.UpdateBaseDrugById(item.ID)
  38302. } else if record_type == 2 {
  38303. service.UpdateGoodInformaitonByDetail(item.ID)
  38304. } else if record_type == 3 {
  38305. service.UpdateProjectById(item.ID)
  38306. }
  38307. c.ServeSuccessJSON(map[string]interface{}{
  38308. "failed_code": 0,
  38309. "msg": "目录对照成功",
  38310. })
  38311. } else {
  38312. c.ServeSuccessJSON(map[string]interface{}{
  38313. "failed_code": -10,
  38314. "msg": res.ErrMsg,
  38315. })
  38316. }
  38317. }
  38318. } else {
  38319. for _, item := range queryResult {
  38320. var result string
  38321. if record_type == 1 {
  38322. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38323. } else if record_type == 2 {
  38324. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38325. } else if record_type == 3 {
  38326. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38327. }
  38328. var dat map[string]interface{}
  38329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38330. fmt.Println(dat)
  38331. } else {
  38332. fmt.Println(err)
  38333. }
  38334. userJSONBytes, _ := json.Marshal(dat)
  38335. var res ResultSix
  38336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38337. utils.ErrorLog("解析失败:%v", err)
  38338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38339. return
  38340. }
  38341. if res.Infcode == 0 {
  38342. if record_type == 1 {
  38343. service.UpdateBaseDrugById(item.ID)
  38344. } else if record_type == 2 {
  38345. service.UpdateGoodInformaitonByDetail(item.ID)
  38346. } else if record_type == 3 {
  38347. service.UpdateProjectById(item.ID)
  38348. }
  38349. c.ServeSuccessJSON(map[string]interface{}{
  38350. "failed_code": 0,
  38351. "msg": "目录对照成功",
  38352. })
  38353. } else {
  38354. c.ServeSuccessJSON(map[string]interface{}{
  38355. "failed_code": -10,
  38356. "msg": res.ErrMsg,
  38357. })
  38358. }
  38359. }
  38360. }
  38361. }
  38362. func (c *HisApiController) UnCheckCode() {
  38363. ids_str := c.GetString("ids")
  38364. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38365. admin_user_id, _ := c.GetInt64("admin_user_id")
  38366. ids_arr := strings.Split(ids_str, ",")
  38367. var queryResult []QueryResult
  38368. ids := make([]int64, 0)
  38369. for _, item := range ids_arr {
  38370. id, _ := strconv.ParseInt(item, 10, 64)
  38371. ids = append(ids, id)
  38372. }
  38373. if record_type == 1 {
  38374. drugs, _ := service.GetBatchDrugList(ids)
  38375. for _, item := range drugs {
  38376. result := QueryResult{
  38377. ID: item.ID,
  38378. Name: item.DrugName,
  38379. Code: item.MedicalInsuranceNumber,
  38380. List_type_code: "101",
  38381. }
  38382. queryResult = append(queryResult, result)
  38383. }
  38384. } else if record_type == 2 {
  38385. goods, _ := service.GetBatchGoodInformationList(ids)
  38386. for _, item := range goods {
  38387. result := QueryResult{
  38388. ID: item.ID,
  38389. Name: item.GoodName,
  38390. Code: item.SocialSecurityDirectoryCode,
  38391. List_type_code: "301",
  38392. }
  38393. queryResult = append(queryResult, result)
  38394. }
  38395. } else if record_type == 3 {
  38396. projects, _ := service.GetBathchMyPorjecgList(ids)
  38397. for _, item := range projects {
  38398. result := QueryResult{
  38399. ID: item.ID,
  38400. Name: item.ProjectName,
  38401. Code: item.MedicalCode,
  38402. List_type_code: "201",
  38403. }
  38404. queryResult = append(queryResult, result)
  38405. }
  38406. }
  38407. adminUser := c.GetAdminUserInfo()
  38408. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38409. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38410. var user_name string
  38411. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38412. if role.ID == 0 {
  38413. user_name = "xxx"
  38414. } else {
  38415. user_name = role.UserName
  38416. }
  38417. baseParams := &models.BaseParams{
  38418. SecretKey: miConfig.SecretKey,
  38419. FixmedinsCode: miConfig.Code,
  38420. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38421. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38422. OrgName: miConfig.OrgName,
  38423. Doctor: user_name,
  38424. }
  38425. if config.IsOpen == 1 {
  38426. if miConfig.MdtrtareaAdmvs == "430800" {
  38427. for _, item := range queryResult {
  38428. var result string
  38429. if record_type == 1 {
  38430. 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)
  38431. } else if record_type == 2 {
  38432. fmt.Println(item.Code)
  38433. 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)
  38434. } else if record_type == 3 {
  38435. 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)
  38436. }
  38437. var dat map[string]interface{}
  38438. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38439. fmt.Println(dat)
  38440. } else {
  38441. fmt.Println(err)
  38442. }
  38443. userJSONBytes, _ := json.Marshal(dat)
  38444. var res ResultSix
  38445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38446. utils.ErrorLog("解析失败:%v", err)
  38447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38448. return
  38449. }
  38450. if res.Infcode == 0 {
  38451. if record_type == 1 {
  38452. service.UpdateBaseDrugById(item.ID)
  38453. } else if record_type == 2 {
  38454. service.UpdateGoodInformaitonByDetail(item.ID)
  38455. } else if record_type == 3 {
  38456. service.UpdateProjectById(item.ID)
  38457. }
  38458. c.ServeSuccessJSON(map[string]interface{}{
  38459. "failed_code": 0,
  38460. "msg": "目录对照成功",
  38461. })
  38462. } else {
  38463. c.ServeSuccessJSON(map[string]interface{}{
  38464. "failed_code": -10,
  38465. "msg": res.ErrMsg,
  38466. })
  38467. }
  38468. }
  38469. } else {
  38470. for _, item := range queryResult {
  38471. var result string
  38472. if record_type == 1 {
  38473. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38474. } else if record_type == 2 {
  38475. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38476. } else if record_type == 3 {
  38477. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38478. }
  38479. var dat2 map[string]interface{}
  38480. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38481. fmt.Println(dat2)
  38482. } else {
  38483. fmt.Println(err)
  38484. }
  38485. userJSONBytes, _ := json.Marshal(dat2)
  38486. var res ResultSix
  38487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38488. utils.ErrorLog("解析失败:%v", err)
  38489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38490. return
  38491. }
  38492. if res.Infcode == 0 {
  38493. if record_type == 1 {
  38494. service.UpdateDrugByIdDetail(item.ID)
  38495. } else if record_type == 2 {
  38496. service.UpdateGoodInfoById(item.ID)
  38497. } else if record_type == 3 {
  38498. service.UpdateMyProjectById(item.ID)
  38499. }
  38500. c.ServeSuccessJSON(map[string]interface{}{
  38501. "failed_code": 0,
  38502. "msg": "撤销目录对照成功",
  38503. })
  38504. } else {
  38505. c.ServeSuccessJSON(map[string]interface{}{
  38506. "failed_code": -10,
  38507. "msg": res.ErrMsg,
  38508. })
  38509. }
  38510. }
  38511. }
  38512. }
  38513. }
  38514. func (c *HisApiController) GetPatientInfo() {
  38515. id_card_no := c.GetString("id_card_no")
  38516. admin_user_id, _ := c.GetInt64("admin_user_id")
  38517. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38518. if patient.ID == 0 {
  38519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38520. return
  38521. }
  38522. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38523. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38524. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38525. var res ResultTwo
  38526. var res10265 ResultTwo10265
  38527. if config.IsOpen == 1 {
  38528. if miConfig.MdtrtareaAdmvs == "150404" {
  38529. //请求内网数据
  38530. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38531. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38532. "&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
  38533. resp, requestErr := http.Get(api)
  38534. if requestErr != nil {
  38535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38536. return
  38537. }
  38538. body, ioErr := ioutil.ReadAll(resp.Body)
  38539. if ioErr != nil {
  38540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38542. return
  38543. }
  38544. var respJSON map[string]interface{}
  38545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38548. return
  38549. }
  38550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38551. result_byte, _ := json.Marshal(respJSON)
  38552. result := string(result_byte)
  38553. var dat map[string]interface{}
  38554. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38555. fmt.Println(dat)
  38556. } else {
  38557. fmt.Println(err)
  38558. }
  38559. userJSONBytes, _ := json.Marshal(dat)
  38560. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38561. utils.ErrorLog("解析失败:%v", err)
  38562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38563. return
  38564. }
  38565. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38566. res.Infcode = Infcode
  38567. res.ErrMsg = res10265.ErrMsg
  38568. res.Output = res10265.Output
  38569. res.InfRefmsgid = res10265.InfRefmsgid
  38570. res.RespondTime = res10265.RespondTime
  38571. res.WarnInfo = res10265.WarnInfo
  38572. } else {
  38573. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38574. var dat map[string]interface{}
  38575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38576. fmt.Println(dat)
  38577. } else {
  38578. fmt.Println(err)
  38579. }
  38580. userJSONBytes, _ := json.Marshal(dat)
  38581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38582. utils.ErrorLog("解析失败:%v", err)
  38583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38584. return
  38585. }
  38586. }
  38587. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38588. // utils.ErrorLog("解析失败:%v", err)
  38589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38590. // return
  38591. //}
  38592. for index, item := range res.Output.Iinfo {
  38593. if item.PsnInsuStas == "2" {
  38594. fmt.Println("--------")
  38595. res.Output.Iinfo[index].Insutype = "300"
  38596. res.Output.Iinfo[index].PsnInsuStas = "1"
  38597. }
  38598. }
  38599. fmt.Println(res.Output.Iinfo)
  38600. if res.Infcode != 0 {
  38601. c.ServeSuccessJSON(map[string]interface{}{
  38602. "failed_code": -10,
  38603. "msg": res.ErrMsg,
  38604. })
  38605. } else {
  38606. c.ServeSuccessJSON(map[string]interface{}{
  38607. "failed_code": 0,
  38608. "info": res,
  38609. })
  38610. }
  38611. }
  38612. }
  38613. func (c *HisApiController) PsnPutOnRecord() {
  38614. record_type, _ := c.GetInt64("type")
  38615. patient_id, _ := c.GetInt64("patient_id")
  38616. admin_user_id, _ := c.GetInt64("admin_user_id")
  38617. start_time := c.GetString("start_time")
  38618. end_time := c.GetString("end_time")
  38619. adminUser := c.GetAdminUserInfo()
  38620. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38621. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38622. var patients []*models.Patients
  38623. if record_type == 1 { //全部备案
  38624. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38625. patients = append(patients, patient...)
  38626. } else { //单个备案
  38627. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38628. patients = append(patients, patient)
  38629. }
  38630. var user_name string
  38631. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38632. if role.ID == 0 {
  38633. user_name = "xxx"
  38634. } else {
  38635. user_name = role.UserName
  38636. }
  38637. if config.IsOpen == 1 {
  38638. for _, item := range patients {
  38639. 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
  38640. resp, requestErr := http.Get(api)
  38641. if requestErr != nil {
  38642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38643. return
  38644. }
  38645. defer resp.Body.Close()
  38646. body, ioErr := ioutil.ReadAll(resp.Body)
  38647. if ioErr != nil {
  38648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38650. return
  38651. }
  38652. var respJSON map[string]interface{}
  38653. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38656. return
  38657. }
  38658. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38659. userJSONBytes, _ := json.Marshal(userJSON)
  38660. var res ResultTwo
  38661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38662. utils.ErrorLog("解析失败:%v", err)
  38663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38664. return
  38665. }
  38666. if res.Infcode == 0 {
  38667. 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)
  38668. var dat map[string]interface{}
  38669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38670. fmt.Println(dat)
  38671. } else {
  38672. fmt.Println(err)
  38673. }
  38674. userJSONBytes, _ := json.Marshal(dat)
  38675. var res2 ResultThirteen
  38676. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38677. utils.ErrorLog("解析失败:%v", err)
  38678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38679. return
  38680. }
  38681. if res2.Infcode == 0 {
  38682. psnResult := &models.GdybPsnRecord{
  38683. UserOrgId: adminUser.CurrentOrgId,
  38684. PatientId: item.ID,
  38685. PsnNo: res.Output.Baseinfo.PsnNo,
  38686. Ctime: time.Now().Unix(),
  38687. Mtime: time.Now().Unix(),
  38688. Status: 1,
  38689. IsCancel: 1,
  38690. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38691. }
  38692. service.CreatePsnRecord(psnResult)
  38693. } else {
  38694. c.ServeSuccessJSON(map[string]interface{}{
  38695. "failed_code": -10,
  38696. "msg": res2.ErrMsg,
  38697. })
  38698. return
  38699. }
  38700. }
  38701. }
  38702. }
  38703. }
  38704. func (c *HisApiController) PsnUnPutOnRecord() {
  38705. id, _ := c.GetInt64("id")
  38706. //record_type, _ := c.GetInt64("type")
  38707. admin_user_id, _ := c.GetInt64("admin_user_id")
  38708. adminUser := c.GetAdminUserInfo()
  38709. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38710. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38711. var user_name string
  38712. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38713. if role.ID == 0 {
  38714. user_name = "xxx"
  38715. } else {
  38716. user_name = role.UserName
  38717. }
  38718. psn_record, _ := service.GetPsnRecordById(id)
  38719. if psn_record.ID == 0 {
  38720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38721. return
  38722. }
  38723. if config.IsOpen == 1 {
  38724. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38725. var dat map[string]interface{}
  38726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38727. fmt.Println(dat)
  38728. } else {
  38729. fmt.Println(err)
  38730. }
  38731. userJSONBytes, _ := json.Marshal(dat)
  38732. var res ResultFourteen
  38733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38734. utils.ErrorLog("解析失败:%v", err)
  38735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38736. return
  38737. }
  38738. if res.Infcode == 0 {
  38739. psn_record.IsCancel = 2
  38740. service.CreatePsnRecord(&psn_record)
  38741. } else {
  38742. c.ServeSuccessJSON(map[string]interface{}{
  38743. "failed_code": -10,
  38744. "msg": res.ErrMsg,
  38745. })
  38746. return
  38747. }
  38748. }
  38749. }
  38750. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38751. patient_id, _ := c.GetInt64("patient_id")
  38752. insutype_two := c.GetString("insutype")
  38753. psn_no := c.GetString("psn_no")
  38754. doctor_id, _ := c.GetInt64("doctor_id")
  38755. sick_id, _ := c.GetInt64("sick_id")
  38756. department_id, _ := c.GetInt64("department_id")
  38757. start_time := c.GetString("start_time")
  38758. end_time := c.GetString("end_time")
  38759. check_time := c.GetString("check_time")
  38760. hospital_code := c.GetString("hospital_code")
  38761. hospital_name := c.GetString("hospital_name")
  38762. adminUser := c.GetAdminUserInfo()
  38763. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38764. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38765. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38766. sick, _ := service.FindSickById(sick_id)
  38767. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38768. if len(hospital_code) == 0 {
  38769. hospital_code = miConfig.Code
  38770. }
  38771. if len(hospital_name) == 0 {
  38772. hospital_name = miConfig.OrgName
  38773. }
  38774. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38775. var res ResultTwo
  38776. var res10265 ResultTwo10265
  38777. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38778. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38779. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38780. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38781. "&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
  38782. resp, requestErr := http.Get(api)
  38783. if requestErr != nil {
  38784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38785. return
  38786. }
  38787. body, ioErr := ioutil.ReadAll(resp.Body)
  38788. if ioErr != nil {
  38789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38791. return
  38792. }
  38793. var respJSON map[string]interface{}
  38794. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38797. return
  38798. }
  38799. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38800. result, _ := json.Marshal(respJSON)
  38801. fmt.Println("log")
  38802. fmt.Println(string(result))
  38803. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38804. utils.ErrorLog("解析失败:%v", err)
  38805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38806. return
  38807. }
  38808. res.ErrMsg = res10265.ErrMsg
  38809. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38810. res.Infcode = infocode
  38811. res.Output = res10265.Output
  38812. res.InfRefmsgid = res10265.InfRefmsgid
  38813. } else {
  38814. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38815. if miConfig.Code == "H15049901371" {
  38816. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38817. utils.ErrorLog("解析失败:%v", err)
  38818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38819. return
  38820. }
  38821. res.ErrMsg = res10265.ErrMsg
  38822. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38823. res.Infcode = infocode
  38824. res.Output = res10265.Output
  38825. res.InfRefmsgid = res10265.InfRefmsgid
  38826. } else {
  38827. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38828. utils.ErrorLog("解析失败:%v", err)
  38829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38830. return
  38831. }
  38832. }
  38833. }
  38834. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38835. infoStr := string(Iinfos)
  38836. var rf []*ResultFive
  38837. json.Unmarshal([]byte(infoStr), &rf)
  38838. var insuplc_admdvs string
  38839. var insutype string
  38840. var is390 int = 0
  38841. var is310 int = 0
  38842. var insutypes []*ResultFive
  38843. for _, item := range rf {
  38844. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38845. insutypes = append(insutypes, item)
  38846. }
  38847. }
  38848. if len(insutypes) == 1 {
  38849. insutype = insutypes[0].Insutype
  38850. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38851. } else {
  38852. for _, i := range insutypes {
  38853. if i.Insutype == "390" {
  38854. is390 = 1
  38855. }
  38856. if i.Insutype == "310" {
  38857. is310 = 1
  38858. }
  38859. }
  38860. }
  38861. if is390 == 1 {
  38862. insutype = "390"
  38863. }
  38864. if is310 == 1 {
  38865. insutype = "310"
  38866. }
  38867. if len(insutypes) == 2 {
  38868. insutype = insutype_two
  38869. }
  38870. if len(insutypes) == 0 {
  38871. insutype = "310"
  38872. }
  38873. insutype = insutype_two
  38874. fmt.Println(insutype)
  38875. for _, item := range rf {
  38876. fmt.Println(item.Insutype)
  38877. fmt.Println(insutype)
  38878. if item.Insutype == insutype {
  38879. fmt.Println(item.Insutype)
  38880. fmt.Println(insutype)
  38881. insuplc_admdvs = item.InsuplcAdmdvs
  38882. }
  38883. }
  38884. fmt.Println(insuplc_admdvs)
  38885. var res2 ResultThirteen
  38886. var res10265_2 ResultThirteen10265
  38887. if config.IsOpen == 1 {
  38888. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38889. } else {
  38890. if miConfig.MdtrtareaAdmvs == "150404" {
  38891. //
  38892. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38893. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38894. // "&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
  38895. //resp, requestErr := http.Get(api)
  38896. //if requestErr != nil {
  38897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38898. // return
  38899. //}
  38900. //
  38901. //body, ioErr := ioutil.ReadAll(resp.Body)
  38902. //if ioErr != nil {
  38903. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38905. // return
  38906. //}
  38907. //var respJSON map[string]interface{}
  38908. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38909. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38911. // return
  38912. //}
  38913. //
  38914. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38915. //result, _ := json.Marshal(respJSON)
  38916. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38917. // utils.ErrorLog("解析失败:%v", err)
  38918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38919. // return
  38920. //}
  38921. //infocode = resThree.Infcode
  38922. //result, _ := json.Marshal(respJSON)
  38923. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38924. // utils.ErrorLog("解析失败:%v", err)
  38925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38926. // return
  38927. //}
  38928. //
  38929. //resThree.ErrMsg = resThree10265.ErrMsg
  38930. //
  38931. //resThree.Output = resThree10265.Output
  38932. //
  38933. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38934. //
  38935. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38936. //
  38937. } else {
  38938. 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)
  38939. var dat map[string]interface{}
  38940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38941. fmt.Println(dat)
  38942. } else {
  38943. fmt.Println(err)
  38944. }
  38945. userJSONBytes, _ := json.Marshal(dat)
  38946. if miConfig.Code == "H15049901371" {
  38947. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38948. utils.ErrorLog("解析失败:%v", err)
  38949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38950. return
  38951. }
  38952. res2.ErrMsg = res10265_2.ErrMsg
  38953. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38954. res2.Infcode = infocode
  38955. res2.Output = res10265_2.Output
  38956. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38957. } else {
  38958. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38959. utils.ErrorLog("解析失败:%v", err)
  38960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38961. return
  38962. }
  38963. }
  38964. }
  38965. }
  38966. if res2.Infcode == 0 {
  38967. psnResult := &models.GdybPsnNcdsRecord{
  38968. UserOrgId: adminUser.CurrentOrgId,
  38969. PatientId: patient.ID,
  38970. PsnNo: psn_no,
  38971. DoctorId: doctor.AdminUserId,
  38972. DepartmentId: department_id,
  38973. SickType: sick_id,
  38974. Insutype: insutype,
  38975. Ctime: time.Now().Unix(),
  38976. Mtime: time.Now().Unix(),
  38977. Status: 1,
  38978. IsCancel: 1,
  38979. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38980. }
  38981. service.CreatePsnNCDSRecord(psnResult)
  38982. c.ServeSuccessJSON(map[string]interface{}{
  38983. "failed_code": 0,
  38984. "msg": "备案成功",
  38985. "result": psnResult,
  38986. })
  38987. } else {
  38988. c.ServeSuccessJSON(map[string]interface{}{
  38989. "failed_code": -10,
  38990. "msg": res2.ErrMsg,
  38991. })
  38992. return
  38993. }
  38994. }
  38995. }
  38996. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38997. id, _ := c.GetInt64("id")
  38998. admin_user_id, _ := c.GetInt64("admin_user_id")
  38999. adminUser := c.GetAdminUserInfo()
  39000. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39001. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39002. //config, _ := service.Ge(adminUser.CurrentOrgId)
  39003. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  39004. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39005. //var user_name string
  39006. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39007. //if role.ID == 0 {
  39008. // user_name = "xxx"
  39009. //} else {
  39010. // user_name = role.UserName
  39011. //}
  39012. psn_record, _ := service.GetPsnNCDSRecordById(id)
  39013. if psn_record.ID == 0 {
  39014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  39015. return
  39016. }
  39017. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  39018. var res ResultTwo
  39019. var res10265 ResultTwo10265
  39020. if miConfig.Code == "H15049901371" {
  39021. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39022. utils.ErrorLog("解析失败:%v", err)
  39023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39024. return
  39025. }
  39026. res.ErrMsg = res10265.ErrMsg
  39027. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39028. res.Infcode = infocode
  39029. res.Output = res10265.Output
  39030. res.InfRefmsgid = res10265.InfRefmsgid
  39031. } else {
  39032. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39033. utils.ErrorLog("解析失败:%v", err)
  39034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39035. return
  39036. }
  39037. }
  39038. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39039. infoStr := string(Iinfos)
  39040. var rf []*ResultFive
  39041. json.Unmarshal([]byte(infoStr), &rf)
  39042. var insuplc_admdvs string
  39043. var insutype string
  39044. var is390 int = 0
  39045. var is310 int = 0
  39046. var insutypes []*ResultFive
  39047. for _, item := range rf {
  39048. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  39049. insutypes = append(insutypes, item)
  39050. }
  39051. }
  39052. if len(insutypes) == 1 {
  39053. insutype = insutypes[0].Insutype
  39054. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  39055. } else {
  39056. for _, i := range insutypes {
  39057. if i.Insutype == "390" {
  39058. is390 = 1
  39059. }
  39060. if i.Insutype == "310" {
  39061. is310 = 1
  39062. }
  39063. }
  39064. }
  39065. if is390 == 1 {
  39066. insutype = "390"
  39067. }
  39068. if is310 == 1 {
  39069. insutype = "310"
  39070. }
  39071. if len(insutypes) == 0 {
  39072. insutype = "310"
  39073. }
  39074. insutype = psn_record.Insutype
  39075. for _, item := range rf {
  39076. if item.Insutype == insutype {
  39077. insuplc_admdvs = item.InsuplcAdmdvs
  39078. }
  39079. }
  39080. if config.IsOpen == 1 {
  39081. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  39082. var dat map[string]interface{}
  39083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39084. fmt.Println(dat)
  39085. } else {
  39086. fmt.Println(err)
  39087. }
  39088. userJSONBytes, _ := json.Marshal(dat)
  39089. var res ResultFourteen
  39090. var res10265 ResultFourteen10265
  39091. if miConfig.Code == "H15049901371" {
  39092. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  39093. utils.ErrorLog("解析失败:%v", err)
  39094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39095. return
  39096. }
  39097. res.ErrMsg = res10265.ErrMsg
  39098. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39099. res.Infcode = infocode
  39100. res.Output = res10265.Output
  39101. res.InfRefmsgid = res10265.InfRefmsgid
  39102. } else {
  39103. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39104. utils.ErrorLog("解析失败:%v", err)
  39105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39106. return
  39107. }
  39108. }
  39109. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39110. // utils.ErrorLog("解析失败:%v", err)
  39111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39112. // return
  39113. //}
  39114. if res.Infcode == 0 {
  39115. psn_record.IsCancel = 2
  39116. service.CreatePsnNCDSRecord(&psn_record)
  39117. c.ServeSuccessJSON(map[string]interface{}{
  39118. "failed_code": 0,
  39119. "msg": "撤销备案成功",
  39120. })
  39121. } else {
  39122. c.ServeSuccessJSON(map[string]interface{}{
  39123. "failed_code": -10,
  39124. "msg": res.ErrMsg,
  39125. })
  39126. return
  39127. }
  39128. }
  39129. }
  39130. func (c *HisApiController) TestTest() {
  39131. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  39132. fmt.Println(patient.Iinfo)
  39133. }
  39134. type CustomData struct {
  39135. MsgId string
  39136. PsnNo string
  39137. Info string
  39138. }
  39139. func (c *HisApiController) ReversalData() {
  39140. var customData []*CustomData
  39141. custom := &CustomData{
  39142. MsgId: "H44022900158202103301714472004",
  39143. PsnNo: "44020000001101329945",
  39144. Info: "2207",
  39145. }
  39146. customData = append(customData, custom)
  39147. custom1 := &CustomData{
  39148. MsgId: "H4402290015820210330172057803",
  39149. PsnNo: "44020000001101161813",
  39150. Info: "2207",
  39151. }
  39152. customData = append(customData, custom1)
  39153. custom2 := &CustomData{
  39154. MsgId: "H44022900158202103301705198813",
  39155. PsnNo: "44190000133097375417",
  39156. Info: "2207",
  39157. }
  39158. customData = append(customData, custom2)
  39159. custom3 := &CustomData{
  39160. MsgId: "H44022900158202103301715524756",
  39161. PsnNo: "44020000001100187221",
  39162. Info: "2207",
  39163. }
  39164. customData = append(customData, custom3)
  39165. custom4 := &CustomData{
  39166. MsgId: "H44022900158202103301730376224",
  39167. PsnNo: "44020000001101959155",
  39168. Info: "2207",
  39169. }
  39170. customData = append(customData, custom4)
  39171. custom5 := &CustomData{
  39172. MsgId: "H44022900158202103301748008725",
  39173. PsnNo: "44020000001104246641",
  39174. Info: "2207",
  39175. }
  39176. customData = append(customData, custom5)
  39177. custom6 := &CustomData{
  39178. MsgId: "H44022900158202103301718096755",
  39179. PsnNo: "44020000001102211860",
  39180. Info: "2207",
  39181. }
  39182. customData = append(customData, custom6)
  39183. custom7 := &CustomData{
  39184. MsgId: "H44022900158202103301736551640",
  39185. PsnNo: "44020000001102687718",
  39186. Info: "2207",
  39187. }
  39188. customData = append(customData, custom7)
  39189. custom8 := &CustomData{
  39190. MsgId: "H44022900158202103301743097676",
  39191. PsnNo: "44020000001102127785",
  39192. Info: "2207",
  39193. }
  39194. customData = append(customData, custom8)
  39195. custom9 := &CustomData{
  39196. MsgId: "H44022900158202103301712304203",
  39197. PsnNo: "44020000001101518097",
  39198. Info: "2207",
  39199. }
  39200. customData = append(customData, custom9)
  39201. custom10 := &CustomData{
  39202. MsgId: "H44022900158202103301738448785",
  39203. PsnNo: "44020000001100500813",
  39204. Info: "2207",
  39205. }
  39206. customData = append(customData, custom10)
  39207. custom11 := &CustomData{
  39208. MsgId: "H44022900158202103301732455843",
  39209. PsnNo: "44020000001102690557",
  39210. Info: "2207",
  39211. }
  39212. customData = append(customData, custom11)
  39213. custom12 := &CustomData{
  39214. MsgId: "H44022900158202103301745421708",
  39215. PsnNo: "44020000001102211928",
  39216. Info: "2207",
  39217. }
  39218. customData = append(customData, custom12)
  39219. custom1212 := &CustomData{
  39220. MsgId: "H440229001582021033017351627",
  39221. PsnNo: "44020000001102481733",
  39222. Info: "2207",
  39223. }
  39224. customData = append(customData, custom1212)
  39225. custom13 := &CustomData{
  39226. MsgId: "H44022900158202103301740327951",
  39227. PsnNo: "44020000001103174866",
  39228. Info: "2207",
  39229. }
  39230. customData = append(customData, custom13)
  39231. custom14 := &CustomData{
  39232. MsgId: "H4402290015820210330174922668",
  39233. PsnNo: "44020000001102927272",
  39234. Info: "2207",
  39235. }
  39236. customData = append(customData, custom14)
  39237. custom15 := &CustomData{
  39238. MsgId: "H44022900158202103301752362273",
  39239. PsnNo: "44020000001102942890",
  39240. Info: "2207",
  39241. }
  39242. customData = append(customData, custom15)
  39243. custom16 := &CustomData{
  39244. MsgId: "H44022900158202103301751082917",
  39245. PsnNo: "44020000001101662162",
  39246. Info: "2207",
  39247. }
  39248. customData = append(customData, custom16)
  39249. custom17 := &CustomData{
  39250. MsgId: "H44022900158202103301754147728",
  39251. PsnNo: "44020000000229014511",
  39252. Info: "2207",
  39253. }
  39254. customData = append(customData, custom17)
  39255. adminUser := c.GetAdminUserInfo()
  39256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39257. for _, item := range customData {
  39258. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39259. fmt.Println(result)
  39260. }
  39261. }
  39262. func (c *HisApiController) GetAllopatry() {
  39263. year := c.GetString("year")
  39264. month := c.GetString("month")
  39265. admin_user_id, _ := c.GetInt64("admin_user_id")
  39266. adminUser := c.GetAdminUserInfo()
  39267. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39268. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39269. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39270. var dat map[string]interface{}
  39271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39272. fmt.Println(dat)
  39273. } else {
  39274. fmt.Println(err)
  39275. }
  39276. userJSONBytes, _ := json.Marshal(dat)
  39277. var res models.Result9001
  39278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39279. utils.ErrorLog("解析失败:%v", err)
  39280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39281. return
  39282. }
  39283. fmt.Println(res.Output.Signinoutb)
  39284. fmt.Println(res.Output.Signinoutb.SignNo)
  39285. fmt.Println(string(userJSONBytes))
  39286. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39287. var dat3 map[string]interface{}
  39288. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  39289. fmt.Println(dat3)
  39290. } else {
  39291. fmt.Println(err)
  39292. }
  39293. userJSONBytes3, _ := json.Marshal(dat3)
  39294. var res3 models.Result3260
  39295. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  39296. utils.ErrorLog("解析失败:%v", err)
  39297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39298. return
  39299. }
  39300. var curpage int
  39301. var pagesize int = 100
  39302. var start int = 1
  39303. //var stop int
  39304. //pagecount := 10
  39305. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  39306. var res22 []models.Result3260
  39307. for curpage = 1; curpage <= pagecount; curpage++ {
  39308. if curpage == 1 {
  39309. start = 0
  39310. } else {
  39311. start = (curpage-1)*pagesize + 1
  39312. }
  39313. fmt.Println(start)
  39314. //stop = curpage * pagesize
  39315. //if stop > int(res3.Output.Totalrow) {
  39316. // stop =int(res3.Output.Totalrow)
  39317. //}
  39318. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  39319. var dat2 map[string]interface{}
  39320. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39321. fmt.Println(dat)
  39322. } else {
  39323. fmt.Println(err)
  39324. }
  39325. userJSONBytes2, _ := json.Marshal(dat2)
  39326. var res2 models.Result3260
  39327. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39328. utils.ErrorLog("解析失败:%v", err)
  39329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39330. return
  39331. }
  39332. if res2.Infcode == 0 {
  39333. res22 = append(res22, res2)
  39334. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39335. //var dat2 map[string]interface{}
  39336. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39337. // fmt.Println(dat)
  39338. //} else {
  39339. // fmt.Println(err)
  39340. //}
  39341. //c.ServeSuccessJSON(map[string]interface{}{
  39342. // "list": res2.Output.Data,
  39343. //})
  39344. //continue
  39345. }
  39346. }
  39347. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39348. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39349. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39350. //var dat2 map[string]interface{}
  39351. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39352. // fmt.Println(dat)
  39353. //} else {
  39354. // fmt.Println(err)
  39355. //}
  39356. //userJSONBytes2, _ := json.Marshal(dat2)
  39357. //var res2 models.Result3260
  39358. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39359. // utils.ErrorLog("解析失败:%v", err)
  39360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39361. // return
  39362. //}
  39363. //if res2.Infcode == 0 {
  39364. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39365. // var dat2 map[string]interface{}
  39366. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39367. // fmt.Println(dat)
  39368. // } else {
  39369. // fmt.Println(err)
  39370. // }
  39371. // c.ServeSuccessJSON(map[string]interface{}{
  39372. // "list": res2.Output.Data,
  39373. // })
  39374. //}
  39375. }
  39376. func (c *HisApiController) ComfirmAllopatry() {
  39377. year := c.GetString("year")
  39378. month := c.GetString("month")
  39379. admin_user_id, _ := c.GetInt64("admin_user_id")
  39380. adminUser := c.GetAdminUserInfo()
  39381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39382. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39383. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39384. var dat map[string]interface{}
  39385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39386. fmt.Println(dat)
  39387. } else {
  39388. fmt.Println(err)
  39389. }
  39390. userJSONBytes, _ := json.Marshal(dat)
  39391. var res models.Result9001
  39392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39393. utils.ErrorLog("解析失败:%v", err)
  39394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39395. return
  39396. }
  39397. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39398. var dat2 map[string]interface{}
  39399. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39400. fmt.Println(dat)
  39401. } else {
  39402. fmt.Println(err)
  39403. }
  39404. userJSONBytes2, _ := json.Marshal(dat2)
  39405. var res2 models.Result3260
  39406. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39407. utils.ErrorLog("解析失败:%v", err)
  39408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39409. return
  39410. }
  39411. //if res2.Infcode == 0 {
  39412. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39413. // var dat map[string]interface{}
  39414. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39415. // fmt.Println(dat)
  39416. // } else {
  39417. // fmt.Println(err)
  39418. // }
  39419. // userJSONBytes, _ := json.Marshal(dat)
  39420. // var res3 models.Result3261
  39421. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39422. // utils.ErrorLog("解析失败:%v", err)
  39423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39424. // return
  39425. // }
  39426. //
  39427. // if res3.Infcode == 0 {
  39428. // record := &models.HisYidiClearRecord{
  39429. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39430. // Ctime: time.Now().Unix(),
  39431. // Mtime: time.Now().Unix(),
  39432. // Status: 1,
  39433. // MsgId: msgId,
  39434. // }
  39435. // service.SaveClearRecord(record)
  39436. // c.ServeSuccessJSON(map[string]interface{}{
  39437. // "msg": "提取成功",
  39438. // })
  39439. // }
  39440. //}
  39441. }
  39442. func (c *HisApiController) RefundAllopatry() {
  39443. year := c.GetString("year")
  39444. month := c.GetString("month")
  39445. //id, _ := c.GetInt64("id")
  39446. admin_user_id, _ := c.GetInt64("admin_user_id")
  39447. adminUser := c.GetAdminUserInfo()
  39448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39449. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39450. //record, _ := service.GetClearRecordById(id)
  39451. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39452. var dat map[string]interface{}
  39453. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39454. fmt.Println(dat)
  39455. } else {
  39456. fmt.Println(err)
  39457. }
  39458. userJSONBytes, _ := json.Marshal(dat)
  39459. var res models.Result9001
  39460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39461. utils.ErrorLog("解析失败:%v", err)
  39462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39463. return
  39464. }
  39465. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39466. var dat2 map[string]interface{}
  39467. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39468. fmt.Println(dat)
  39469. } else {
  39470. fmt.Println(err)
  39471. }
  39472. userJSONBytes2, _ := json.Marshal(dat2)
  39473. var empty ResultFourteen
  39474. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39475. utils.ErrorLog("解析失败:%v", err)
  39476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39477. return
  39478. }
  39479. if empty.Infcode == 0 {
  39480. c.ServeSuccessJSON(map[string]interface{}{
  39481. "msg": "撤销成功",
  39482. })
  39483. return
  39484. }
  39485. }
  39486. func (c *HisApiController) ReversalOtherData() {
  39487. var customData []*CustomData
  39488. custom := &CustomData{
  39489. MsgId: "H44022900158202103301714472004",
  39490. PsnNo: "44020000001101329945",
  39491. Info: "2208",
  39492. }
  39493. customData = append(customData, custom)
  39494. custom1 := &CustomData{
  39495. MsgId: "H4402290015820210330172057803",
  39496. PsnNo: "44020000001101161813",
  39497. Info: "2208",
  39498. }
  39499. customData = append(customData, custom1)
  39500. custom2 := &CustomData{
  39501. MsgId: "H44022900158202103301705198813",
  39502. PsnNo: "44190000133097375417",
  39503. Info: "2208",
  39504. }
  39505. customData = append(customData, custom2)
  39506. custom3 := &CustomData{
  39507. MsgId: "H44022900158202103301715524756",
  39508. PsnNo: "44020000001100187221",
  39509. Info: "2208",
  39510. }
  39511. customData = append(customData, custom3)
  39512. custom4 := &CustomData{
  39513. MsgId: "H44022900158202103301730376224",
  39514. PsnNo: "44020000001101959155",
  39515. Info: "2208",
  39516. }
  39517. customData = append(customData, custom4)
  39518. custom5 := &CustomData{
  39519. MsgId: "H44022900158202103301748008725",
  39520. PsnNo: "44020000001104246641",
  39521. Info: "2208",
  39522. }
  39523. customData = append(customData, custom5)
  39524. custom6 := &CustomData{
  39525. MsgId: "H44022900158202103301718096755",
  39526. PsnNo: "44020000001102211860",
  39527. Info: "2208",
  39528. }
  39529. customData = append(customData, custom6)
  39530. custom7 := &CustomData{
  39531. MsgId: "H44022900158202103301736551640",
  39532. PsnNo: "44020000001102687718",
  39533. Info: "2208",
  39534. }
  39535. customData = append(customData, custom7)
  39536. custom8 := &CustomData{
  39537. MsgId: "H44022900158202103301743097676",
  39538. PsnNo: "44020000001102127785",
  39539. Info: "2208",
  39540. }
  39541. customData = append(customData, custom8)
  39542. custom9 := &CustomData{
  39543. MsgId: "H44022900158202103301712304203",
  39544. PsnNo: "44020000001101518097",
  39545. Info: "2208",
  39546. }
  39547. customData = append(customData, custom9)
  39548. custom10 := &CustomData{
  39549. MsgId: "H44022900158202103301738448785",
  39550. PsnNo: "44020000001100500813",
  39551. Info: "2208",
  39552. }
  39553. customData = append(customData, custom10)
  39554. custom11 := &CustomData{
  39555. MsgId: "H44022900158202103301732455843",
  39556. PsnNo: "44020000001102690557",
  39557. Info: "2208",
  39558. }
  39559. customData = append(customData, custom11)
  39560. custom12 := &CustomData{
  39561. MsgId: "H44022900158202103301745421708",
  39562. PsnNo: "44020000001102211928",
  39563. Info: "2208",
  39564. }
  39565. customData = append(customData, custom12)
  39566. custom1212 := &CustomData{
  39567. MsgId: "H440229001582021033017351627",
  39568. PsnNo: "44020000001102481733",
  39569. Info: "2208",
  39570. }
  39571. customData = append(customData, custom1212)
  39572. custom13 := &CustomData{
  39573. MsgId: "H44022900158202103301740327951",
  39574. PsnNo: "44020000001103174866",
  39575. Info: "2208",
  39576. }
  39577. customData = append(customData, custom13)
  39578. custom14 := &CustomData{
  39579. MsgId: "H4402290015820210330174922668",
  39580. PsnNo: "44020000001102927272",
  39581. Info: "2208",
  39582. }
  39583. customData = append(customData, custom14)
  39584. custom15 := &CustomData{
  39585. MsgId: "H44022900158202103301752362273",
  39586. PsnNo: "44020000001102942890",
  39587. Info: "2208",
  39588. }
  39589. customData = append(customData, custom15)
  39590. custom16 := &CustomData{
  39591. MsgId: "H44022900158202103301751082917",
  39592. PsnNo: "44020000001101662162",
  39593. Info: "2208",
  39594. }
  39595. customData = append(customData, custom16)
  39596. custom17 := &CustomData{
  39597. MsgId: "H44022900158202103301754147728",
  39598. PsnNo: "44020000000229014511",
  39599. Info: "2208",
  39600. }
  39601. customData = append(customData, custom17)
  39602. adminUser := c.GetAdminUserInfo()
  39603. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39604. for _, item := range customData {
  39605. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39606. fmt.Println(result)
  39607. }
  39608. }
  39609. func PathExists(path string) (bool, error) {
  39610. _, err := os.Stat(path)
  39611. if err == nil {
  39612. return true, nil
  39613. }
  39614. if os.IsNotExist(err) {
  39615. return false, nil
  39616. }
  39617. return false, err
  39618. }
  39619. // 创建文件夹
  39620. func Mkdir(dir string) {
  39621. // 创建文件夹
  39622. exist, err := PathExists(dir)
  39623. if err != nil {
  39624. fmt.Println(err.Error())
  39625. } else {
  39626. if exist {
  39627. fmt.Println(dir + "文件夹已存在!")
  39628. } else {
  39629. // 文件夹名称,权限
  39630. err := os.Mkdir(dir, os.ModePerm)
  39631. if err != nil {
  39632. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39633. } else {
  39634. fmt.Println(dir + "文件夹创建成功!")
  39635. }
  39636. }
  39637. }
  39638. }
  39639. // 压缩文件
  39640. func Zip(srcFile string, destZip string) error {
  39641. zipfile, err := os.Create(destZip)
  39642. if err != nil {
  39643. return err
  39644. }
  39645. defer zipfile.Close()
  39646. archive := zip.NewWriter(zipfile)
  39647. defer archive.Close()
  39648. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39649. if err != nil {
  39650. return err
  39651. }
  39652. header, err := zip.FileInfoHeader(info)
  39653. if err != nil {
  39654. return err
  39655. }
  39656. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39657. // header.Name = path
  39658. if info.IsDir() {
  39659. header.Name += "/"
  39660. } else {
  39661. header.Method = zip.Deflate
  39662. }
  39663. writer, err := archive.CreateHeader(header)
  39664. if err != nil {
  39665. return err
  39666. }
  39667. if !info.IsDir() {
  39668. file, err := os.Open(path)
  39669. if err != nil {
  39670. return err
  39671. }
  39672. defer file.Close()
  39673. _, err = io.Copy(writer, file)
  39674. }
  39675. return err
  39676. })
  39677. return err
  39678. }
  39679. func ReadFile(filePath string) []byte {
  39680. f, err := os.Open(filePath)
  39681. if err != nil {
  39682. fmt.Println("read file fail", err)
  39683. return nil
  39684. }
  39685. defer f.Close()
  39686. fd, err := ioutil.ReadAll(f)
  39687. if err != nil {
  39688. fmt.Println("read to fd fail", err)
  39689. return nil
  39690. }
  39691. return fd
  39692. }
  39693. func saveLogq(result string, request string, infno string, desc string) {
  39694. dir := "日志"
  39695. utils.Mkdir(dir)
  39696. month := time.Unix(1557042972, 0).Format("1")
  39697. year := time.Now().Format("2006")
  39698. month = time.Now().Format("01")
  39699. day := time.Now().Format("02")
  39700. hour := time.Now().Format("15")
  39701. min := time.Now().Format("04")
  39702. sec := time.Now().Format("05")
  39703. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39704. file := year + month + day + "_log"
  39705. file_name := file + ".txt"
  39706. file_path := "日志" + "/" + file_name
  39707. exist, _ := utils.PathExists(file_path)
  39708. if exist { //存在
  39709. fmt.Println("存在")
  39710. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39711. if err != nil {
  39712. fmt.Println("read fail")
  39713. }
  39714. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39715. n, _ := f.Seek(0, 2)
  39716. _, err = f.WriteAt([]byte(content), n)
  39717. } else { //不存在
  39718. fmt.Println("文件不存在,创建文件")
  39719. f, err := os.Create("日志" + "/" + file_name)
  39720. defer f.Close()
  39721. if err != nil {
  39722. } else {
  39723. _, err = f.Write([]byte("记录日志"))
  39724. }
  39725. }
  39726. }
  39727. func saveLog(result string, request string, infno string, desc string) {
  39728. org_id, _ := beego.AppConfig.Int64("org_id")
  39729. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39730. dir := miConfig.OrgName + "日志"
  39731. utils.Mkdir(dir)
  39732. month := time.Unix(1557042972, 0).Format("1")
  39733. year := time.Now().Format("2006")
  39734. month = time.Now().Format("01")
  39735. day := time.Now().Format("02")
  39736. hour := time.Now().Format("15")
  39737. min := time.Now().Format("04")
  39738. sec := time.Now().Format("05")
  39739. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39740. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39741. file_name := file + ".txt"
  39742. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39743. exist, _ := utils.PathExists(file_path)
  39744. if exist { //存在
  39745. fmt.Println("存在")
  39746. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39747. if err != nil {
  39748. fmt.Println("read fail")
  39749. }
  39750. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39751. n, _ := f.Seek(0, 2)
  39752. _, err = f.WriteAt([]byte(content), n)
  39753. } else { //不存在
  39754. fmt.Println("文件不存在,创建文件")
  39755. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39756. defer f.Close()
  39757. if err != nil {
  39758. } else {
  39759. _, err = f.Write([]byte("记录日志"))
  39760. }
  39761. }
  39762. }
  39763. type Charset string
  39764. const (
  39765. UTF8 = Charset("UTF-8")
  39766. GB18030 = Charset("GB18030")
  39767. )
  39768. func ConvertToString(src string, srcCode string, tagCode string) string {
  39769. srcCoder := mahonia.NewDecoder(srcCode)
  39770. srcResult := srcCoder.ConvertString(src)
  39771. tagCoder := mahonia.NewDecoder(tagCode)
  39772. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39773. result := string(cdata)
  39774. return result
  39775. }
  39776. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39777. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39778. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39779. var token string
  39780. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39781. var api string
  39782. if miConfig.MdtrtareaAdmvs == "320830" {
  39783. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39784. "&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
  39785. fmt.Println(api)
  39786. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39787. 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 +
  39788. "&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
  39789. fmt.Println(api)
  39790. } else {
  39791. 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 +
  39792. "&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
  39793. }
  39794. resp, requestErr := http.Get(api)
  39795. if requestErr != nil {
  39796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39797. return ""
  39798. }
  39799. body, ioErr := ioutil.ReadAll(resp.Body)
  39800. if ioErr != nil {
  39801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39803. return ""
  39804. }
  39805. var respJSON map[string]interface{}
  39806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39809. return ""
  39810. }
  39811. var status string
  39812. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39813. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39814. var res ResultTwo //1101结果
  39815. var res10265 ResultTwo10265 //1101结果
  39816. if status == "0" { //读卡成功
  39817. var card_info string //卡信息
  39818. var busi_card_info string
  39819. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39820. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39821. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39822. fmt.Println(card_info)
  39823. fmt.Println(busi_card_info)
  39824. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39825. result, _ := json.Marshal(respJSON)
  39826. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39827. utils.ErrorLog("解析失败:%v", err)
  39828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39829. return ""
  39830. }
  39831. res.ErrMsg = res10265.ErrMsg
  39832. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39833. res.Infcode = infocode
  39834. res.Output = res10265.Output
  39835. res.InfRefmsgid = res10265.InfRefmsgid
  39836. if res.Infcode == 0 {
  39837. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39838. if err == gorm.ErrRecordNotFound {
  39839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39840. return ""
  39841. } else if err != nil {
  39842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39843. return ""
  39844. } else {
  39845. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39846. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39847. infoStr := string(Iinfos)
  39848. idetinfoStr := string(Idetinfos)
  39849. psn := &models.HisPsn{
  39850. PsnNo: res.Output.Baseinfo.PsnNo,
  39851. PatientId: patient.ID,
  39852. Certno: res.Output.Baseinfo.Certno,
  39853. Gend: res.Output.Baseinfo.Gend,
  39854. Naty: res.Output.Baseinfo.Naty,
  39855. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39856. PsnName: res.Output.Baseinfo.PsnName,
  39857. Idetinfo: idetinfoStr,
  39858. Insuinfo: infoStr,
  39859. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39860. CardInfo: card_info,
  39861. VerifyNumber: token,
  39862. }
  39863. service.CreateHisPsn(psn)
  39864. return token
  39865. }
  39866. }
  39867. } else {
  39868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39869. return ""
  39870. }
  39871. } else { //读卡失败
  39872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39873. return ""
  39874. }
  39875. return token
  39876. }
  39877. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39878. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39879. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39880. var token string
  39881. var api string
  39882. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39883. "&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
  39884. fmt.Println(api)
  39885. resp, requestErr := http.Get(api)
  39886. if requestErr != nil {
  39887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39888. return ""
  39889. }
  39890. body, ioErr := ioutil.ReadAll(resp.Body)
  39891. if ioErr != nil {
  39892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39894. return ""
  39895. }
  39896. var respJSON map[string]interface{}
  39897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39900. return ""
  39901. }
  39902. var status string
  39903. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39904. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39905. var res ResultTwo //1101结果
  39906. if status == "1" { //读卡成功
  39907. var card_info string //卡信息
  39908. var busi_card_info string
  39909. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39910. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39911. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39912. fmt.Println(card_info)
  39913. fmt.Println(busi_card_info)
  39914. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39915. result, _ := json.Marshal(respJSON)
  39916. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39917. utils.ErrorLog("解析失败:%v", err)
  39918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39919. return ""
  39920. }
  39921. if res.Infcode == 0 {
  39922. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39923. if err == gorm.ErrRecordNotFound {
  39924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39925. return ""
  39926. } else if err != nil {
  39927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39928. return ""
  39929. } else {
  39930. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39931. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39932. infoStr := string(Iinfos)
  39933. idetinfoStr := string(Idetinfos)
  39934. psn := &models.HisPsn{
  39935. PsnNo: res.Output.Baseinfo.PsnNo,
  39936. PatientId: patient.ID,
  39937. Certno: res.Output.Baseinfo.Certno,
  39938. Gend: res.Output.Baseinfo.Gend,
  39939. Naty: res.Output.Baseinfo.Naty,
  39940. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39941. PsnName: res.Output.Baseinfo.PsnName,
  39942. Idetinfo: idetinfoStr,
  39943. Insuinfo: infoStr,
  39944. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39945. CardInfo: card_info,
  39946. VerifyNumber: token,
  39947. }
  39948. service.CreateHisPsn(psn)
  39949. return token
  39950. }
  39951. }
  39952. } else {
  39953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39954. return ""
  39955. }
  39956. return token
  39957. }
  39958. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39959. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39960. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39961. var token string
  39962. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39963. var api string
  39964. if miConfig.MdtrtareaAdmvs == "320830" {
  39965. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39966. "&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
  39967. fmt.Println(api)
  39968. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39969. 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 +
  39970. "&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
  39971. fmt.Println(api)
  39972. } else {
  39973. 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 +
  39974. "&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
  39975. }
  39976. resp, requestErr := http.Get(api)
  39977. if requestErr != nil {
  39978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39979. return ""
  39980. }
  39981. body, ioErr := ioutil.ReadAll(resp.Body)
  39982. if ioErr != nil {
  39983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39985. return ""
  39986. }
  39987. var respJSON map[string]interface{}
  39988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39991. return ""
  39992. }
  39993. var status string
  39994. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39995. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39996. var res ResultTwo //1101结果
  39997. var res10265 ResultTwo10265 //1101结果
  39998. if status == "0" { //读卡成功
  39999. var card_info string //卡信息
  40000. var busi_card_info string
  40001. token = respJSON["data"].(map[string]interface{})["token"].(string)
  40002. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  40003. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  40004. fmt.Println(card_info)
  40005. fmt.Println(busi_card_info)
  40006. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  40007. result, _ := json.Marshal(respJSON)
  40008. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  40009. utils.ErrorLog("解析失败:%v", err)
  40010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40011. return ""
  40012. }
  40013. res.ErrMsg = res10265.ErrMsg
  40014. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  40015. res.Infcode = infocode
  40016. res.Output = res10265.Output
  40017. res.InfRefmsgid = res10265.InfRefmsgid
  40018. if res.Infcode == 0 {
  40019. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  40020. if err == gorm.ErrRecordNotFound {
  40021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  40022. return ""
  40023. } else if err != nil {
  40024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  40025. return ""
  40026. } else {
  40027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  40028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  40029. infoStr := string(Iinfos)
  40030. idetinfoStr := string(Idetinfos)
  40031. psn := &models.HisPsn{
  40032. PsnNo: res.Output.Baseinfo.PsnNo,
  40033. PatientId: patient.ID,
  40034. Certno: res.Output.Baseinfo.Certno,
  40035. Gend: res.Output.Baseinfo.Gend,
  40036. Naty: res.Output.Baseinfo.Naty,
  40037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  40038. PsnName: res.Output.Baseinfo.PsnName,
  40039. Idetinfo: idetinfoStr,
  40040. Insuinfo: infoStr,
  40041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  40042. CardInfo: card_info,
  40043. VerifyNumber: token,
  40044. }
  40045. service.CreateHisPsn(psn)
  40046. return token
  40047. }
  40048. }
  40049. } else {
  40050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  40051. return ""
  40052. }
  40053. } else { //读卡失败
  40054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  40055. return ""
  40056. }
  40057. return token
  40058. }
  40059. func DeleteExtraSpaceTwo(s string) string {
  40060. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  40061. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  40062. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  40063. reg, _ := regexp.Compile(regstr) //编译正则表达式
  40064. s2 := make([]byte, len(s1)) //定义字符数组切片
  40065. copy(s2, s1) //将字符串复制到切片
  40066. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  40067. for len(spc_index) > 0 { //找到适配项
  40068. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  40069. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  40070. }
  40071. return string(s2)
  40072. }
  40073. func Remove0000(s string) string {
  40074. str := make([]rune, 0, len(s))
  40075. for _, v := range []rune(s) {
  40076. if v == 0 {
  40077. continue
  40078. }
  40079. str = append(str, v)
  40080. }
  40081. return string(str)
  40082. }
  40083. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  40084. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  40085. readCard := DllDef.MustFindProc("EcQuery")
  40086. pCardInfo := make([]byte, 8192)
  40087. pBusiCardInfo := make([]byte, 8192)
  40088. data := make(map[string]interface{})
  40089. //pData := make(map[string]interface{})
  40090. inputData := make(map[string]interface{})
  40091. inputData["orgId"] = code
  40092. inputData["businessType"] = "01101"
  40093. inputData["operatorId"] = operator_id
  40094. inputData["operatorName"] = operator_name
  40095. inputData["officeId"] = "001"
  40096. inputData["officeName"] = "血透室"
  40097. //
  40098. data["data"] = inputData
  40099. data["transType"] = "ec.query"
  40100. data["orgId"] = code
  40101. bytesData, _ := json.Marshal(data)
  40102. pCardInfo = bytesData
  40103. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  40104. fmt.Println(ret2)
  40105. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  40106. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  40107. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  40108. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  40109. if ret2 != 0 {
  40110. return "", ""
  40111. }
  40112. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  40113. }
  40114. func DeleteExtraSpace(s string) string {
  40115. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  40116. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  40117. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  40118. reg, _ := regexp.Compile(regstr) //编译正则表达式
  40119. s2 := make([]byte, len(s1)) //定义字符数组切片
  40120. copy(s2, s1) //将字符串复制到切片
  40121. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  40122. for len(spc_index) > 0 { //找到适配项
  40123. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  40124. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  40125. }
  40126. return string(s2)
  40127. }
  40128. // 对账
  40129. func (c *HisApiController) Post3202() {
  40130. start_time := c.GetString("start_time")
  40131. end_time := c.GetString("end_time")
  40132. //insutype := c.GetString("insutype")
  40133. clr_type := c.GetString("clr_type")
  40134. clr_org := c.GetString("clr_optins")
  40135. admin_user_id, _ := c.GetInt64("admin_user_id")
  40136. adminUser := c.GetAdminUserInfo()
  40137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40139. if len(clr_org) == 0 {
  40140. clr_org = miConfig.MdtrtareaAdmvs
  40141. }
  40142. timeLayout := "2006-01-02"
  40143. loc, _ := time.LoadLocation("Local")
  40144. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40145. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40146. var orders []*models.HisOrder
  40147. if clr_org == "421300" {
  40148. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40149. } else if clr_org == "420902" {
  40150. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40151. } else {
  40152. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40153. }
  40154. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40155. //fixmedins_setl_cnt := int64(len(orders))
  40156. var medfee_sumamt float64
  40157. var acct_pay float64
  40158. var fund_pay_sumamt float64
  40159. for _, item := range orders {
  40160. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40161. acct_pay = acct_pay + item.AcctPay
  40162. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40163. }
  40164. //var medfee_sumamt_two float64
  40165. //var acct_pay_two float64
  40166. //var fund_pay_sumamt_two float64
  40167. //for _, item := range orders_two {
  40168. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40169. // acct_pay_two = acct_pay_two + item.AcctPay
  40170. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40171. //}
  40172. //var user_name string
  40173. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40174. //if role.ID == 0 {
  40175. // user_name = "xxx"
  40176. //} else {
  40177. // user_name = role.UserName
  40178. //}
  40179. var res ResultSix
  40180. if config.IsOpen == 1 {
  40181. var bps []*models.BusinessParamsTwo
  40182. var bp models.BusinessParamsTwo
  40183. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40184. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40185. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40186. bp.MedfeeSumamt = medfee_sumamt_str
  40187. bp.AcctPay = acct_pay_str
  40188. bp.FundPaySumamt = fund_pay_sumamt_str
  40189. bp.Insutype = ""
  40190. bp.StmtBegndate = start_time
  40191. bp.ClrType = clr_type
  40192. bp.SetlOptins = clr_org
  40193. bp.StmtEnddate = end_time
  40194. bps = append(bps, &bp)
  40195. data := make(map[string]interface{})
  40196. data["bps"] = bps
  40197. data["org_name"] = miConfig.OrgName
  40198. data["doctor"] = role.UserName
  40199. data["fixmedins_code"] = miConfig.Code
  40200. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40201. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40202. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40203. if miConfig.MdtrtareaAdmvs == "421300" {
  40204. client := &http.Client{}
  40205. bytesData, _ := json.Marshal(data)
  40206. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40207. resp, _ := client.Do(req)
  40208. defer resp.Body.Close()
  40209. body, ioErr := ioutil.ReadAll(resp.Body)
  40210. if ioErr != nil {
  40211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40213. return
  40214. }
  40215. var respJSON map[string]interface{}
  40216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40219. return
  40220. }
  40221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40222. userJSONBytes, _ := json.Marshal(respJSON)
  40223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40224. utils.ErrorLog("解析失败:%v", err)
  40225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40226. return
  40227. }
  40228. }
  40229. if miConfig.MdtrtareaAdmvs == "420200" {
  40230. client := &http.Client{}
  40231. bytesData, _ := json.Marshal(data)
  40232. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40233. resp, _ := client.Do(req)
  40234. defer resp.Body.Close()
  40235. body, ioErr := ioutil.ReadAll(resp.Body)
  40236. if ioErr != nil {
  40237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40239. return
  40240. }
  40241. var respJSON map[string]interface{}
  40242. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40245. return
  40246. }
  40247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40248. userJSONBytes, _ := json.Marshal(respJSON)
  40249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40250. utils.ErrorLog("解析失败:%v", err)
  40251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40252. return
  40253. }
  40254. }
  40255. if miConfig.MdtrtareaAdmvs == "421182" {
  40256. client := &http.Client{}
  40257. bytesData, _ := json.Marshal(data)
  40258. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40259. resp, _ := client.Do(req)
  40260. defer resp.Body.Close()
  40261. body, ioErr := ioutil.ReadAll(resp.Body)
  40262. if ioErr != nil {
  40263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40265. return
  40266. }
  40267. var respJSON map[string]interface{}
  40268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40271. return
  40272. }
  40273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40274. userJSONBytes, _ := json.Marshal(respJSON)
  40275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40276. utils.ErrorLog("解析失败:%v", err)
  40277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40278. return
  40279. }
  40280. }
  40281. if miConfig.MdtrtareaAdmvs == "420902" {
  40282. client := &http.Client{}
  40283. bytesData, _ := json.Marshal(data)
  40284. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40285. resp, _ := client.Do(req)
  40286. defer resp.Body.Close()
  40287. body, ioErr := ioutil.ReadAll(resp.Body)
  40288. if ioErr != nil {
  40289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40291. return
  40292. }
  40293. var respJSON map[string]interface{}
  40294. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40297. return
  40298. }
  40299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40300. userJSONBytes, _ := json.Marshal(respJSON)
  40301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40302. utils.ErrorLog("解析失败:%v", err)
  40303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40304. return
  40305. }
  40306. }
  40307. if res.Infcode == 0 {
  40308. c.ServeSuccessJSON(map[string]interface{}{
  40309. "msg": "发起成功",
  40310. })
  40311. } else {
  40312. c.ServeSuccessJSON(map[string]interface{}{
  40313. "failed_code": -10,
  40314. "msg": res.ErrMsg,
  40315. })
  40316. }
  40317. }
  40318. }
  40319. func (c *HisApiController) Post3204a() {
  40320. start_time := c.GetString("start_time")
  40321. end_time := c.GetString("end_time")
  40322. //insutype := c.GetString("insutype")
  40323. clr_type := c.GetString("clr_type")
  40324. clr_org := c.GetString("clr_optins")
  40325. admin_user_id, _ := c.GetInt64("admin_user_id")
  40326. adminUser := c.GetAdminUserInfo()
  40327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40328. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40329. if len(clr_org) == 0 {
  40330. clr_org = miConfig.MdtrtareaAdmvs
  40331. }
  40332. timeLayout := "2006-01-02"
  40333. loc, _ := time.LoadLocation("Local")
  40334. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40335. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40336. var orders []*models.HisOrder
  40337. if clr_org == "421300" {
  40338. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40339. } else if clr_org == "420902" {
  40340. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40341. } else {
  40342. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40343. }
  40344. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40345. //fixmedins_setl_cnt := int64(len(orders))
  40346. var medfee_sumamt float64
  40347. var acct_pay float64
  40348. var fund_pay_sumamt float64
  40349. for _, item := range orders {
  40350. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40351. acct_pay = acct_pay + item.AcctPay
  40352. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40353. }
  40354. //var medfee_sumamt_two float64
  40355. //var acct_pay_two float64
  40356. //var fund_pay_sumamt_two float64
  40357. //for _, item := range orders_two {
  40358. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40359. // acct_pay_two = acct_pay_two + item.AcctPay
  40360. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40361. //}
  40362. //var user_name string
  40363. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40364. //if role.ID == 0 {
  40365. // user_name = "xxx"
  40366. //} else {
  40367. // user_name = role.UserName
  40368. //}
  40369. var res ResultSix
  40370. if config.IsOpen == 1 {
  40371. var bps []*models.BusinessParamsTwo
  40372. var bp models.BusinessParamsTwo
  40373. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40374. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40375. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40376. bp.MedfeeSumamt = medfee_sumamt_str
  40377. bp.AcctPay = acct_pay_str
  40378. bp.FundPaySumamt = fund_pay_sumamt_str
  40379. bp.Insutype = ""
  40380. bp.StmtBegndate = start_time
  40381. bp.ClrType = clr_type
  40382. bp.SetlOptins = clr_org
  40383. bp.StmtEnddate = end_time
  40384. bps = append(bps, &bp)
  40385. data := make(map[string]interface{})
  40386. data["bps"] = bps
  40387. data["org_name"] = miConfig.OrgName
  40388. data["doctor"] = role.UserName
  40389. data["fixmedins_code"] = miConfig.Code
  40390. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40391. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40392. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40393. if miConfig.MdtrtareaAdmvs == "421300" {
  40394. client := &http.Client{}
  40395. bytesData, _ := json.Marshal(data)
  40396. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40397. resp, _ := client.Do(req)
  40398. defer resp.Body.Close()
  40399. body, ioErr := ioutil.ReadAll(resp.Body)
  40400. if ioErr != nil {
  40401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40403. return
  40404. }
  40405. var respJSON map[string]interface{}
  40406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40409. return
  40410. }
  40411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40412. userJSONBytes, _ := json.Marshal(respJSON)
  40413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40414. utils.ErrorLog("解析失败:%v", err)
  40415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40416. return
  40417. }
  40418. }
  40419. if miConfig.MdtrtareaAdmvs == "420200" {
  40420. client := &http.Client{}
  40421. bytesData, _ := json.Marshal(data)
  40422. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40423. resp, _ := client.Do(req)
  40424. defer resp.Body.Close()
  40425. body, ioErr := ioutil.ReadAll(resp.Body)
  40426. if ioErr != nil {
  40427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40429. return
  40430. }
  40431. var respJSON map[string]interface{}
  40432. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40435. return
  40436. }
  40437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40438. userJSONBytes, _ := json.Marshal(respJSON)
  40439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40440. utils.ErrorLog("解析失败:%v", err)
  40441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40442. return
  40443. }
  40444. }
  40445. if miConfig.MdtrtareaAdmvs == "421182" {
  40446. client := &http.Client{}
  40447. bytesData, _ := json.Marshal(data)
  40448. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40449. resp, _ := client.Do(req)
  40450. defer resp.Body.Close()
  40451. body, ioErr := ioutil.ReadAll(resp.Body)
  40452. if ioErr != nil {
  40453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40455. return
  40456. }
  40457. var respJSON map[string]interface{}
  40458. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40461. return
  40462. }
  40463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40464. userJSONBytes, _ := json.Marshal(respJSON)
  40465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40466. utils.ErrorLog("解析失败:%v", err)
  40467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40468. return
  40469. }
  40470. }
  40471. if miConfig.MdtrtareaAdmvs == "420902" {
  40472. client := &http.Client{}
  40473. bytesData, _ := json.Marshal(data)
  40474. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40475. resp, _ := client.Do(req)
  40476. defer resp.Body.Close()
  40477. body, ioErr := ioutil.ReadAll(resp.Body)
  40478. if ioErr != nil {
  40479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40481. return
  40482. }
  40483. var respJSON map[string]interface{}
  40484. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40487. return
  40488. }
  40489. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40490. userJSONBytes, _ := json.Marshal(respJSON)
  40491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40492. utils.ErrorLog("解析失败:%v", err)
  40493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40494. return
  40495. }
  40496. }
  40497. if res.Infcode == 0 {
  40498. c.ServeSuccessJSON(map[string]interface{}{
  40499. "msg": "撤销成功",
  40500. })
  40501. } else {
  40502. c.ServeSuccessJSON(map[string]interface{}{
  40503. "failed_code": -10,
  40504. "msg": res.ErrMsg,
  40505. })
  40506. }
  40507. }
  40508. }
  40509. func (c *HisApiController) Post3204() {
  40510. admin_user_id, _ := c.GetInt64("admin_user_id")
  40511. id := c.GetString("id")
  40512. adminUser := c.GetAdminUserInfo()
  40513. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40514. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40515. //clr_org := miConfig.MdtrtareaAdmvs
  40516. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40517. var res ResultSix
  40518. if config.IsOpen == 1 {
  40519. data := make(map[string]interface{})
  40520. data["id"] = id
  40521. data["org_name"] = miConfig.OrgName
  40522. data["doctor"] = role.UserName
  40523. data["fixmedins_code"] = miConfig.Code
  40524. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40525. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40526. client := &http.Client{}
  40527. bytesData, _ := json.Marshal(data)
  40528. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40529. resp, _ := client.Do(req)
  40530. defer resp.Body.Close()
  40531. body, ioErr := ioutil.ReadAll(resp.Body)
  40532. if ioErr != nil {
  40533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40535. return
  40536. }
  40537. var respJSON map[string]interface{}
  40538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40541. return
  40542. }
  40543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40544. userJSONBytes, _ := json.Marshal(respJSON)
  40545. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40546. utils.ErrorLog("解析失败:%v", err)
  40547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40548. return
  40549. }
  40550. if res.Infcode == 0 {
  40551. c.ServeSuccessJSON(map[string]interface{}{
  40552. "msg": "发起成功",
  40553. })
  40554. } else {
  40555. c.ServeSuccessJSON(map[string]interface{}{
  40556. "failed_code": -10,
  40557. "msg": res.ErrMsg,
  40558. })
  40559. }
  40560. }
  40561. }
  40562. func (c *HisApiController) Post8404() {
  40563. admin_user_id, _ := c.GetInt64("admin_user_id")
  40564. month := c.GetString("month")
  40565. adminUser := c.GetAdminUserInfo()
  40566. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40567. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40568. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40569. var res ResultSix
  40570. if config.IsOpen == 1 {
  40571. data := make(map[string]interface{})
  40572. data["month"] = month
  40573. data["org_name"] = miConfig.OrgName
  40574. data["doctor"] = role.UserName
  40575. data["fixmedins_code"] = miConfig.Code
  40576. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40577. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40578. client := &http.Client{}
  40579. bytesData, _ := json.Marshal(data)
  40580. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40581. resp, _ := client.Do(req)
  40582. defer resp.Body.Close()
  40583. body, ioErr := ioutil.ReadAll(resp.Body)
  40584. if ioErr != nil {
  40585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40587. return
  40588. }
  40589. var respJSON map[string]interface{}
  40590. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40593. return
  40594. }
  40595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40596. userJSONBytes, _ := json.Marshal(respJSON)
  40597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40598. utils.ErrorLog("解析失败:%v", err)
  40599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40600. return
  40601. }
  40602. if res.Infcode == 0 {
  40603. c.ServeSuccessJSON(map[string]interface{}{
  40604. "msg": "查询成功",
  40605. })
  40606. } else {
  40607. c.ServeSuccessJSON(map[string]interface{}{
  40608. "failed_code": -10,
  40609. "msg": res.ErrMsg,
  40610. })
  40611. }
  40612. }
  40613. }
  40614. func (c *HisApiController) Post3202b() {
  40615. start_time := c.GetString("start_time")
  40616. end_time := c.GetString("end_time")
  40617. //insutype := c.GetString("insutype")
  40618. clr_type := c.GetString("clr_type")
  40619. clr_org := c.GetString("clr_optins")
  40620. admin_user_id, _ := c.GetInt64("admin_user_id")
  40621. adminUser := c.GetAdminUserInfo()
  40622. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40623. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40624. if len(clr_org) == 0 {
  40625. clr_org = miConfig.MdtrtareaAdmvs
  40626. }
  40627. timeLayout := "2006-01-02"
  40628. loc, _ := time.LoadLocation("Local")
  40629. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40630. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40631. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40632. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40633. //fixmedins_setl_cnt := int64(len(orders))
  40634. var medfee_sumamt float64
  40635. var acct_pay float64
  40636. var fund_pay_sumamt float64
  40637. for _, item := range orders {
  40638. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40639. acct_pay = acct_pay + item.AcctPay
  40640. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40641. }
  40642. //var medfee_sumamt_two float64
  40643. //var acct_pay_two float64
  40644. //var fund_pay_sumamt_two float64
  40645. //for _, item := range orders_two {
  40646. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40647. // acct_pay_two = acct_pay_two + item.AcctPay
  40648. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40649. //}
  40650. //var user_name string
  40651. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40652. //if role.ID == 0 {
  40653. // user_name = "xxx"
  40654. //} else {
  40655. // user_name = role.UserName
  40656. //}
  40657. var res ResultSix
  40658. if config.IsOpen == 1 {
  40659. var bps []*models.BusinessParamsTwo
  40660. var bp models.BusinessParamsTwo
  40661. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40662. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40663. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40664. bp.MedfeeSumamt = medfee_sumamt_str
  40665. bp.AcctPay = acct_pay_str
  40666. bp.FundPaySumamt = fund_pay_sumamt_str
  40667. bp.Insutype = "390"
  40668. bp.StmtBegndate = start_time
  40669. bp.ClrType = clr_type
  40670. bp.SetlOptins = clr_org
  40671. bp.StmtEnddate = end_time
  40672. bps = append(bps, &bp)
  40673. data := make(map[string]interface{})
  40674. data["bps"] = bps
  40675. data["org_name"] = miConfig.OrgName
  40676. data["doctor"] = role.UserName
  40677. data["fixmedins_code"] = miConfig.Code
  40678. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40679. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40680. if miConfig.MdtrtareaAdmvs == "421300" {
  40681. client := &http.Client{}
  40682. bytesData, _ := json.Marshal(data)
  40683. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40684. resp, _ := client.Do(req)
  40685. defer resp.Body.Close()
  40686. body, ioErr := ioutil.ReadAll(resp.Body)
  40687. if ioErr != nil {
  40688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40690. return
  40691. }
  40692. var respJSON map[string]interface{}
  40693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40696. return
  40697. }
  40698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40699. userJSONBytes, _ := json.Marshal(respJSON)
  40700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40701. utils.ErrorLog("解析失败:%v", err)
  40702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40703. return
  40704. }
  40705. }
  40706. if miConfig.MdtrtareaAdmvs == "420200" {
  40707. client := &http.Client{}
  40708. bytesData, _ := json.Marshal(data)
  40709. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40710. resp, _ := client.Do(req)
  40711. defer resp.Body.Close()
  40712. body, ioErr := ioutil.ReadAll(resp.Body)
  40713. if ioErr != nil {
  40714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40716. return
  40717. }
  40718. var respJSON map[string]interface{}
  40719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40722. return
  40723. }
  40724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40725. userJSONBytes, _ := json.Marshal(respJSON)
  40726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40727. utils.ErrorLog("解析失败:%v", err)
  40728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40729. return
  40730. }
  40731. }
  40732. if miConfig.MdtrtareaAdmvs == "421182" {
  40733. client := &http.Client{}
  40734. bytesData, _ := json.Marshal(data)
  40735. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40736. resp, _ := client.Do(req)
  40737. defer resp.Body.Close()
  40738. body, ioErr := ioutil.ReadAll(resp.Body)
  40739. if ioErr != nil {
  40740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40742. return
  40743. }
  40744. var respJSON map[string]interface{}
  40745. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40748. return
  40749. }
  40750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40751. userJSONBytes, _ := json.Marshal(respJSON)
  40752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40753. utils.ErrorLog("解析失败:%v", err)
  40754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40755. return
  40756. }
  40757. }
  40758. if res.Infcode == 0 {
  40759. c.ServeSuccessJSON(map[string]interface{}{
  40760. "msg": "发起成功",
  40761. })
  40762. } else {
  40763. c.ServeSuccessJSON(map[string]interface{}{
  40764. "failed_code": -10,
  40765. "msg": res.ErrMsg,
  40766. })
  40767. }
  40768. }
  40769. }
  40770. func (c *HisApiController) Post1608() {
  40771. start_time := c.GetString("start_time")
  40772. end_time := c.GetString("end_time")
  40773. admin_user_id, _ := c.GetInt64("admin_user_id")
  40774. adminUser := c.GetAdminUserInfo()
  40775. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40776. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40777. timeLayout := "2006-01-02"
  40778. loc, _ := time.LoadLocation("Local")
  40779. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40780. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40781. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40782. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40783. fixmedins_setl_cnt := int64(len(orders))
  40784. var medfee_sumamt float64
  40785. var func_smamt float64
  40786. for _, item := range orders {
  40787. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40788. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40789. }
  40790. times := strings.Split(start_time, "-")
  40791. time_tows := strings.Split(end_time, "-")
  40792. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40793. var res ResultSix
  40794. if config.IsOpen == 1 {
  40795. //var bps []*models.BusinessParamsTwo
  40796. //var bp models.BusinessParamsTwo
  40797. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40798. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40799. data := make(map[string]interface{})
  40800. data["org_name"] = miConfig.OrgName
  40801. data["doctor"] = role.UserName
  40802. data["func_smamt"] = func_smamt_str
  40803. data["fixmedins_code"] = miConfig.Code
  40804. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40805. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40806. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40807. data["medfee_sumamt"] = medfee_sumamt_str
  40808. data["start_time"] = times[0] + times[1] + times[2]
  40809. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40810. if miConfig.MdtrtareaAdmvs == "421300" {
  40811. client := &http.Client{}
  40812. bytesData, _ := json.Marshal(data)
  40813. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40814. resp, _ := client.Do(req)
  40815. defer resp.Body.Close()
  40816. body, ioErr := ioutil.ReadAll(resp.Body)
  40817. if ioErr != nil {
  40818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40820. return
  40821. }
  40822. var respJSON map[string]interface{}
  40823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40826. return
  40827. }
  40828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40829. userJSONBytes, _ := json.Marshal(respJSON)
  40830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40831. utils.ErrorLog("解析失败:%v", err)
  40832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40833. return
  40834. }
  40835. }
  40836. if miConfig.MdtrtareaAdmvs == "420200" {
  40837. client := &http.Client{}
  40838. bytesData, _ := json.Marshal(data)
  40839. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40840. resp, _ := client.Do(req)
  40841. defer resp.Body.Close()
  40842. body, ioErr := ioutil.ReadAll(resp.Body)
  40843. if ioErr != nil {
  40844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40846. return
  40847. }
  40848. var respJSON map[string]interface{}
  40849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40852. return
  40853. }
  40854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40855. userJSONBytes, _ := json.Marshal(respJSON)
  40856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40857. utils.ErrorLog("解析失败:%v", err)
  40858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40859. return
  40860. }
  40861. }
  40862. if miConfig.MdtrtareaAdmvs == "421182" {
  40863. client := &http.Client{}
  40864. bytesData, _ := json.Marshal(data)
  40865. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40866. resp, _ := client.Do(req)
  40867. defer resp.Body.Close()
  40868. body, ioErr := ioutil.ReadAll(resp.Body)
  40869. if ioErr != nil {
  40870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40872. return
  40873. }
  40874. var respJSON map[string]interface{}
  40875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40878. return
  40879. }
  40880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40881. userJSONBytes, _ := json.Marshal(respJSON)
  40882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40883. utils.ErrorLog("解析失败:%v", err)
  40884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40885. return
  40886. }
  40887. }
  40888. if res.Infcode == 0 {
  40889. c.ServeSuccessJSON(map[string]interface{}{
  40890. "msg": "发起成功",
  40891. })
  40892. } else {
  40893. c.ServeSuccessJSON(map[string]interface{}{
  40894. "failed_code": -10,
  40895. "msg": res.ErrMsg,
  40896. })
  40897. }
  40898. }
  40899. }
  40900. // 5.11.1.1【5262】结算信息按时间段查询
  40901. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40902. admin_user_id, _ := c.GetInt64("admin_user_id")
  40903. adminUser := c.GetAdminUserInfo()
  40904. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40905. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40906. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40907. var res Result5262
  40908. if config.IsOpen == 1 {
  40909. if miConfig.MdtrtareaAdmvs == "421300" {
  40910. data := make(map[string]interface{})
  40911. data["bps"] = bp
  40912. data["org_name"] = miConfig.OrgName
  40913. data["doctor"] = role.UserName
  40914. data["fixmedins_code"] = miConfig.Code
  40915. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40916. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40917. data["page"] = strconv.FormatInt(page, 10)
  40918. data["limit"] = strconv.FormatInt(limit, 10)
  40919. fmt.Println(data)
  40920. client := &http.Client{}
  40921. bytesData, _ := json.Marshal(data)
  40922. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40923. resp, _ := client.Do(req)
  40924. defer resp.Body.Close()
  40925. body, ioErr := ioutil.ReadAll(resp.Body)
  40926. if ioErr != nil {
  40927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40929. return
  40930. }
  40931. var respJSON map[string]interface{}
  40932. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40935. return
  40936. }
  40937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40938. userJSONBytes, _ := json.Marshal(respJSON)
  40939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40940. utils.ErrorLog("解析失败:%v", err)
  40941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40942. return
  40943. }
  40944. }
  40945. if miConfig.MdtrtareaAdmvs == "420200" {
  40946. data := make(map[string]interface{})
  40947. data["bps"] = bp
  40948. data["org_name"] = miConfig.OrgName
  40949. data["doctor"] = role.UserName
  40950. data["fixmedins_code"] = miConfig.Code
  40951. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40952. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40953. data["page"] = strconv.FormatInt(page, 10)
  40954. data["limit"] = strconv.FormatInt(limit, 10)
  40955. fmt.Println(data)
  40956. client := &http.Client{}
  40957. bytesData, _ := json.Marshal(data)
  40958. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40959. resp, _ := client.Do(req)
  40960. defer resp.Body.Close()
  40961. body, ioErr := ioutil.ReadAll(resp.Body)
  40962. if ioErr != nil {
  40963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40965. return
  40966. }
  40967. var respJSON map[string]interface{}
  40968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40971. return
  40972. }
  40973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40974. userJSONBytes, _ := json.Marshal(respJSON)
  40975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40976. utils.ErrorLog("解析失败:%v", err)
  40977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40978. return
  40979. }
  40980. }
  40981. if miConfig.MdtrtareaAdmvs == "421182" {
  40982. data := make(map[string]interface{})
  40983. data["bps"] = bp
  40984. data["org_name"] = miConfig.OrgName
  40985. data["doctor"] = role.UserName
  40986. data["fixmedins_code"] = miConfig.Code
  40987. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40988. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40989. data["page"] = strconv.FormatInt(page, 10)
  40990. data["limit"] = strconv.FormatInt(limit, 10)
  40991. fmt.Println(data)
  40992. client := &http.Client{}
  40993. bytesData, _ := json.Marshal(data)
  40994. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40995. resp, _ := client.Do(req)
  40996. defer resp.Body.Close()
  40997. body, ioErr := ioutil.ReadAll(resp.Body)
  40998. if ioErr != nil {
  40999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41001. return
  41002. }
  41003. var respJSON map[string]interface{}
  41004. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41007. return
  41008. }
  41009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41010. userJSONBytes, _ := json.Marshal(respJSON)
  41011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41012. utils.ErrorLog("解析失败:%v", err)
  41013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41014. return
  41015. }
  41016. }
  41017. if miConfig.MdtrtareaAdmvs == "420902" {
  41018. data := make(map[string]interface{})
  41019. data["bps"] = bp
  41020. data["org_name"] = miConfig.OrgName
  41021. data["doctor"] = role.UserName
  41022. data["fixmedins_code"] = miConfig.Code
  41023. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41024. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41025. data["page"] = strconv.FormatInt(page, 10)
  41026. data["limit"] = strconv.FormatInt(limit, 10)
  41027. fmt.Println(data)
  41028. client := &http.Client{}
  41029. bytesData, _ := json.Marshal(data)
  41030. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  41031. resp, _ := client.Do(req)
  41032. defer resp.Body.Close()
  41033. body, ioErr := ioutil.ReadAll(resp.Body)
  41034. if ioErr != nil {
  41035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41037. return
  41038. }
  41039. var respJSON map[string]interface{}
  41040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41043. return
  41044. }
  41045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41046. userJSONBytes, _ := json.Marshal(respJSON)
  41047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41048. utils.ErrorLog("解析失败:%v", err)
  41049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41050. return
  41051. }
  41052. }
  41053. if res.Infcode == 0 {
  41054. c.ServeSuccessJSON(map[string]interface{}{
  41055. "order": res.Output.Result,
  41056. "total": res.Output.PageInfo.RecordCounts,
  41057. })
  41058. } else {
  41059. c.ServeSuccessJSON(map[string]interface{}{
  41060. "failed_code": -10,
  41061. "msg": res.ErrMsg,
  41062. })
  41063. }
  41064. }
  41065. }
  41066. // 5.11.1.2【5267】异地结算信息时间段查询
  41067. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  41068. admin_user_id, _ := c.GetInt64("admin_user_id")
  41069. adminUser := c.GetAdminUserInfo()
  41070. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  41071. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  41072. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  41073. var res Result5267
  41074. if config.IsOpen == 1 {
  41075. if miConfig.MdtrtareaAdmvs == "421300" {
  41076. data := make(map[string]interface{})
  41077. data["bps"] = bp
  41078. data["org_name"] = miConfig.OrgName
  41079. data["doctor"] = role.UserName
  41080. data["fixmedins_code"] = miConfig.Code
  41081. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41082. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41083. data["page"] = page
  41084. data["limit"] = limit
  41085. fmt.Println(data)
  41086. client := &http.Client{}
  41087. bytesData, _ := json.Marshal(data)
  41088. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41089. resp, _ := client.Do(req)
  41090. defer resp.Body.Close()
  41091. body, ioErr := ioutil.ReadAll(resp.Body)
  41092. if ioErr != nil {
  41093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41095. return
  41096. }
  41097. var respJSON map[string]interface{}
  41098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41101. return
  41102. }
  41103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41104. userJSONBytes, _ := json.Marshal(respJSON)
  41105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41106. utils.ErrorLog("解析失败:%v", err)
  41107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41108. return
  41109. }
  41110. }
  41111. if miConfig.MdtrtareaAdmvs == "420200" {
  41112. data := make(map[string]interface{})
  41113. data["bps"] = bp
  41114. data["org_name"] = miConfig.OrgName
  41115. data["doctor"] = role.UserName
  41116. data["fixmedins_code"] = miConfig.Code
  41117. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41118. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41119. data["page"] = page
  41120. data["limit"] = limit
  41121. fmt.Println(data)
  41122. client := &http.Client{}
  41123. bytesData, _ := json.Marshal(data)
  41124. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41125. resp, _ := client.Do(req)
  41126. defer resp.Body.Close()
  41127. body, ioErr := ioutil.ReadAll(resp.Body)
  41128. if ioErr != nil {
  41129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41131. return
  41132. }
  41133. var respJSON map[string]interface{}
  41134. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41137. return
  41138. }
  41139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41140. userJSONBytes, _ := json.Marshal(respJSON)
  41141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41142. utils.ErrorLog("解析失败:%v", err)
  41143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41144. return
  41145. }
  41146. }
  41147. if miConfig.MdtrtareaAdmvs == "421182" {
  41148. data := make(map[string]interface{})
  41149. data["bps"] = bp
  41150. data["org_name"] = miConfig.OrgName
  41151. data["doctor"] = role.UserName
  41152. data["fixmedins_code"] = miConfig.Code
  41153. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41154. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41155. data["page"] = page
  41156. data["limit"] = limit
  41157. fmt.Println(data)
  41158. client := &http.Client{}
  41159. bytesData, _ := json.Marshal(data)
  41160. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  41161. resp, _ := client.Do(req)
  41162. defer resp.Body.Close()
  41163. body, ioErr := ioutil.ReadAll(resp.Body)
  41164. if ioErr != nil {
  41165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41167. return
  41168. }
  41169. var respJSON map[string]interface{}
  41170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41173. return
  41174. }
  41175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41176. userJSONBytes, _ := json.Marshal(respJSON)
  41177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41178. utils.ErrorLog("解析失败:%v", err)
  41179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41180. return
  41181. }
  41182. }
  41183. if res.Infcode == 0 {
  41184. c.ServeSuccessJSON(map[string]interface{}{
  41185. "order": res.Output.Result,
  41186. "total": res.Output.PageInfo.RecordCounts,
  41187. })
  41188. } else {
  41189. c.ServeSuccessJSON(map[string]interface{}{
  41190. "failed_code": -10,
  41191. "msg": res.ErrMsg,
  41192. })
  41193. }
  41194. }
  41195. }
  41196. func (c *HisApiController) Post3501() {
  41197. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41198. data := make(map[string]interface{})
  41199. var struct3501s []models.Struct3501
  41200. var struct3501 models.Struct3501
  41201. struct3501.OrgName = miConfig.OrgName
  41202. struct3501.AccessKey = miConfig.AccessKey
  41203. struct3501.RequestUrl = miConfig.Url
  41204. struct3501.SecretKey = miConfig.SecretKey
  41205. struct3501.ManuDate = "2022-08-17"
  41206. struct3501.FixmedinsBchno = ""
  41207. struct3501.ManuLotnum = ""
  41208. struct3501.RxFlag = "0"
  41209. struct3501.ExpyEnd = "2022-08-17"
  41210. struct3501.Invdate = "2022-08-17"
  41211. struct3501.InvCnt = "20.25"
  41212. struct3501.Memo = ""
  41213. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41214. struct3501.FixmedinsHilistId = miConfig.Code
  41215. struct3501.FixmedinsHilistName = miConfig.OrgName
  41216. struct3501s = append(struct3501s, struct3501)
  41217. data["struct_3501s"] = struct3501s
  41218. client := &http.Client{}
  41219. bytesData, _ := json.Marshal(data)
  41220. var req *http.Request
  41221. if miConfig.MdtrtareaAdmvs == "320830" {
  41222. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41223. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41224. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41225. } else {
  41226. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41227. }
  41228. resp, _ := client.Do(req)
  41229. defer resp.Body.Close()
  41230. body, ioErr := ioutil.ReadAll(resp.Body)
  41231. if ioErr != nil {
  41232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41234. return
  41235. }
  41236. var respJSON map[string]interface{}
  41237. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41240. return
  41241. }
  41242. var res ResultSix
  41243. var resSix10265 ResultSix10265 //1101结果
  41244. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41245. result, _ := json.Marshal(respJSON)
  41246. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41247. utils.ErrorLog("解析失败:%v", err)
  41248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41249. return
  41250. }
  41251. res.InfRefmsgid = resSix10265.InfRefmsgid
  41252. res.Output = resSix10265.Output
  41253. res.ErrMsg = resSix10265.ErrMsg
  41254. res.Cainfo = resSix10265.Cainfo
  41255. res.WarnMsg = resSix10265.WarnMsg
  41256. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41257. res.Infcode = infocode
  41258. if infocode == 0 {
  41259. c.ServeSuccessJSON(map[string]interface{}{
  41260. "msg": "上传成功",
  41261. })
  41262. return
  41263. } else {
  41264. c.ServeSuccessJSON(map[string]interface{}{
  41265. "failed_code": -10,
  41266. "msg": res.ErrMsg,
  41267. })
  41268. return
  41269. }
  41270. }
  41271. func (c *HisApiController) Post3502() {
  41272. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41273. data := make(map[string]interface{})
  41274. var struct3502s []models.Struct3502
  41275. var struct3502 models.Struct3502
  41276. struct3502.OrgName = miConfig.OrgName
  41277. struct3502.AccessKey = miConfig.AccessKey
  41278. struct3502.RequestUrl = miConfig.Url
  41279. struct3502.SecretKey = miConfig.SecretKey
  41280. struct3502.ManuDate = "2022-08-15"
  41281. struct3502.FixmedinsBchno = ""
  41282. struct3502.ManuLotnum = ""
  41283. struct3502.RxFlag = "0"
  41284. struct3502.ExpyEnd = "2022-08-15"
  41285. struct3502.Invdate = "2022-08-15"
  41286. struct3502.InvCnt = "20.25"
  41287. struct3502.Memo = ""
  41288. struct3502.MedListCodg = "XB01ABD056B002020200517"
  41289. struct3502.FixmedinsHilistId = miConfig.Code
  41290. struct3502.FixmedinsHilistName = miConfig.OrgName
  41291. struct3502s = append(struct3502s, struct3502)
  41292. data["struct_3502s"] = struct3502s
  41293. client := &http.Client{}
  41294. bytesData, _ := json.Marshal(data)
  41295. var req *http.Request
  41296. if miConfig.MdtrtareaAdmvs == "320830" {
  41297. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41298. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41299. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41300. } else {
  41301. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41302. }
  41303. resp, _ := client.Do(req)
  41304. defer resp.Body.Close()
  41305. body, ioErr := ioutil.ReadAll(resp.Body)
  41306. if ioErr != nil {
  41307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41309. return
  41310. }
  41311. var respJSON map[string]interface{}
  41312. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41315. return
  41316. }
  41317. var res ResultSix
  41318. var resSix10265 ResultSix10265 //1101结果
  41319. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41320. result, _ := json.Marshal(respJSON)
  41321. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41322. utils.ErrorLog("解析失败:%v", err)
  41323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41324. return
  41325. }
  41326. res.InfRefmsgid = resSix10265.InfRefmsgid
  41327. res.Output = resSix10265.Output
  41328. res.ErrMsg = resSix10265.ErrMsg
  41329. res.Cainfo = resSix10265.Cainfo
  41330. res.WarnMsg = resSix10265.WarnMsg
  41331. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41332. res.Infcode = infocode
  41333. if infocode == 0 {
  41334. c.ServeSuccessJSON(map[string]interface{}{
  41335. "msg": "上传成功",
  41336. })
  41337. return
  41338. } else {
  41339. c.ServeSuccessJSON(map[string]interface{}{
  41340. "failed_code": -10,
  41341. "msg": res.ErrMsg,
  41342. })
  41343. return
  41344. }
  41345. }
  41346. func (c *HisApiController) Post3503() {
  41347. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41348. data := make(map[string]interface{})
  41349. var struct3501s []models.Struct3501
  41350. var struct3501 models.Struct3501
  41351. struct3501.OrgName = miConfig.OrgName
  41352. struct3501.AccessKey = miConfig.AccessKey
  41353. struct3501.RequestUrl = miConfig.Url
  41354. struct3501.SecretKey = miConfig.SecretKey
  41355. struct3501.ManuDate = "2022-08-15"
  41356. struct3501.FixmedinsBchno = ""
  41357. struct3501.ManuLotnum = ""
  41358. struct3501.RxFlag = "0"
  41359. struct3501.ExpyEnd = "2022-08-15"
  41360. struct3501.Invdate = "2022-08-15"
  41361. struct3501.InvCnt = "20.25"
  41362. struct3501.Memo = ""
  41363. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41364. struct3501.FixmedinsHilistId = miConfig.Code
  41365. struct3501.FixmedinsHilistName = miConfig.OrgName
  41366. struct3501s = append(struct3501s, struct3501)
  41367. data["struct_3501s"] = struct3501s
  41368. client := &http.Client{}
  41369. bytesData, _ := json.Marshal(data)
  41370. var req *http.Request
  41371. if miConfig.MdtrtareaAdmvs == "320921" {
  41372. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41373. } else {
  41374. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41375. }
  41376. resp, _ := client.Do(req)
  41377. defer resp.Body.Close()
  41378. body, ioErr := ioutil.ReadAll(resp.Body)
  41379. if ioErr != nil {
  41380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41382. return
  41383. }
  41384. var respJSON map[string]interface{}
  41385. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41388. return
  41389. }
  41390. var res ResultSix
  41391. var resSix10265 ResultSix10265 //1101结果
  41392. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41393. result, _ := json.Marshal(respJSON)
  41394. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41395. utils.ErrorLog("解析失败:%v", err)
  41396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41397. return
  41398. }
  41399. res.InfRefmsgid = resSix10265.InfRefmsgid
  41400. res.Output = resSix10265.Output
  41401. res.ErrMsg = resSix10265.ErrMsg
  41402. res.Cainfo = resSix10265.Cainfo
  41403. res.WarnMsg = resSix10265.WarnMsg
  41404. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41405. res.Infcode = infocode
  41406. if infocode == 0 {
  41407. c.ServeSuccessJSON(map[string]interface{}{
  41408. "msg": "上传成功",
  41409. })
  41410. return
  41411. } else {
  41412. c.ServeSuccessJSON(map[string]interface{}{
  41413. "failed_code": -10,
  41414. "msg": res.ErrMsg,
  41415. })
  41416. return
  41417. }
  41418. }
  41419. func (c *HisApiController) Post3504() {
  41420. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41421. data := make(map[string]interface{})
  41422. var struct3501s []models.Struct3501
  41423. var struct3501 models.Struct3501
  41424. struct3501.OrgName = miConfig.OrgName
  41425. struct3501.AccessKey = miConfig.AccessKey
  41426. struct3501.RequestUrl = miConfig.Url
  41427. struct3501.SecretKey = miConfig.SecretKey
  41428. struct3501.ManuDate = "2022-08-15"
  41429. struct3501.FixmedinsBchno = ""
  41430. struct3501.ManuLotnum = ""
  41431. struct3501.RxFlag = "0"
  41432. struct3501.ExpyEnd = "2022-08-15"
  41433. struct3501.Invdate = "2022-08-15"
  41434. struct3501.InvCnt = "20.25"
  41435. struct3501.Memo = ""
  41436. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41437. struct3501.FixmedinsHilistId = miConfig.Code
  41438. struct3501.FixmedinsHilistName = miConfig.OrgName
  41439. struct3501s = append(struct3501s, struct3501)
  41440. data["struct_3501s"] = struct3501s
  41441. client := &http.Client{}
  41442. bytesData, _ := json.Marshal(data)
  41443. var req *http.Request
  41444. if miConfig.MdtrtareaAdmvs == "320921" {
  41445. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41446. } else {
  41447. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41448. }
  41449. resp, _ := client.Do(req)
  41450. defer resp.Body.Close()
  41451. body, ioErr := ioutil.ReadAll(resp.Body)
  41452. if ioErr != nil {
  41453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41455. return
  41456. }
  41457. var respJSON map[string]interface{}
  41458. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41461. return
  41462. }
  41463. var res ResultSix
  41464. var resSix10265 ResultSix10265 //1101结果
  41465. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41466. result, _ := json.Marshal(respJSON)
  41467. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41468. utils.ErrorLog("解析失败:%v", err)
  41469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41470. return
  41471. }
  41472. res.InfRefmsgid = resSix10265.InfRefmsgid
  41473. res.Output = resSix10265.Output
  41474. res.ErrMsg = resSix10265.ErrMsg
  41475. res.Cainfo = resSix10265.Cainfo
  41476. res.WarnMsg = resSix10265.WarnMsg
  41477. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41478. res.Infcode = infocode
  41479. if infocode == 0 {
  41480. c.ServeSuccessJSON(map[string]interface{}{
  41481. "msg": "上传成功",
  41482. })
  41483. return
  41484. } else {
  41485. c.ServeSuccessJSON(map[string]interface{}{
  41486. "failed_code": -10,
  41487. "msg": res.ErrMsg,
  41488. })
  41489. return
  41490. }
  41491. }
  41492. func (c *HisApiController) Post3505() {
  41493. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41494. data := make(map[string]interface{})
  41495. var struct3501s []models.Struct3501
  41496. var struct3501 models.Struct3501
  41497. struct3501.OrgName = miConfig.OrgName
  41498. struct3501.AccessKey = miConfig.AccessKey
  41499. struct3501.RequestUrl = miConfig.Url
  41500. struct3501.SecretKey = miConfig.SecretKey
  41501. struct3501.ManuDate = "2022-08-15"
  41502. struct3501.FixmedinsBchno = ""
  41503. struct3501.ManuLotnum = ""
  41504. struct3501.RxFlag = "0"
  41505. struct3501.ExpyEnd = "2022-08-15"
  41506. struct3501.Invdate = "2022-08-15"
  41507. struct3501.InvCnt = "20.25"
  41508. struct3501.Memo = ""
  41509. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41510. struct3501.FixmedinsHilistId = miConfig.Code
  41511. struct3501.FixmedinsHilistName = miConfig.OrgName
  41512. struct3501s = append(struct3501s, struct3501)
  41513. data["struct_3501s"] = struct3501s
  41514. client := &http.Client{}
  41515. bytesData, _ := json.Marshal(data)
  41516. var req *http.Request
  41517. if miConfig.MdtrtareaAdmvs == "320921" {
  41518. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41519. } else {
  41520. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41521. }
  41522. resp, _ := client.Do(req)
  41523. defer resp.Body.Close()
  41524. body, ioErr := ioutil.ReadAll(resp.Body)
  41525. if ioErr != nil {
  41526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41528. return
  41529. }
  41530. var respJSON map[string]interface{}
  41531. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41534. return
  41535. }
  41536. var res ResultSix
  41537. var resSix10265 ResultSix10265 //1101结果
  41538. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41539. result, _ := json.Marshal(respJSON)
  41540. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41541. utils.ErrorLog("解析失败:%v", err)
  41542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41543. return
  41544. }
  41545. res.InfRefmsgid = resSix10265.InfRefmsgid
  41546. res.Output = resSix10265.Output
  41547. res.ErrMsg = resSix10265.ErrMsg
  41548. res.Cainfo = resSix10265.Cainfo
  41549. res.WarnMsg = resSix10265.WarnMsg
  41550. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41551. res.Infcode = infocode
  41552. if infocode == 0 {
  41553. c.ServeSuccessJSON(map[string]interface{}{
  41554. "msg": "上传成功",
  41555. })
  41556. return
  41557. } else {
  41558. c.ServeSuccessJSON(map[string]interface{}{
  41559. "failed_code": -10,
  41560. "msg": res.ErrMsg,
  41561. })
  41562. return
  41563. }
  41564. }
  41565. func (c *HisApiController) Post3506() {
  41566. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41567. data := make(map[string]interface{})
  41568. var struct3501s []models.Struct3501
  41569. var struct3501 models.Struct3501
  41570. struct3501.OrgName = miConfig.OrgName
  41571. struct3501.AccessKey = miConfig.AccessKey
  41572. struct3501.RequestUrl = miConfig.Url
  41573. struct3501.SecretKey = miConfig.SecretKey
  41574. struct3501.ManuDate = "2022-08-15"
  41575. struct3501.FixmedinsBchno = ""
  41576. struct3501.ManuLotnum = ""
  41577. struct3501.RxFlag = "0"
  41578. struct3501.ExpyEnd = "2022-08-15"
  41579. struct3501.Invdate = "2022-08-15"
  41580. struct3501.InvCnt = "20.25"
  41581. struct3501.Memo = ""
  41582. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41583. struct3501.FixmedinsHilistId = miConfig.Code
  41584. struct3501.FixmedinsHilistName = miConfig.OrgName
  41585. struct3501s = append(struct3501s, struct3501)
  41586. data["struct_3501s"] = struct3501s
  41587. client := &http.Client{}
  41588. bytesData, _ := json.Marshal(data)
  41589. var req *http.Request
  41590. if miConfig.MdtrtareaAdmvs == "320921" {
  41591. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41592. } else {
  41593. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41594. }
  41595. resp, _ := client.Do(req)
  41596. defer resp.Body.Close()
  41597. body, ioErr := ioutil.ReadAll(resp.Body)
  41598. if ioErr != nil {
  41599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41601. return
  41602. }
  41603. var respJSON map[string]interface{}
  41604. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41607. return
  41608. }
  41609. var res ResultSix
  41610. var resSix10265 ResultSix10265 //1101结果
  41611. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41612. result, _ := json.Marshal(respJSON)
  41613. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41614. utils.ErrorLog("解析失败:%v", err)
  41615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41616. return
  41617. }
  41618. res.InfRefmsgid = resSix10265.InfRefmsgid
  41619. res.Output = resSix10265.Output
  41620. res.ErrMsg = resSix10265.ErrMsg
  41621. res.Cainfo = resSix10265.Cainfo
  41622. res.WarnMsg = resSix10265.WarnMsg
  41623. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41624. res.Infcode = infocode
  41625. if infocode == 0 {
  41626. c.ServeSuccessJSON(map[string]interface{}{
  41627. "msg": "上传成功",
  41628. })
  41629. return
  41630. } else {
  41631. c.ServeSuccessJSON(map[string]interface{}{
  41632. "failed_code": -10,
  41633. "msg": res.ErrMsg,
  41634. })
  41635. return
  41636. }
  41637. }
  41638. func (c *HisApiController) Post3507() {
  41639. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41640. data := make(map[string]interface{})
  41641. var struct3501s []models.Struct3501
  41642. var struct3501 models.Struct3501
  41643. struct3501.OrgName = miConfig.OrgName
  41644. struct3501.AccessKey = miConfig.AccessKey
  41645. struct3501.RequestUrl = miConfig.Url
  41646. struct3501.SecretKey = miConfig.SecretKey
  41647. struct3501.ManuDate = "2022-08-15"
  41648. struct3501.FixmedinsBchno = ""
  41649. struct3501.ManuLotnum = ""
  41650. struct3501.RxFlag = "0"
  41651. struct3501.ExpyEnd = "2022-08-15"
  41652. struct3501.Invdate = "2022-08-15"
  41653. struct3501.InvCnt = "20.25"
  41654. struct3501.Memo = ""
  41655. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41656. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41657. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41658. struct3501s = append(struct3501s, struct3501)
  41659. data["struct_3501s"] = struct3501s
  41660. client := &http.Client{}
  41661. bytesData, _ := json.Marshal(data)
  41662. var req *http.Request
  41663. if miConfig.MdtrtareaAdmvs == "320921" {
  41664. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41665. } else {
  41666. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41667. }
  41668. resp, _ := client.Do(req)
  41669. defer resp.Body.Close()
  41670. body, ioErr := ioutil.ReadAll(resp.Body)
  41671. if ioErr != nil {
  41672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41674. return
  41675. }
  41676. var respJSON map[string]interface{}
  41677. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41680. return
  41681. }
  41682. var res ResultSix
  41683. var resSix10265 ResultSix10265 //1101结果
  41684. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41685. result, _ := json.Marshal(respJSON)
  41686. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41687. utils.ErrorLog("解析失败:%v", err)
  41688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41689. return
  41690. }
  41691. res.InfRefmsgid = resSix10265.InfRefmsgid
  41692. res.Output = resSix10265.Output
  41693. res.ErrMsg = resSix10265.ErrMsg
  41694. res.Cainfo = resSix10265.Cainfo
  41695. res.WarnMsg = resSix10265.WarnMsg
  41696. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41697. res.Infcode = infocode
  41698. if infocode == 0 {
  41699. c.ServeSuccessJSON(map[string]interface{}{
  41700. "msg": "上传成功",
  41701. })
  41702. return
  41703. } else {
  41704. c.ServeSuccessJSON(map[string]interface{}{
  41705. "failed_code": -10,
  41706. "msg": res.ErrMsg,
  41707. })
  41708. return
  41709. }
  41710. }
  41711. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41712. // WebSocket服务器地址
  41713. serverURL := "ws://127.0.0.1:8899"
  41714. // 解析WebSocket服务器地址
  41715. u, err := url.Parse(serverURL)
  41716. if err != nil {
  41717. }
  41718. // 建立WebSocket连接
  41719. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41720. if err != nil {
  41721. }
  41722. defer conn.Close()
  41723. input2 := make(map[string]interface{})
  41724. input := make(map[string]interface{})
  41725. inputData := make(map[string]interface{})
  41726. inputData["orgId"] = code
  41727. inputData["businessType"] = "01101"
  41728. inputData["operatorId"] = operator_id
  41729. inputData["operatorName"] = operator_name
  41730. inputData["officeId"] = "001"
  41731. inputData["officeName"] = "血透室"
  41732. inputData["deviceType"] = ""
  41733. input["data"] = inputData
  41734. input["orgId"] = code
  41735. input["transType"] = "ec.query"
  41736. //if md == ""
  41737. if md[:4] == "4403" {
  41738. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41739. } else if md[:4] == "4401" {
  41740. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41741. } else {
  41742. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41743. }
  41744. input2["indata"] = input
  41745. fmt.Println(input2)
  41746. bytesData, _ := json.Marshal(input2)
  41747. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41748. if err != nil {
  41749. fmt.Println(err)
  41750. }
  41751. // 接收消息
  41752. _, receivedMessage, err := conn.ReadMessage()
  41753. if err != nil {
  41754. fmt.Println(err)
  41755. }
  41756. return "", string(receivedMessage)
  41757. }
  41758. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41759. // WebSocket服务器地址
  41760. serverURL := "ws://127.0.0.1:8899"
  41761. // 解析WebSocket服务器地址
  41762. u, err := url.Parse(serverURL)
  41763. if err != nil {
  41764. }
  41765. // 建立WebSocket连接
  41766. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41767. if err != nil {
  41768. }
  41769. defer conn.Close()
  41770. input2 := make(map[string]interface{})
  41771. input := make(map[string]interface{})
  41772. inputData := make(map[string]interface{})
  41773. inputData["orgId"] = code
  41774. inputData["businessType"] = "01101"
  41775. inputData["operatorId"] = operator_id
  41776. inputData["operatorName"] = operator_name
  41777. inputData["officeId"] = "001"
  41778. inputData["officeName"] = "血透室"
  41779. inputData["deviceType"] = ""
  41780. input["data"] = inputData
  41781. input["orgId"] = code
  41782. input["transType"] = "ec.query"
  41783. //if md == ""
  41784. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41785. input2["indata"] = input
  41786. fmt.Println(input2)
  41787. bytesData, _ := json.Marshal(input2)
  41788. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41789. if err != nil {
  41790. fmt.Println(err)
  41791. }
  41792. // 接收消息
  41793. _, receivedMessage, err := conn.ReadMessage()
  41794. if err != nil {
  41795. fmt.Println(err)
  41796. }
  41797. return "", string(receivedMessage)
  41798. }
  41799. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41800. // WebSocket服务器地址
  41801. serverURL := "ws://127.0.0.1:8899"
  41802. // 解析WebSocket服务器地址
  41803. u, err := url.Parse(serverURL)
  41804. if err != nil {
  41805. }
  41806. // 建立WebSocket连接
  41807. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41808. if err != nil {
  41809. }
  41810. defer conn.Close()
  41811. input2 := make(map[string]interface{})
  41812. input := make(map[string]interface{})
  41813. inputData := make(map[string]interface{})
  41814. inputData["orgId"] = code
  41815. inputData["businessType"] = "01301"
  41816. inputData["operatorId"] = operator_id
  41817. inputData["operatorName"] = operator_name
  41818. inputData["officeId"] = "001"
  41819. inputData["officeName"] = "血透室"
  41820. inputData["deviceType"] = ""
  41821. input["data"] = inputData
  41822. input["orgId"] = code
  41823. input["transType"] = "ec.query"
  41824. //if md == ""
  41825. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41826. input2["indata"] = input
  41827. fmt.Println(input2)
  41828. bytesData, _ := json.Marshal(input2)
  41829. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41830. if err != nil {
  41831. fmt.Println(err)
  41832. }
  41833. // 接收消息
  41834. _, receivedMessage, err := conn.ReadMessage()
  41835. if err != nil {
  41836. fmt.Println(err)
  41837. }
  41838. return "", string(receivedMessage)
  41839. }
  41840. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41841. // WebSocket服务器地址
  41842. serverURL := "ws://127.0.0.1:8899"
  41843. // 解析WebSocket服务器地址
  41844. u, err := url.Parse(serverURL)
  41845. if err != nil {
  41846. }
  41847. // 建立WebSocket连接
  41848. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41849. if err != nil {
  41850. }
  41851. defer conn.Close()
  41852. input2 := make(map[string]interface{})
  41853. input := make(map[string]interface{})
  41854. inputData := make(map[string]interface{})
  41855. inputData["orgId"] = code
  41856. inputData["businessType"] = "01103"
  41857. inputData["operatorId"] = operator_id
  41858. inputData["operatorName"] = operator_name
  41859. inputData["officeId"] = "001"
  41860. inputData["officeName"] = "血透室"
  41861. inputData["deviceType"] = ""
  41862. input["data"] = inputData
  41863. input["orgId"] = code
  41864. input["transType"] = "ec.query"
  41865. //if md ==
  41866. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41867. input2["indata"] = input
  41868. fmt.Println(input2)
  41869. bytesData, _ := json.Marshal(input2)
  41870. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41871. if err != nil {
  41872. fmt.Println(err)
  41873. }
  41874. // 接收消息
  41875. _, receivedMessage, err := conn.ReadMessage()
  41876. if err != nil {
  41877. fmt.Println(err)
  41878. }
  41879. return "", string(receivedMessage)
  41880. }
  41881. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41882. // WebSocket服务器地址
  41883. serverURL := "ws://127.0.0.1:8899"
  41884. // 解析WebSocket服务器地址
  41885. u, err := url.Parse(serverURL)
  41886. if err != nil {
  41887. }
  41888. // 建立WebSocket连接
  41889. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41890. if err != nil {
  41891. }
  41892. defer conn.Close()
  41893. input2 := make(map[string]interface{})
  41894. input := make(map[string]interface{})
  41895. inputData := make(map[string]interface{})
  41896. inputData["orgId"] = code
  41897. inputData["businessType"] = "01101"
  41898. inputData["operatorId"] = operator_id
  41899. inputData["operatorName"] = operator_name
  41900. inputData["officeId"] = "001"
  41901. inputData["officeName"] = "血透室"
  41902. inputData["deviceType"] = ""
  41903. input["data"] = inputData
  41904. input["orgId"] = code
  41905. input["transType"] = "ec.query"
  41906. //if md == ""
  41907. if md[:4] == "4403" {
  41908. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41909. } else if md[:4] == "4401" {
  41910. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41911. } else {
  41912. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41913. }
  41914. input2["indata"] = input
  41915. fmt.Println(input2)
  41916. bytesData, _ := json.Marshal(input2)
  41917. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41918. if err != nil {
  41919. fmt.Println(err)
  41920. }
  41921. // 接收消息
  41922. _, receivedMessage, err := conn.ReadMessage()
  41923. if err != nil {
  41924. fmt.Println(err)
  41925. }
  41926. return "", string(receivedMessage)
  41927. }
  41928. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41929. // WebSocket服务器地址
  41930. serverURL := "ws://127.0.0.1:8899"
  41931. // 解析WebSocket服务器地址
  41932. u, err := url.Parse(serverURL)
  41933. if err != nil {
  41934. }
  41935. // 建立WebSocket连接
  41936. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41937. if err != nil {
  41938. }
  41939. defer conn.Close()
  41940. input2 := make(map[string]interface{})
  41941. input := make(map[string]interface{})
  41942. inputData := make(map[string]interface{})
  41943. inputData["orgId"] = code
  41944. inputData["businessType"] = "01301"
  41945. inputData["operatorId"] = operator_id
  41946. inputData["operatorName"] = operator_name
  41947. inputData["officeId"] = "001"
  41948. inputData["officeName"] = "血透室"
  41949. inputData["deviceType"] = ""
  41950. input["data"] = inputData
  41951. input["orgId"] = code
  41952. input["transType"] = "ec.query"
  41953. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41954. input2["indata"] = input
  41955. bytesData, _ := json.Marshal(input2)
  41956. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41957. if err != nil {
  41958. fmt.Println(err)
  41959. }
  41960. // 接收消息
  41961. _, receivedMessage, err := conn.ReadMessage()
  41962. if err != nil {
  41963. fmt.Println(err)
  41964. }
  41965. return "", string(receivedMessage)
  41966. }
  41967. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41968. newArr = make([]string, 0)
  41969. for i := 0; i < len(arr); i++ {
  41970. repeat := false
  41971. for j := i + 1; j < len(arr); j++ {
  41972. if arr[i] == arr[j] {
  41973. repeat = true
  41974. break
  41975. }
  41976. }
  41977. if !repeat {
  41978. newArr = append(newArr, arr[i])
  41979. }
  41980. }
  41981. return
  41982. }
  41983. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41984. if len(idNumber) != 18 {
  41985. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41986. }
  41987. // 提取出生日期
  41988. year, err := strconv.Atoi(idNumber[6:10])
  41989. if err != nil {
  41990. return "", 0, err
  41991. }
  41992. month, err := strconv.Atoi(idNumber[10:12])
  41993. if err != nil {
  41994. return "", 0, err
  41995. }
  41996. day, err := strconv.Atoi(idNumber[12:14])
  41997. if err != nil {
  41998. return "", 0, err
  41999. }
  42000. // 格式化生日字符串
  42001. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  42002. birthdateFormatted := birthdate.Format("2006-01-02")
  42003. // 计算年龄
  42004. today := time.Now()
  42005. age := today.Year() - birthdate.Year()
  42006. if today.YearDay() < birthdate.YearDay() {
  42007. age--
  42008. }
  42009. return birthdateFormatted, age, nil
  42010. }
  42011. // 从身份证号码中提取出生年月日
  42012. func getBirthDateFromIDCard(idCard string) (string, error) {
  42013. // 身份证号码长度应为18位
  42014. if len(idCard) != 18 {
  42015. return "", fmt.Errorf("身份证号码长度应为18位")
  42016. }
  42017. // 提取出生日期部分 (YYYYMMDD)
  42018. birthDateStr := idCard[6:14]
  42019. // 解析出生日期
  42020. birthDate, err := time.Parse("20060102", birthDateStr)
  42021. if err != nil {
  42022. return "", fmt.Errorf("解析出生日期失败: %v", err)
  42023. }
  42024. // 格式化出生日期为 YYYY-MM-DD
  42025. formattedDate := birthDate.Format("2006-01-02")
  42026. return formattedDate, nil
  42027. }