his_api_controller.go 1.6MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. //"encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. //beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. //beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. //beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. //beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. //beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. //beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. //beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  116. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  117. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  118. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  119. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  120. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  121. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  122. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  123. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  124. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  125. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  126. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  127. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  128. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  129. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  130. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  131. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  132. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  133. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  134. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  135. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  136. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  137. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  138. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  139. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  140. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  141. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  142. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  143. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  144. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  145. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  146. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  147. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  148. //库盘和变更
  149. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  150. //删除库盘和变更
  151. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  152. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  153. //药品变更
  154. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  155. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  156. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  157. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  158. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  159. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  160. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  161. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  162. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  163. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  164. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  165. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  166. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  167. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  168. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  169. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  170. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  171. }
  172. func (c *HisApiController) Get3201() {
  173. adminUser := c.GetAdminUserInfo()
  174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  175. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  176. var response Response
  177. if err := json.Unmarshal([]byte(result), &response); err != nil {
  178. fmt.Println("Error decoding JSON:", err)
  179. return
  180. }
  181. }
  182. func (c *HisApiController) TestNet() {
  183. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  184. //return
  185. c.ServeSuccessJSON(map[string]interface{}{
  186. "msg": "成功",
  187. })
  188. }
  189. func (c *HisApiController) Get3508() {
  190. admin_user_id, _ := c.GetInt64("admin_user_id")
  191. drug_id, _ := c.GetInt64("id")
  192. start_time := c.GetString("start_time")
  193. end_time := c.GetString("end_time")
  194. adminUser := c.GetAdminUserInfo()
  195. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  197. drug, _ := service.GetDrugByID(drug_id)
  198. var struct3508 models.Struct3508
  199. struct3508.OrgName = miConfig.OrgName
  200. struct3508.FixmedinsCode = miConfig.Code
  201. struct3508.AccessKey = miConfig.AccessKey
  202. struct3508.Opter = curRoles.UserName
  203. struct3508.RequestUrl = miConfig.Url
  204. struct3508.Url = miConfig.Url
  205. struct3508.AppId = miConfig.Cainfo
  206. struct3508.AppSecret = miConfig.AppSecret
  207. struct3508.Enckey = miConfig.EncKey
  208. struct3508.SignKey = miConfig.SignKey
  209. struct3508.SecretKey = miConfig.SecretKey
  210. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  211. struct3508.Begndate = start_time
  212. struct3508.Enddate = end_time
  213. result1, result2, _ := service.FJyb3508(struct3508)
  214. saveLog(result1, result2, "3508", "3508")
  215. var res models.Result3508
  216. var respJSON2 map[string]interface{}
  217. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. userJSONBytes2, _ := json.Marshal(respJSON2)
  223. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  224. utils.ErrorLog("解析失败:%v", err)
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  226. return
  227. }
  228. if res.Infcode == -1 {
  229. c.ServeSuccessJSON(map[string]interface{}{
  230. "failed_code": -10,
  231. "msg": res.ErrMsg,
  232. })
  233. } else {
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "info": res.Output,
  236. })
  237. }
  238. }
  239. func (c *HisApiController) Get3509() {
  240. admin_user_id, _ := c.GetInt64("admin_user_id")
  241. drug_id, _ := c.GetInt64("id")
  242. start_time := c.GetString("start_time")
  243. end_time := c.GetString("end_time")
  244. adminUser := c.GetAdminUserInfo()
  245. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  247. drug, _ := service.GetDrugByID(drug_id)
  248. var struct3508 models.Struct3509
  249. struct3508.OrgName = miConfig.OrgName
  250. struct3508.FixmedinsCode = miConfig.Code
  251. struct3508.AccessKey = miConfig.AccessKey
  252. struct3508.Opter = curRoles.UserName
  253. struct3508.RequestUrl = miConfig.Url
  254. struct3508.Url = miConfig.Url
  255. struct3508.AppId = miConfig.Cainfo
  256. struct3508.AppSecret = miConfig.AppSecret
  257. struct3508.Enckey = miConfig.EncKey
  258. struct3508.SignKey = miConfig.SignKey
  259. struct3508.SecretKey = miConfig.SecretKey
  260. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  261. struct3508.Begndate = start_time
  262. struct3508.Enddate = end_time
  263. result1, result2, _ := service.FJyb3509(struct3508)
  264. saveLog(result1, result2, "3509", "3509")
  265. var res models.Result3509
  266. var respJSON2 map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. userJSONBytes2, _ := json.Marshal(respJSON2)
  273. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  274. utils.ErrorLog("解析失败:%v", err)
  275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  276. return
  277. }
  278. if res.Infcode == -1 {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "failed_code": -10,
  281. "msg": res.ErrMsg,
  282. })
  283. } else {
  284. c.ServeSuccessJSON(map[string]interface{}{
  285. "info": res.Output,
  286. })
  287. }
  288. }
  289. func (c *HisApiController) Get3510() {
  290. admin_user_id, _ := c.GetInt64("admin_user_id")
  291. drug_id, _ := c.GetInt64("id")
  292. start_time := c.GetString("start_time")
  293. end_time := c.GetString("end_time")
  294. adminUser := c.GetAdminUserInfo()
  295. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  297. drug, _ := service.GetDrugByID(drug_id)
  298. var struct3508 models.Struct3510
  299. struct3508.FixmedinsCode = miConfig.Code
  300. struct3508.OrgName = miConfig.OrgName
  301. struct3508.AccessKey = miConfig.AccessKey
  302. struct3508.Opter = curRoles.UserName
  303. struct3508.RequestUrl = miConfig.Url
  304. struct3508.Url = miConfig.Url
  305. struct3508.AppId = miConfig.Cainfo
  306. struct3508.AppSecret = miConfig.AppSecret
  307. struct3508.Enckey = miConfig.EncKey
  308. struct3508.SignKey = miConfig.SignKey
  309. struct3508.SecretKey = miConfig.SecretKey
  310. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  311. struct3508.Begndate = start_time
  312. struct3508.Enddate = end_time
  313. result1, result2, _ := service.FJyb3510(struct3508)
  314. saveLog(result1, result2, "3510", "3510")
  315. var res models.Result3510
  316. var respJSON2 map[string]interface{}
  317. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  320. return
  321. }
  322. userJSONBytes2, _ := json.Marshal(respJSON2)
  323. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  324. utils.ErrorLog("解析失败:%v", err)
  325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  326. return
  327. }
  328. if res.Infcode == -1 {
  329. c.ServeSuccessJSON(map[string]interface{}{
  330. "failed_code": -10,
  331. "msg": res.ErrMsg,
  332. })
  333. } else {
  334. c.ServeSuccessJSON(map[string]interface{}{
  335. "info": res.Output,
  336. })
  337. }
  338. }
  339. func (c *HisApiController) Get3511() {
  340. admin_user_id, _ := c.GetInt64("admin_user_id")
  341. drug_id, _ := c.GetInt64("id")
  342. start_time := c.GetString("start_time")
  343. end_time := c.GetString("end_time")
  344. adminUser := c.GetAdminUserInfo()
  345. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  347. drug, _ := service.GetDrugByID(drug_id)
  348. var struct3508 models.Struct3511
  349. struct3508.FixmedinsCode = miConfig.Code
  350. struct3508.OrgName = miConfig.OrgName
  351. struct3508.AccessKey = miConfig.AccessKey
  352. struct3508.Opter = curRoles.UserName
  353. struct3508.RequestUrl = miConfig.Url
  354. struct3508.Url = miConfig.Url
  355. struct3508.AppId = miConfig.Cainfo
  356. struct3508.AppSecret = miConfig.AppSecret
  357. struct3508.Enckey = miConfig.EncKey
  358. struct3508.SignKey = miConfig.SignKey
  359. struct3508.SecretKey = miConfig.SecretKey
  360. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  361. struct3508.Begndate = start_time
  362. struct3508.Enddate = end_time
  363. result1, result2, _ := service.FJyb3511(struct3508)
  364. saveLog(result1, result2, "3511", "3511")
  365. var res models.Result3511
  366. var respJSON2 map[string]interface{}
  367. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  370. return
  371. }
  372. userJSONBytes2, _ := json.Marshal(respJSON2)
  373. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  374. utils.ErrorLog("解析失败:%v", err)
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. if res.Infcode == -1 {
  379. c.ServeSuccessJSON(map[string]interface{}{
  380. "failed_code": -10,
  381. "msg": res.ErrMsg,
  382. })
  383. } else {
  384. c.ServeSuccessJSON(map[string]interface{}{
  385. "info": res.Output,
  386. })
  387. }
  388. }
  389. func (c *HisApiController) Get3512() {
  390. admin_user_id, _ := c.GetInt64("admin_user_id")
  391. drug_id, _ := c.GetInt64("id")
  392. start_time := c.GetString("start_time")
  393. end_time := c.GetString("end_time")
  394. adminUser := c.GetAdminUserInfo()
  395. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  397. drug, _ := service.GetDrugByID(drug_id)
  398. var struct3508 models.Struct3512
  399. struct3508.FixmedinsCode = miConfig.Code
  400. struct3508.OrgName = miConfig.OrgName
  401. struct3508.AccessKey = miConfig.AccessKey
  402. struct3508.Opter = curRoles.UserName
  403. struct3508.RequestUrl = miConfig.Url
  404. struct3508.Url = miConfig.Url
  405. struct3508.AppId = miConfig.Cainfo
  406. struct3508.AppSecret = miConfig.AppSecret
  407. struct3508.Enckey = miConfig.EncKey
  408. struct3508.SignKey = miConfig.SignKey
  409. struct3508.SecretKey = miConfig.SecretKey
  410. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  411. struct3508.Begndate = start_time
  412. struct3508.Enddate = end_time
  413. result1, result2, _ := service.FJyb3512(struct3508)
  414. saveLog(result1, result2, "3512", "3512")
  415. var res models.Result3512
  416. var respJSON2 map[string]interface{}
  417. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. userJSONBytes2, _ := json.Marshal(respJSON2)
  423. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == -1 {
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "failed_code": -10,
  431. "msg": res.ErrMsg,
  432. })
  433. } else {
  434. c.ServeSuccessJSON(map[string]interface{}{
  435. "info": res.Output,
  436. })
  437. }
  438. }
  439. func (c *HisApiController) Get3513() {
  440. admin_user_id, _ := c.GetInt64("admin_user_id")
  441. drug_id, _ := c.GetInt64("id")
  442. start_time := c.GetString("start_time")
  443. end_time := c.GetString("end_time")
  444. adminUser := c.GetAdminUserInfo()
  445. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  447. drug, _ := service.GetDrugByID(drug_id)
  448. var struct3508 models.Struct3513
  449. struct3508.FixmedinsCode = miConfig.Code
  450. struct3508.OrgName = miConfig.OrgName
  451. struct3508.AccessKey = miConfig.AccessKey
  452. struct3508.Opter = curRoles.UserName
  453. struct3508.RequestUrl = miConfig.Url
  454. struct3508.Url = miConfig.Url
  455. struct3508.AppId = miConfig.Cainfo
  456. struct3508.AppSecret = miConfig.AppSecret
  457. struct3508.Enckey = miConfig.EncKey
  458. struct3508.SignKey = miConfig.SignKey
  459. struct3508.SecretKey = miConfig.SecretKey
  460. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  461. struct3508.Begndate = start_time
  462. struct3508.Enddate = end_time
  463. result1, result2, _ := service.FJyb3513(struct3508)
  464. saveLog(result1, result2, "3513", "3513")
  465. var res models.Result3513
  466. var respJSON2 map[string]interface{}
  467. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  470. return
  471. }
  472. userJSONBytes2, _ := json.Marshal(respJSON2)
  473. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  474. utils.ErrorLog("解析失败:%v", err)
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  476. return
  477. }
  478. if res.Infcode == -1 {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "failed_code": -10,
  481. "msg": res.ErrMsg,
  482. })
  483. } else {
  484. c.ServeSuccessJSON(map[string]interface{}{
  485. "info": res.Output,
  486. })
  487. }
  488. }
  489. func (c *HisApiController) Get35081() {
  490. admin_user_id, _ := c.GetInt64("admin_user_id")
  491. drug_id, _ := c.GetInt64("id")
  492. //start_time := c.GetString("start_time")
  493. //end_time := c.GetString("end_time")
  494. page, _ := c.GetInt("page")
  495. adminUser := c.GetAdminUserInfo()
  496. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  498. drug, _ := service.GetDrugByID(drug_id)
  499. var struct3508 models.Struct35081
  500. struct3508.FixmedinsCode = miConfig.Code
  501. struct3508.OrgName = miConfig.OrgName
  502. struct3508.AccessKey = miConfig.AccessKey
  503. struct3508.Opter = curRoles.UserName
  504. struct3508.RequestUrl = miConfig.Url
  505. struct3508.Url = miConfig.Url
  506. struct3508.AppId = miConfig.Cainfo
  507. struct3508.AppSecret = miConfig.AppSecret
  508. struct3508.Enckey = miConfig.EncKey
  509. struct3508.SignKey = miConfig.SignKey
  510. struct3508.SecretKey = miConfig.SecretKey
  511. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  512. struct3508.PageNum = page
  513. struct3508.PageSize = 10
  514. result1, result2, _ := service.FJyb35081(struct3508)
  515. saveLog(result1, result2, "35081", "35081")
  516. var res models.Result35081
  517. var respJSON2 map[string]interface{}
  518. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  521. return
  522. }
  523. userJSONBytes2, _ := json.Marshal(respJSON2)
  524. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  525. utils.ErrorLog("解析失败:%v", err)
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  527. return
  528. }
  529. if res.Infcode == -1 {
  530. c.ServeSuccessJSON(map[string]interface{}{
  531. "failed_code": -10,
  532. "msg": res.ErrMsg,
  533. })
  534. } else {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "info": res.Output,
  537. })
  538. }
  539. }
  540. func (c *HisApiController) Get35082() {
  541. admin_user_id, _ := c.GetInt64("admin_user_id")
  542. drug_id, _ := c.GetInt64("id")
  543. //start_time := c.GetString("start_time")
  544. //end_time := c.GetString("end_time")
  545. page, _ := c.GetInt("page")
  546. adminUser := c.GetAdminUserInfo()
  547. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  549. drug, _ := service.GetDrugByID(drug_id)
  550. var struct3508 models.Struct35082
  551. struct3508.FixmedinsCode = miConfig.Code
  552. struct3508.OrgName = miConfig.OrgName
  553. struct3508.AccessKey = miConfig.AccessKey
  554. struct3508.Opter = curRoles.UserName
  555. struct3508.RequestUrl = miConfig.Url
  556. struct3508.Url = miConfig.Url
  557. struct3508.AppId = miConfig.Cainfo
  558. struct3508.AppSecret = miConfig.AppSecret
  559. struct3508.Enckey = miConfig.EncKey
  560. struct3508.SignKey = miConfig.SignKey
  561. struct3508.SecretKey = miConfig.SecretKey
  562. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  563. struct3508.PageNum = page
  564. struct3508.PageSize = 10
  565. result1, result2, _ := service.FJyb35082(struct3508)
  566. saveLog(result1, result2, "35082", "35082")
  567. var res models.Result35082
  568. var respJSON2 map[string]interface{}
  569. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. userJSONBytes2, _ := json.Marshal(respJSON2)
  575. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  576. utils.ErrorLog("解析失败:%v", err)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. if res.Infcode == -1 {
  581. c.ServeSuccessJSON(map[string]interface{}{
  582. "failed_code": -10,
  583. "msg": res.ErrMsg,
  584. })
  585. } else {
  586. c.ServeSuccessJSON(map[string]interface{}{
  587. "info": res.Output,
  588. })
  589. }
  590. }
  591. func (c *HisApiController) FJ3501AND3502() {
  592. ids := c.GetString("ids")
  593. admin_user_id, _ := c.GetInt64("admin_user_id")
  594. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  595. id_arr := strings.Split(ids, ",")
  596. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  598. //库盘
  599. var errs []string
  600. for _, drug := range drugs {
  601. if drug.IsPc == 0 {
  602. var res2 ResultSix
  603. var res3 ResultSix
  604. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  605. var struct3501 models.Struct3501
  606. struct3501.Code = miConfig.Code
  607. struct3501.OrgName = miConfig.OrgName
  608. struct3501.AccessKey = miConfig.AccessKey
  609. struct3501.Opter = roles.UserName
  610. struct3501.RequestUrl = miConfig.Url
  611. struct3501.Url = miConfig.Url
  612. struct3501.AppId = miConfig.Cainfo
  613. struct3501.AppSecret = miConfig.AppSecret
  614. struct3501.Enckey = miConfig.EncKey
  615. struct3501.SignKey = miConfig.SignKey
  616. struct3501.SecretKey = miConfig.SecretKey
  617. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  618. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  620. struct3501.RxFlag = "1"
  621. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  622. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  623. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  624. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  625. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  626. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  627. struct3501.FixmedinsBchno = number
  628. struct3501.DrugTracCodg = drug.DrugCode
  629. memo := make(map[string]interface{})
  630. memo["pric"] = drug.Price
  631. bytesData, _ := json.Marshal(memo)
  632. struct3501.Memo = string(bytesData)
  633. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  634. result1, result2, _ := service.FJyb3501(struct3501)
  635. saveLog(result1, result2, "3501", "3501")
  636. //saveLog(result, requestLog, "2201", "挂号")
  637. var respJSON2 map[string]interface{}
  638. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. userJSONBytes2, _ := json.Marshal(respJSON2)
  644. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  650. data := make(map[string]interface{})
  651. data["struct_3501s"] = struct3501
  652. client := &http.Client{}
  653. bytesData, _ := json.Marshal(data)
  654. var req *http.Request
  655. if miConfig.MdtrtareaAdmvs == "320921" {
  656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  657. } else {
  658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  659. }
  660. resp, _ := client.Do(req)
  661. defer resp.Body.Close()
  662. body, ioErr := ioutil.ReadAll(resp.Body)
  663. if ioErr != nil {
  664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  665. }
  666. var respJSON map[string]interface{}
  667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. var resSix10265 ResultSix10265 //1101结果
  673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  674. result, _ := json.Marshal(respJSON)
  675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  676. utils.ErrorLog("解析失败:%v", err)
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  678. return
  679. }
  680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  681. res2.Output = resSix10265.Output
  682. res2.ErrMsg = resSix10265.ErrMsg
  683. res2.Cainfo = resSix10265.Cainfo
  684. res2.WarnMsg = resSix10265.WarnMsg
  685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  686. res2.Infcode = infocode
  687. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  688. data := make(map[string]interface{})
  689. data["struct_3501s"] = struct3501
  690. client := &http.Client{}
  691. bytesData, _ := json.Marshal(data)
  692. var req *http.Request
  693. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  694. resp, _ := client.Do(req)
  695. defer resp.Body.Close()
  696. body, ioErr := ioutil.ReadAll(resp.Body)
  697. if ioErr != nil {
  698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. var resSix10265 ResultSix10265 //1101结果
  707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  708. result, _ := json.Marshal(respJSON)
  709. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  710. utils.ErrorLog("解析失败:%v", err)
  711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  712. return
  713. }
  714. res2.InfRefmsgid = resSix10265.InfRefmsgid
  715. res2.Output = resSix10265.Output
  716. res2.ErrMsg = resSix10265.ErrMsg
  717. res2.Cainfo = resSix10265.Cainfo
  718. res2.WarnMsg = resSix10265.WarnMsg
  719. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  720. res2.Infcode = infocode
  721. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  722. data := make(map[string]interface{})
  723. data["struct_3501s"] = struct3501
  724. client := &http.Client{}
  725. bytesData, _ := json.Marshal(data)
  726. var req *http.Request
  727. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  728. resp, _ := client.Do(req)
  729. defer resp.Body.Close()
  730. body, ioErr := ioutil.ReadAll(resp.Body)
  731. if ioErr != nil {
  732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return
  739. }
  740. var resSix10265 ResultSix10265 //1101结果
  741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  742. result, _ := json.Marshal(respJSON)
  743. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  744. utils.ErrorLog("解析失败:%v", err)
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. res2.InfRefmsgid = resSix10265.InfRefmsgid
  749. res2.Output = resSix10265.Output
  750. res2.ErrMsg = resSix10265.ErrMsg
  751. res2.Cainfo = resSix10265.Cainfo
  752. res2.WarnMsg = resSix10265.WarnMsg
  753. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  754. res2.Infcode = infocode
  755. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  756. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  757. saveLog(result1, result2, "3501", "3501")
  758. //saveLog(result, requestLog, "2201", "挂号")
  759. var respJSON2 map[string]interface{}
  760. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. userJSONBytes2, _ := json.Marshal(respJSON2)
  766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  767. utils.ErrorLog("解析失败:%v", err)
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  769. return
  770. }
  771. }
  772. if res2.Infcode != -1 {
  773. drug.IsPc = 1
  774. drug.Bchno = number
  775. drug.PcDate = time.Now().Unix()
  776. err := service.SaveW(drug)
  777. if err == nil {
  778. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  779. var struct3502 models.Struct3502
  780. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  781. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  783. struct3502.FixmedinsCode = miConfig.Code
  784. struct3502.Code = miConfig.Code
  785. struct3502.RxFlag = "0"
  786. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  787. struct3502.OrgName = miConfig.OrgName
  788. struct3502.Opter = roles.UserName
  789. struct3502.AccessKey = miConfig.AccessKey
  790. struct3502.RequestUrl = miConfig.Url
  791. struct3502.SecretKey = miConfig.SecretKey
  792. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  793. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  794. struct3502.Url = miConfig.Url
  795. struct3502.AppId = miConfig.Cainfo
  796. struct3502.AppSecret = miConfig.AppSecret
  797. struct3502.Enckey = miConfig.EncKey
  798. struct3502.SignKey = miConfig.SignKey
  799. struct3502.SecretKey = miConfig.SecretKey
  800. struct3502.DrugTracCodg = drug.DrugCode
  801. struct3502.Memo = ""
  802. struct3502.InvChgType = "108"
  803. struct3502.FixmedinsBchno = bg_number
  804. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  805. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  806. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  807. result11, result22, _ := service.FJyb3502(struct3502)
  808. saveLog(result11, result22, "3502", "3502")
  809. var respJSON3 map[string]interface{}
  810. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. userJSONBytes3, _ := json.Marshal(respJSON3)
  816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  817. utils.ErrorLog("解析失败:%v", err)
  818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  819. return
  820. }
  821. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  822. data := make(map[string]interface{})
  823. data["struct_3502s"] = struct3502
  824. client := &http.Client{}
  825. bytesData, _ := json.Marshal(data)
  826. var req *http.Request
  827. if miConfig.MdtrtareaAdmvs == "320921" {
  828. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  829. } else {
  830. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  831. }
  832. resp, _ := client.Do(req)
  833. defer resp.Body.Close()
  834. body, ioErr := ioutil.ReadAll(resp.Body)
  835. if ioErr != nil {
  836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  837. }
  838. var respJSON map[string]interface{}
  839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  842. return
  843. }
  844. var resSix10265 ResultSix10265 //1101结果
  845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  846. result, _ := json.Marshal(respJSON)
  847. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  848. utils.ErrorLog("解析失败:%v", err)
  849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  850. return
  851. }
  852. res3.InfRefmsgid = resSix10265.InfRefmsgid
  853. res3.Output = resSix10265.Output
  854. res3.ErrMsg = resSix10265.ErrMsg
  855. res3.Cainfo = resSix10265.Cainfo
  856. res3.WarnMsg = resSix10265.WarnMsg
  857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  858. res3.Infcode = infocode
  859. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  860. data := make(map[string]interface{})
  861. data["struct_3502s"] = struct3502
  862. client := &http.Client{}
  863. bytesData, _ := json.Marshal(data)
  864. var req *http.Request
  865. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  866. resp, _ := client.Do(req)
  867. defer resp.Body.Close()
  868. body, ioErr := ioutil.ReadAll(resp.Body)
  869. if ioErr != nil {
  870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  871. }
  872. var respJSON map[string]interface{}
  873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  876. return
  877. }
  878. var resSix10265 ResultSix10265 //1101结果
  879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  880. result, _ := json.Marshal(respJSON)
  881. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  882. utils.ErrorLog("解析失败:%v", err)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. res3.InfRefmsgid = resSix10265.InfRefmsgid
  887. res3.Output = resSix10265.Output
  888. res3.ErrMsg = resSix10265.ErrMsg
  889. res3.Cainfo = resSix10265.Cainfo
  890. res3.WarnMsg = resSix10265.WarnMsg
  891. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  892. res3.Infcode = infocode
  893. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  894. data := make(map[string]interface{})
  895. data["struct_3501s"] = struct3501
  896. client := &http.Client{}
  897. bytesData, _ := json.Marshal(data)
  898. var req *http.Request
  899. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  900. resp, _ := client.Do(req)
  901. defer resp.Body.Close()
  902. body, ioErr := ioutil.ReadAll(resp.Body)
  903. if ioErr != nil {
  904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  905. }
  906. var respJSON map[string]interface{}
  907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  910. return
  911. }
  912. var resSix10265 ResultSix10265 //1101结果
  913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  914. result, _ := json.Marshal(respJSON)
  915. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  916. utils.ErrorLog("解析失败:%v", err)
  917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  918. return
  919. }
  920. res2.InfRefmsgid = resSix10265.InfRefmsgid
  921. res2.Output = resSix10265.Output
  922. res2.ErrMsg = resSix10265.ErrMsg
  923. res2.Cainfo = resSix10265.Cainfo
  924. res2.WarnMsg = resSix10265.WarnMsg
  925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  926. res2.Infcode = infocode
  927. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  928. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  929. saveLog(result11, result22, "3502", "3502")
  930. var respJSON3 map[string]interface{}
  931. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. userJSONBytes3, _ := json.Marshal(respJSON3)
  937. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  938. utils.ErrorLog("解析失败:%v", err)
  939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  940. return
  941. }
  942. }
  943. if res3.Infcode == -1 {
  944. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res3.ErrMsg,
  948. })
  949. } else {
  950. drug.IsBg = 1
  951. drug.BgBchno = bg_number
  952. service.SaveW(drug)
  953. }
  954. }
  955. } else {
  956. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  957. }
  958. }
  959. //变更
  960. }
  961. if len(errs) == 0 {
  962. c.ServeSuccessJSON(map[string]interface{}{
  963. "msg": "盘存变更成功",
  964. })
  965. } else {
  966. c.ServeSuccessJSON(map[string]interface{}{
  967. "failed_code": -10,
  968. "msg": errs,
  969. })
  970. }
  971. }
  972. func (c *HisApiController) DeletePCandBG() {
  973. ids := c.GetString("ids")
  974. id_arr := strings.Split(ids, ",")
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  977. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  979. var err []string
  980. for _, item := range drugs {
  981. if item.IsPc == 1 && item.IsBg == 1 {
  982. var res FJ3507Result
  983. var res2 FJ3507Result
  984. var struct3507 models.Struct3507
  985. struct3507.FixmedinsBchno = item.Bchno
  986. struct3507.InvDataType = "1"
  987. struct3507.Opter = roles.UserName
  988. struct3507.OrgName = miConfig.OrgName
  989. struct3507.AccessKey = miConfig.AccessKey
  990. struct3507.RequestUrl = miConfig.Url
  991. struct3507.FixmedinsCode = miConfig.Code
  992. struct3507.Code = miConfig.Code
  993. struct3507.SecretKey = miConfig.SecretKey
  994. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  995. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. struct3507.Url = miConfig.Url
  997. struct3507.AppId = miConfig.Cainfo
  998. struct3507.AppSecret = miConfig.AppSecret
  999. struct3507.Enckey = miConfig.EncKey
  1000. struct3507.SignKey = miConfig.SignKey
  1001. struct3507.SecretKey = miConfig.SecretKey
  1002. if miConfig.MdtrtareaAdmvs == "350500" {
  1003. result, result1, _ := service.FJyb3507(struct3507)
  1004. saveLog(result, result1, "3507", "3507")
  1005. var respJSON2 map[string]interface{}
  1006. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. userJSONBytes2, _ := json.Marshal(respJSON2)
  1012. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1013. utils.ErrorLog("解析失败:%v", err)
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1015. return
  1016. }
  1017. } else {
  1018. data := make(map[string]interface{})
  1019. data["struct_3507s"] = struct3507
  1020. client := &http.Client{}
  1021. bytesData, _ := json.Marshal(data)
  1022. var req *http.Request
  1023. if miConfig.MdtrtareaAdmvs == "320921" {
  1024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1025. } else {
  1026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1027. }
  1028. resp, _ := client.Do(req)
  1029. defer resp.Body.Close()
  1030. body, ioErr := ioutil.ReadAll(resp.Body)
  1031. if ioErr != nil {
  1032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1033. }
  1034. var respJSON map[string]interface{}
  1035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. var resSix10265 ResultSix10265 //1101结果
  1041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1042. result, _ := json.Marshal(respJSON)
  1043. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1044. utils.ErrorLog("解析失败:%v", err)
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1046. return
  1047. }
  1048. res.InfRefmsgid = resSix10265.InfRefmsgid
  1049. //res.Output = resSix10265.Output
  1050. res.ErrMsg = resSix10265.ErrMsg
  1051. res.Cainfo = resSix10265.Cainfo
  1052. res.WarnMsg = resSix10265.WarnMsg
  1053. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1054. res.Infcode = infocode
  1055. }
  1056. if res.Infcode == 0 {
  1057. item.IsPc = 0
  1058. err2 := service.SaveW(item)
  1059. if err2 == nil {
  1060. var struct3507_2 models.Struct3507
  1061. struct3507_2.OrgName = miConfig.OrgName
  1062. struct3507_2.AccessKey = miConfig.AccessKey
  1063. struct3507_2.RequestUrl = miConfig.Url
  1064. struct3507_2.Opter = roles.UserName
  1065. struct3507_2.FixmedinsCode = miConfig.Code
  1066. struct3507_2.Code = miConfig.Code
  1067. struct3507_2.SecretKey = miConfig.SecretKey
  1068. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1069. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1070. struct3507_2.Url = miConfig.Url
  1071. struct3507_2.AppId = miConfig.Cainfo
  1072. struct3507_2.AppSecret = miConfig.AppSecret
  1073. struct3507_2.Enckey = miConfig.EncKey
  1074. struct3507_2.SignKey = miConfig.SignKey
  1075. struct3507_2.SecretKey = miConfig.SecretKey
  1076. struct3507_2.FixmedinsBchno = item.BgBchno
  1077. struct3507_2.InvDataType = "2"
  1078. if miConfig.MdtrtareaAdmvs == "350500" {
  1079. result11, result22, _ := service.FJyb3507(struct3507_2)
  1080. saveLog(result11, result22, "3507", "3507")
  1081. var respJSON3 map[string]interface{}
  1082. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. userJSONBytes3, _ := json.Marshal(respJSON3)
  1088. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1089. utils.ErrorLog("解析失败:%v", err)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. } else {
  1094. data := make(map[string]interface{})
  1095. data["struct_3507s"] = struct3507_2
  1096. client := &http.Client{}
  1097. bytesData, _ := json.Marshal(data)
  1098. var req *http.Request
  1099. if miConfig.MdtrtareaAdmvs == "320921" {
  1100. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1101. } else {
  1102. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1103. }
  1104. resp, _ := client.Do(req)
  1105. defer resp.Body.Close()
  1106. body, ioErr := ioutil.ReadAll(resp.Body)
  1107. if ioErr != nil {
  1108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1109. }
  1110. var respJSON map[string]interface{}
  1111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. return
  1115. }
  1116. var resSix10265 ResultSix10265 //1101结果
  1117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1118. result, _ := json.Marshal(respJSON)
  1119. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1120. utils.ErrorLog("解析失败:%v", err)
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1122. return
  1123. }
  1124. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1125. //res2.Output = resSix10265.Output
  1126. res2.ErrMsg = resSix10265.ErrMsg
  1127. res2.Cainfo = resSix10265.Cainfo
  1128. res2.WarnMsg = resSix10265.WarnMsg
  1129. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1130. res2.Infcode = infocode
  1131. }
  1132. if res2.Infcode != -1 {
  1133. item.IsBg = 0
  1134. item.Bchno = ""
  1135. item.BgBchno = ""
  1136. item.PcDate = 0
  1137. service.SaveW(item)
  1138. } else {
  1139. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1140. }
  1141. }
  1142. } else {
  1143. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1144. }
  1145. }
  1146. if item.IsPc == 1 && item.IsBg == 0 {
  1147. var res FJ3507Result
  1148. var struct3507 models.Struct3507
  1149. struct3507.FixmedinsBchno = item.Bchno
  1150. struct3507.InvDataType = "1"
  1151. struct3507.Opter = roles.UserName
  1152. struct3507.FixmedinsCode = miConfig.Code
  1153. struct3507.Code = miConfig.Code
  1154. struct3507.OrgName = miConfig.OrgName
  1155. struct3507.AccessKey = miConfig.AccessKey
  1156. struct3507.RequestUrl = miConfig.Url
  1157. struct3507.SecretKey = miConfig.SecretKey
  1158. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1159. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1160. struct3507.Url = miConfig.Url
  1161. struct3507.AppId = miConfig.Cainfo
  1162. struct3507.AppSecret = miConfig.AppSecret
  1163. struct3507.Enckey = miConfig.EncKey
  1164. struct3507.SignKey = miConfig.SignKey
  1165. struct3507.SecretKey = miConfig.SecretKey
  1166. //result, result1, _ := service.FJyb3507(struct3507)
  1167. //saveLog(result, result1, "3507", "3507")
  1168. if miConfig.MdtrtareaAdmvs == "350500" {
  1169. result, result1, _ := service.FJyb3507(struct3507)
  1170. saveLog(result, result1, "3507", "3507")
  1171. var respJSON2 map[string]interface{}
  1172. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1175. return
  1176. }
  1177. userJSONBytes2, _ := json.Marshal(respJSON2)
  1178. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1179. utils.ErrorLog("解析失败:%v", err)
  1180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1181. return
  1182. }
  1183. } else {
  1184. data := make(map[string]interface{})
  1185. data["struct_3507s"] = struct3507
  1186. client := &http.Client{}
  1187. bytesData, _ := json.Marshal(data)
  1188. var req *http.Request
  1189. if miConfig.MdtrtareaAdmvs == "320921" {
  1190. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1191. } else {
  1192. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1193. }
  1194. resp, _ := client.Do(req)
  1195. defer resp.Body.Close()
  1196. body, ioErr := ioutil.ReadAll(resp.Body)
  1197. if ioErr != nil {
  1198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1199. }
  1200. var respJSON map[string]interface{}
  1201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. var resSix10265 ResultSix10265 //1101结果
  1207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1208. result, _ := json.Marshal(respJSON)
  1209. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1210. utils.ErrorLog("解析失败:%v", err)
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. return
  1213. }
  1214. res.InfRefmsgid = resSix10265.InfRefmsgid
  1215. //res.Output = resSix10265.Output
  1216. res.ErrMsg = resSix10265.ErrMsg
  1217. res.Cainfo = resSix10265.Cainfo
  1218. res.WarnMsg = resSix10265.WarnMsg
  1219. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1220. res.Infcode = infocode
  1221. }
  1222. if res.Infcode == 0 {
  1223. item.IsPc = 0
  1224. item.Bchno = ""
  1225. item.BgBchno = ""
  1226. item.PcDate = 0
  1227. service.SaveW(item)
  1228. } else {
  1229. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1230. }
  1231. }
  1232. if item.IsPc == 0 && item.IsBg == 1 {
  1233. var res FJ3507Result
  1234. var struct3507 models.Struct3507
  1235. struct3507.FixmedinsBchno = item.BgBchno
  1236. struct3507.InvDataType = "2"
  1237. struct3507.Opter = roles.UserName
  1238. struct3507.FixmedinsCode = miConfig.Code
  1239. struct3507.OrgName = miConfig.OrgName
  1240. struct3507.AccessKey = miConfig.AccessKey
  1241. struct3507.RequestUrl = miConfig.Url
  1242. struct3507.SecretKey = miConfig.SecretKey
  1243. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1244. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1245. struct3507.Url = miConfig.Url
  1246. struct3507.AppId = miConfig.Cainfo
  1247. struct3507.AppSecret = miConfig.AppSecret
  1248. struct3507.Enckey = miConfig.EncKey
  1249. struct3507.SignKey = miConfig.SignKey
  1250. struct3507.SecretKey = miConfig.SecretKey
  1251. //result, result1, _ := service.FJyb3507(struct3507)
  1252. //saveLog(result, result1, "3507", "3507")
  1253. if miConfig.MdtrtareaAdmvs == "350500" {
  1254. result, result1, _ := service.FJyb3507(struct3507)
  1255. saveLog(result, result1, "3507", "3507")
  1256. var respJSON2 map[string]interface{}
  1257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. userJSONBytes2, _ := json.Marshal(respJSON2)
  1263. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1264. utils.ErrorLog("解析失败:%v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. } else {
  1269. data := make(map[string]interface{})
  1270. data["struct_3507s"] = struct3507
  1271. client := &http.Client{}
  1272. bytesData, _ := json.Marshal(data)
  1273. var req *http.Request
  1274. if miConfig.MdtrtareaAdmvs == "320921" {
  1275. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1276. } else {
  1277. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1278. }
  1279. resp, _ := client.Do(req)
  1280. defer resp.Body.Close()
  1281. body, ioErr := ioutil.ReadAll(resp.Body)
  1282. if ioErr != nil {
  1283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1284. }
  1285. var respJSON map[string]interface{}
  1286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1289. return
  1290. }
  1291. var resSix10265 ResultSix10265 //1101结果
  1292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1293. result, _ := json.Marshal(respJSON)
  1294. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1295. utils.ErrorLog("解析失败:%v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. res.InfRefmsgid = resSix10265.InfRefmsgid
  1300. //res.Output = resSix10265.Output
  1301. res.ErrMsg = resSix10265.ErrMsg
  1302. res.Cainfo = resSix10265.Cainfo
  1303. res.WarnMsg = resSix10265.WarnMsg
  1304. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1305. res.Infcode = infocode
  1306. }
  1307. if res.Infcode == 0 {
  1308. item.IsBg = 0
  1309. item.Bchno = ""
  1310. item.BgBchno = ""
  1311. item.PcDate = 0
  1312. service.SaveW(item)
  1313. } else {
  1314. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1315. }
  1316. }
  1317. }
  1318. if len(err) == 0 {
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "msg": "删除盘存变更成功",
  1321. })
  1322. } else {
  1323. c.ServeSuccessJSON(map[string]interface{}{
  1324. "failed_code": -10,
  1325. "msg": err,
  1326. })
  1327. }
  1328. }
  1329. func (c *HisApiController) DeleteXSandBG() {
  1330. ids := c.GetString("ids")
  1331. id_arr := strings.Split(ids, ",")
  1332. admin_user_id, _ := c.GetInt64("admin_user_id")
  1333. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1336. var err []string
  1337. for _, item := range flows {
  1338. if item.IsSale == 1 && item.IsChange == 1 {
  1339. var res FJ3507Result
  1340. var res2 FJ3507Result
  1341. var struct3507 models.Struct3507
  1342. struct3507.FixmedinsBchno = item.Bchno
  1343. struct3507.InvDataType = "4"
  1344. struct3507.Opter = roles.UserName
  1345. struct3507.OrgName = miConfig.OrgName
  1346. struct3507.AccessKey = miConfig.AccessKey
  1347. struct3507.RequestUrl = miConfig.Url
  1348. struct3507.FixmedinsCode = miConfig.Code
  1349. struct3507.SecretKey = miConfig.SecretKey
  1350. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1351. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1352. struct3507.Url = miConfig.Url
  1353. struct3507.AppId = miConfig.Cainfo
  1354. struct3507.AppSecret = miConfig.AppSecret
  1355. struct3507.Enckey = miConfig.EncKey
  1356. struct3507.SignKey = miConfig.SignKey
  1357. struct3507.SecretKey = miConfig.SecretKey
  1358. //result, result1, _ := service.FJyb3507(struct3507)
  1359. //saveLog(result, result1, "3507", "3507")
  1360. if miConfig.MdtrtareaAdmvs == "350500" {
  1361. result, result1, _ := service.FJyb3507(struct3507)
  1362. saveLog(result, result1, "3507", "3507")
  1363. var respJSON2 map[string]interface{}
  1364. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1367. return
  1368. }
  1369. userJSONBytes2, _ := json.Marshal(respJSON2)
  1370. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1371. utils.ErrorLog("解析失败:%v", err)
  1372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1373. return
  1374. }
  1375. } else {
  1376. data := make(map[string]interface{})
  1377. data["struct_3507s"] = struct3507
  1378. client := &http.Client{}
  1379. bytesData, _ := json.Marshal(data)
  1380. var req *http.Request
  1381. if miConfig.MdtrtareaAdmvs == "320921" {
  1382. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1383. } else {
  1384. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. }
  1386. resp, _ := client.Do(req)
  1387. defer resp.Body.Close()
  1388. body, ioErr := ioutil.ReadAll(resp.Body)
  1389. if ioErr != nil {
  1390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1391. }
  1392. var respJSON map[string]interface{}
  1393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. var resSix10265 ResultSix10265 //1101结果
  1399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1400. result, _ := json.Marshal(respJSON)
  1401. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1402. utils.ErrorLog("解析失败:%v", err)
  1403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1404. return
  1405. }
  1406. res.InfRefmsgid = resSix10265.InfRefmsgid
  1407. //res.Output = resSix10265.Output
  1408. res.ErrMsg = resSix10265.ErrMsg
  1409. res.Cainfo = resSix10265.Cainfo
  1410. res.WarnMsg = resSix10265.WarnMsg
  1411. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1412. res.Infcode = infocode
  1413. }
  1414. if res.Infcode == 0 {
  1415. item.IsSale = 0
  1416. item.SaleDate = ""
  1417. item.Bchno = ""
  1418. err2 := service.SaveDF(item)
  1419. if err2 == nil {
  1420. var struct3507_2 models.Struct3507
  1421. struct3507_2.OrgName = miConfig.OrgName
  1422. struct3507_2.AccessKey = miConfig.AccessKey
  1423. struct3507_2.RequestUrl = miConfig.Url
  1424. struct3507_2.Opter = roles.UserName
  1425. struct3507_2.FixmedinsCode = miConfig.Code
  1426. struct3507_2.Code = miConfig.Code
  1427. struct3507_2.SecretKey = miConfig.SecretKey
  1428. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1429. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1430. struct3507_2.Url = miConfig.Url
  1431. struct3507_2.AppId = miConfig.Cainfo
  1432. struct3507_2.AppSecret = miConfig.AppSecret
  1433. struct3507_2.Enckey = miConfig.EncKey
  1434. struct3507_2.SignKey = miConfig.SignKey
  1435. struct3507_2.SecretKey = miConfig.SecretKey
  1436. struct3507_2.FixmedinsBchno = item.BgBchno
  1437. struct3507_2.InvDataType = "2"
  1438. if miConfig.MdtrtareaAdmvs == "350500" {
  1439. result11, result22, _ := service.FJyb3507(struct3507_2)
  1440. saveLog(result11, result22, "3507", "3507")
  1441. var respJSON3 map[string]interface{}
  1442. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1445. return
  1446. }
  1447. userJSONBytes3, _ := json.Marshal(respJSON3)
  1448. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1449. utils.ErrorLog("解析失败:%v", err)
  1450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1451. return
  1452. }
  1453. } else {
  1454. data := make(map[string]interface{})
  1455. data["struct_3507s"] = struct3507_2
  1456. client := &http.Client{}
  1457. bytesData, _ := json.Marshal(data)
  1458. var req *http.Request
  1459. if miConfig.MdtrtareaAdmvs == "320921" {
  1460. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1461. } else {
  1462. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1463. }
  1464. resp, _ := client.Do(req)
  1465. defer resp.Body.Close()
  1466. body, ioErr := ioutil.ReadAll(resp.Body)
  1467. if ioErr != nil {
  1468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1469. }
  1470. var respJSON map[string]interface{}
  1471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. var resSix10265 ResultSix10265 //1101结果
  1477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1478. result, _ := json.Marshal(respJSON)
  1479. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1480. utils.ErrorLog("解析失败:%v", err)
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1482. return
  1483. }
  1484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1485. //res.Output = resSix10265.Output
  1486. res2.ErrMsg = resSix10265.ErrMsg
  1487. res2.Cainfo = resSix10265.Cainfo
  1488. res2.WarnMsg = resSix10265.WarnMsg
  1489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1490. res2.Infcode = infocode
  1491. }
  1492. if res2.Infcode == 0 {
  1493. item.IsChange = 0
  1494. item.BgBchno = ""
  1495. service.SaveDF2(item)
  1496. } else {
  1497. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1498. }
  1499. }
  1500. } else {
  1501. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1502. }
  1503. }
  1504. if item.IsSale == 2 && item.IsChange == 1 {
  1505. var res FJ3507Result
  1506. var res2 FJ3507Result
  1507. var struct3507 models.Struct3507
  1508. struct3507.FixmedinsBchno = item.Bchno
  1509. struct3507.InvDataType = "4"
  1510. struct3507.Opter = roles.UserName
  1511. struct3507.OrgName = miConfig.OrgName
  1512. struct3507.AccessKey = miConfig.AccessKey
  1513. struct3507.RequestUrl = miConfig.Url
  1514. struct3507.FixmedinsCode = miConfig.Code
  1515. struct3507.Code = miConfig.Code
  1516. struct3507.SecretKey = miConfig.SecretKey
  1517. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1518. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1519. struct3507.Url = miConfig.Url
  1520. struct3507.AppId = miConfig.Cainfo
  1521. struct3507.AppSecret = miConfig.AppSecret
  1522. struct3507.Enckey = miConfig.EncKey
  1523. struct3507.SignKey = miConfig.SignKey
  1524. struct3507.SecretKey = miConfig.SecretKey
  1525. //result, result1, _ := service.FJyb3507(struct3507)
  1526. //saveLog(result, result1, "3507", "3507")
  1527. //
  1528. //var respJSON2 map[string]interface{}
  1529. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1530. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. //}
  1534. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1535. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1536. // utils.ErrorLog("解析失败:%v", err)
  1537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. // return
  1539. //}
  1540. if miConfig.MdtrtareaAdmvs == "350500" {
  1541. result, result1, _ := service.FJyb3507(struct3507)
  1542. saveLog(result, result1, "3507", "3507")
  1543. var respJSON2 map[string]interface{}
  1544. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. return
  1548. }
  1549. userJSONBytes2, _ := json.Marshal(respJSON2)
  1550. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1551. utils.ErrorLog("解析失败:%v", err)
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. return
  1554. }
  1555. } else {
  1556. data := make(map[string]interface{})
  1557. data["struct_3507s"] = struct3507
  1558. client := &http.Client{}
  1559. bytesData, _ := json.Marshal(data)
  1560. var req *http.Request
  1561. if miConfig.MdtrtareaAdmvs == "320921" {
  1562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1563. } else {
  1564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1565. }
  1566. resp, _ := client.Do(req)
  1567. defer resp.Body.Close()
  1568. body, ioErr := ioutil.ReadAll(resp.Body)
  1569. if ioErr != nil {
  1570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1571. }
  1572. var respJSON map[string]interface{}
  1573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. var resSix10265 ResultSix10265 //1101结果
  1579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1580. result, _ := json.Marshal(respJSON)
  1581. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1582. utils.ErrorLog("解析失败:%v", err)
  1583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1584. return
  1585. }
  1586. res.InfRefmsgid = resSix10265.InfRefmsgid
  1587. //res.Output = resSix10265.Output
  1588. res.ErrMsg = resSix10265.ErrMsg
  1589. res.Cainfo = resSix10265.Cainfo
  1590. res.WarnMsg = resSix10265.WarnMsg
  1591. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1592. res.Infcode = infocode
  1593. }
  1594. if res.Infcode == 0 {
  1595. item.IsSale = 0
  1596. item.SaleDate = ""
  1597. item.Bchno = ""
  1598. err2 := service.SaveDF(item)
  1599. if err2 == nil {
  1600. var struct3507_2 models.Struct3507
  1601. struct3507_2.OrgName = miConfig.OrgName
  1602. struct3507_2.AccessKey = miConfig.AccessKey
  1603. struct3507_2.RequestUrl = miConfig.Url
  1604. struct3507_2.Opter = roles.UserName
  1605. struct3507_2.FixmedinsCode = miConfig.Code
  1606. struct3507_2.Code = miConfig.Code
  1607. struct3507_2.SecretKey = miConfig.SecretKey
  1608. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1609. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1610. struct3507_2.Url = miConfig.Url
  1611. struct3507_2.AppId = miConfig.Cainfo
  1612. struct3507_2.AppSecret = miConfig.AppSecret
  1613. struct3507_2.Enckey = miConfig.EncKey
  1614. struct3507_2.SignKey = miConfig.SignKey
  1615. struct3507_2.SecretKey = miConfig.SecretKey
  1616. struct3507_2.FixmedinsBchno = item.BgBchno
  1617. struct3507_2.InvDataType = "2"
  1618. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1619. //saveLog(result11, result22, "3507", "3507")
  1620. //var respJSON3 map[string]interface{}
  1621. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1622. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. // return
  1625. //}
  1626. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1627. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1628. // utils.ErrorLog("解析失败:%v", err)
  1629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. // return
  1631. //}
  1632. if miConfig.MdtrtareaAdmvs == "350500" {
  1633. result11, result22, _ := service.FJyb3507(struct3507_2)
  1634. saveLog(result11, result22, "3507", "3507")
  1635. var respJSON3 map[string]interface{}
  1636. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1639. return
  1640. }
  1641. userJSONBytes3, _ := json.Marshal(respJSON3)
  1642. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1643. utils.ErrorLog("解析失败:%v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. } else {
  1648. data := make(map[string]interface{})
  1649. data["struct_3507s"] = struct3507_2
  1650. client := &http.Client{}
  1651. bytesData, _ := json.Marshal(data)
  1652. var req *http.Request
  1653. if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. var resSix10265 ResultSix10265 //1101结果
  1671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1672. result, _ := json.Marshal(respJSON)
  1673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1679. //res.Output = resSix10265.Output
  1680. res2.ErrMsg = resSix10265.ErrMsg
  1681. res2.Cainfo = resSix10265.Cainfo
  1682. res2.WarnMsg = resSix10265.WarnMsg
  1683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1684. res2.Infcode = infocode
  1685. }
  1686. if res2.Infcode == 0 {
  1687. item.IsChange = 0
  1688. item.BgBchno = ""
  1689. service.SaveDF2(item)
  1690. } else {
  1691. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1692. }
  1693. }
  1694. } else {
  1695. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1696. }
  1697. }
  1698. if item.IsSale == 1 && item.IsChange == 0 {
  1699. var res FJ3507Result
  1700. var struct3507 models.Struct3507
  1701. struct3507.FixmedinsBchno = item.Bchno
  1702. struct3507.InvDataType = "4"
  1703. struct3507.Opter = roles.UserName
  1704. struct3507.FixmedinsCode = miConfig.Code
  1705. struct3507.Code = miConfig.Code
  1706. struct3507.OrgName = miConfig.OrgName
  1707. struct3507.AccessKey = miConfig.AccessKey
  1708. struct3507.RequestUrl = miConfig.Url
  1709. struct3507.SecretKey = miConfig.SecretKey
  1710. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1711. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1712. struct3507.Url = miConfig.Url
  1713. struct3507.AppId = miConfig.Cainfo
  1714. struct3507.AppSecret = miConfig.AppSecret
  1715. struct3507.Enckey = miConfig.EncKey
  1716. struct3507.SignKey = miConfig.SignKey
  1717. struct3507.SecretKey = miConfig.SecretKey
  1718. //result, result1, _ := service.FJyb3507(struct3507)
  1719. //saveLog(result, result1, "3507", "3507")
  1720. //
  1721. //var respJSON3 map[string]interface{}
  1722. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1725. // return
  1726. //}
  1727. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1728. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1729. // utils.ErrorLog("解析失败:%v", err)
  1730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. // return
  1732. //}
  1733. if miConfig.MdtrtareaAdmvs == "350500" {
  1734. result, result1, _ := service.FJyb3507(struct3507)
  1735. saveLog(result, result1, "3507", "3507")
  1736. var respJSON2 map[string]interface{}
  1737. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1740. return
  1741. }
  1742. userJSONBytes2, _ := json.Marshal(respJSON2)
  1743. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1744. utils.ErrorLog("解析失败:%v", err)
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1746. return
  1747. }
  1748. } else {
  1749. data := make(map[string]interface{})
  1750. data["struct_3507s"] = struct3507
  1751. client := &http.Client{}
  1752. bytesData, _ := json.Marshal(data)
  1753. var req *http.Request
  1754. if miConfig.MdtrtareaAdmvs == "320921" {
  1755. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1756. } else {
  1757. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. }
  1759. resp, _ := client.Do(req)
  1760. defer resp.Body.Close()
  1761. body, ioErr := ioutil.ReadAll(resp.Body)
  1762. if ioErr != nil {
  1763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1764. }
  1765. var respJSON map[string]interface{}
  1766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. var resSix10265 ResultSix10265 //1101结果
  1772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1773. result, _ := json.Marshal(respJSON)
  1774. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. return
  1778. }
  1779. res.InfRefmsgid = resSix10265.InfRefmsgid
  1780. //res.Output = resSix10265.Output
  1781. res.ErrMsg = resSix10265.ErrMsg
  1782. res.Cainfo = resSix10265.Cainfo
  1783. res.WarnMsg = resSix10265.WarnMsg
  1784. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1785. res.Infcode = infocode
  1786. }
  1787. if res.Infcode == 0 {
  1788. item.IsSale = 0
  1789. item.SaleDate = ""
  1790. service.SaveDF(item)
  1791. } else {
  1792. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1793. }
  1794. }
  1795. if item.IsSale == 2 && item.IsChange == 0 {
  1796. var res FJ3507Result
  1797. var struct3507 models.Struct3507
  1798. struct3507.FixmedinsBchno = item.Bchno
  1799. struct3507.InvDataType = "4"
  1800. struct3507.Opter = roles.UserName
  1801. struct3507.FixmedinsCode = miConfig.Code
  1802. struct3507.Code = miConfig.Code
  1803. struct3507.OrgName = miConfig.OrgName
  1804. struct3507.AccessKey = miConfig.AccessKey
  1805. struct3507.RequestUrl = miConfig.Url
  1806. struct3507.SecretKey = miConfig.SecretKey
  1807. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1808. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1809. struct3507.Url = miConfig.Url
  1810. struct3507.AppId = miConfig.Cainfo
  1811. struct3507.AppSecret = miConfig.AppSecret
  1812. struct3507.Enckey = miConfig.EncKey
  1813. struct3507.SignKey = miConfig.SignKey
  1814. struct3507.SecretKey = miConfig.SecretKey
  1815. //result, result1, _ := service.FJyb3507(struct3507)
  1816. //saveLog(result, result1, "3507", "3507")
  1817. //
  1818. //var respJSON3 map[string]interface{}
  1819. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1820. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. // return
  1823. //}
  1824. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1825. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1826. // utils.ErrorLog("解析失败:%v", err)
  1827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. // return
  1829. //}
  1830. if miConfig.MdtrtareaAdmvs == "350500" {
  1831. result, result1, _ := service.FJyb3507(struct3507)
  1832. saveLog(result, result1, "3507", "3507")
  1833. var respJSON2 map[string]interface{}
  1834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. userJSONBytes2, _ := json.Marshal(respJSON2)
  1840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1841. utils.ErrorLog("解析失败:%v", err)
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. return
  1844. }
  1845. } else {
  1846. data := make(map[string]interface{})
  1847. data["struct_3507s"] = struct3507
  1848. client := &http.Client{}
  1849. bytesData, _ := json.Marshal(data)
  1850. var req *http.Request
  1851. if miConfig.MdtrtareaAdmvs == "320921" {
  1852. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1853. } else {
  1854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1855. }
  1856. resp, _ := client.Do(req)
  1857. defer resp.Body.Close()
  1858. body, ioErr := ioutil.ReadAll(resp.Body)
  1859. if ioErr != nil {
  1860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1861. }
  1862. var respJSON map[string]interface{}
  1863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1866. return
  1867. }
  1868. var resSix10265 ResultSix10265 //1101结果
  1869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1870. result, _ := json.Marshal(respJSON)
  1871. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1872. utils.ErrorLog("解析失败:%v", err)
  1873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1874. return
  1875. }
  1876. res.InfRefmsgid = resSix10265.InfRefmsgid
  1877. //res.Output = resSix10265.Output
  1878. res.ErrMsg = resSix10265.ErrMsg
  1879. res.Cainfo = resSix10265.Cainfo
  1880. res.WarnMsg = resSix10265.WarnMsg
  1881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1882. res.Infcode = infocode
  1883. }
  1884. if res.Infcode == 0 {
  1885. item.IsSale = 0
  1886. item.SaleDate = ""
  1887. item.Bchno = ""
  1888. service.SaveDF(item)
  1889. } else {
  1890. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1891. }
  1892. }
  1893. if item.IsSale == 0 && item.IsChange == 1 {
  1894. var res FJ3507Result
  1895. var struct3507 models.Struct3507
  1896. struct3507.FixmedinsBchno = item.BgBchno
  1897. struct3507.InvDataType = "2"
  1898. struct3507.Opter = roles.UserName
  1899. struct3507.FixmedinsCode = miConfig.Code
  1900. struct3507.Code = miConfig.Code
  1901. struct3507.OrgName = miConfig.OrgName
  1902. struct3507.AccessKey = miConfig.AccessKey
  1903. struct3507.RequestUrl = miConfig.Url
  1904. struct3507.SecretKey = miConfig.SecretKey
  1905. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1906. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1907. struct3507.Url = miConfig.Url
  1908. struct3507.AppId = miConfig.Cainfo
  1909. struct3507.AppSecret = miConfig.AppSecret
  1910. struct3507.Enckey = miConfig.EncKey
  1911. struct3507.SignKey = miConfig.SignKey
  1912. struct3507.SecretKey = miConfig.SecretKey
  1913. //result, result1, _ := service.FJyb3507(struct3507)
  1914. //saveLog(result, result1, "3507", "3507")
  1915. //
  1916. //var respJSON3 map[string]interface{}
  1917. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1918. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. // return
  1921. //}
  1922. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1923. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1924. // utils.ErrorLog("解析失败:%v", err)
  1925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. // return
  1927. //}
  1928. if miConfig.MdtrtareaAdmvs == "350500" {
  1929. result, result1, _ := service.FJyb3507(struct3507)
  1930. saveLog(result, result1, "3507", "3507")
  1931. var respJSON2 map[string]interface{}
  1932. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1935. return
  1936. }
  1937. userJSONBytes2, _ := json.Marshal(respJSON2)
  1938. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1939. utils.ErrorLog("解析失败:%v", err)
  1940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1941. return
  1942. }
  1943. } else {
  1944. data := make(map[string]interface{})
  1945. data["struct_3507s"] = struct3507
  1946. client := &http.Client{}
  1947. bytesData, _ := json.Marshal(data)
  1948. var req *http.Request
  1949. if miConfig.MdtrtareaAdmvs == "320921" {
  1950. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1951. } else {
  1952. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1953. }
  1954. resp, _ := client.Do(req)
  1955. defer resp.Body.Close()
  1956. body, ioErr := ioutil.ReadAll(resp.Body)
  1957. if ioErr != nil {
  1958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1959. }
  1960. var respJSON map[string]interface{}
  1961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1964. return
  1965. }
  1966. var resSix10265 ResultSix10265 //1101结果
  1967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1968. result, _ := json.Marshal(respJSON)
  1969. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. res.InfRefmsgid = resSix10265.InfRefmsgid
  1975. //res.Output = resSix10265.Output
  1976. res.ErrMsg = resSix10265.ErrMsg
  1977. res.Cainfo = resSix10265.Cainfo
  1978. res.WarnMsg = resSix10265.WarnMsg
  1979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1980. res.Infcode = infocode
  1981. }
  1982. if res.Infcode == 0 {
  1983. item.IsChange = 0
  1984. item.BgBchno = ""
  1985. service.SaveDF2(item)
  1986. } else {
  1987. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1988. }
  1989. }
  1990. }
  1991. if len(err) == 0 {
  1992. c.ServeSuccessJSON(map[string]interface{}{
  1993. "msg": "删除销售变更成功",
  1994. })
  1995. } else {
  1996. c.ServeSuccessJSON(map[string]interface{}{
  1997. "failed_code": -10,
  1998. "msg": err,
  1999. })
  2000. }
  2001. }
  2002. //func (c *HisApiController) BatchFJ3501AND3502() {
  2003. // //ids := c.GetString("ids")
  2004. // start_time := c.GetString("start_time")
  2005. // end_time := c.GetString("end_time")
  2006. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2007. //
  2008. //
  2009. // timeLayout := "2006-01-02"
  2010. // loc, _ := time.LoadLocation("Local")
  2011. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2012. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2013. //
  2014. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2015. // //id_arr := strings.Split(ids, ",")
  2016. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2017. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2018. // //库盘
  2019. // var errs []string
  2020. // for _, drug := range drugs {
  2021. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2022. // var res2 ResultSix
  2023. // var res3 ResultSix
  2024. //
  2025. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2026. // var struct3501 models.Struct3501
  2027. // struct3501.Code = miConfig.Code
  2028. // struct3501.OrgName = miConfig.OrgName
  2029. // struct3501.AccessKey = miConfig.AccessKey
  2030. // struct3501.Opter = roles.UserName
  2031. // struct3501.RequestUrl = miConfig.Url
  2032. // struct3501.Url = miConfig.Url
  2033. // struct3501.AppId = miConfig.Cainfo
  2034. // struct3501.AppSecret = miConfig.AppSecret
  2035. // struct3501.Enckey = miConfig.EncKey
  2036. // struct3501.SignKey = miConfig.SignKey
  2037. // struct3501.SecretKey = miConfig.SecretKey
  2038. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2039. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2041. // struct3501.RxFlag = "1"
  2042. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2043. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2044. //
  2045. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2046. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2047. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2048. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2049. // struct3501.FixmedinsBchno = number
  2050. // struct3501.DrugTracCodg = drug.DrugCode
  2051. // memo := make(map[string]interface{})
  2052. // memo["pric"] = drug.Price
  2053. // bytesData, _ := json.Marshal(memo)
  2054. // struct3501.Memo = string(bytesData)
  2055. //
  2056. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2057. //
  2058. // result1, result2, _ := service.FJyb3501(struct3501)
  2059. // saveLog(result1, result2, "3501", "3501")
  2060. // //saveLog(result, requestLog, "2201", "挂号")
  2061. //
  2062. // var respJSON2 map[string]interface{}
  2063. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. // return
  2067. // }
  2068. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2069. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2070. // utils.ErrorLog("解析失败:%v", err)
  2071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2072. // return
  2073. // }
  2074. //
  2075. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2076. // data := make(map[string]interface{})
  2077. // data["struct_3501s"] = struct3501
  2078. // client := &http.Client{}
  2079. // bytesData, _ := json.Marshal(data)
  2080. // var req *http.Request
  2081. // if miConfig.MdtrtareaAdmvs == "320921" {
  2082. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2083. // } else {
  2084. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2085. // }
  2086. //
  2087. // resp, _ := client.Do(req)
  2088. // defer resp.Body.Close()
  2089. // body, ioErr := ioutil.ReadAll(resp.Body)
  2090. // if ioErr != nil {
  2091. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2092. // }
  2093. // var respJSON map[string]interface{}
  2094. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2097. // return
  2098. // }
  2099. // var resSix10265 ResultSix10265 //1101结果
  2100. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2101. // result, _ := json.Marshal(respJSON)
  2102. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2103. // utils.ErrorLog("解析失败:%v", err)
  2104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2105. // return
  2106. // }
  2107. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2108. // res2.Output = resSix10265.Output
  2109. // res2.ErrMsg = resSix10265.ErrMsg
  2110. // res2.Cainfo = resSix10265.Cainfo
  2111. // res2.WarnMsg = resSix10265.WarnMsg
  2112. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2113. // res2.Infcode = infocode
  2114. //
  2115. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2116. // data := make(map[string]interface{})
  2117. // data["struct_3501s"] = struct3501
  2118. // client := &http.Client{}
  2119. // bytesData, _ := json.Marshal(data)
  2120. // var req *http.Request
  2121. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2122. // resp, _ := client.Do(req)
  2123. // defer resp.Body.Close()
  2124. // body, ioErr := ioutil.ReadAll(resp.Body)
  2125. // if ioErr != nil {
  2126. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2127. // }
  2128. // var respJSON map[string]interface{}
  2129. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2130. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2132. // return
  2133. // }
  2134. // var resSix10265 ResultSix10265 //1101结果
  2135. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2136. // result, _ := json.Marshal(respJSON)
  2137. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2138. // utils.ErrorLog("解析失败:%v", err)
  2139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. // return
  2141. // }
  2142. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2143. // res2.Output = resSix10265.Output
  2144. // res2.ErrMsg = resSix10265.ErrMsg
  2145. // res2.Cainfo = resSix10265.Cainfo
  2146. // res2.WarnMsg = resSix10265.WarnMsg
  2147. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2148. // res2.Infcode = infocode
  2149. //
  2150. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2151. // data := make(map[string]interface{})
  2152. // data["struct_3501s"] = struct3501
  2153. // client := &http.Client{}
  2154. // bytesData, _ := json.Marshal(data)
  2155. // var req *http.Request
  2156. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2157. // resp, _ := client.Do(req)
  2158. // defer resp.Body.Close()
  2159. // body, ioErr := ioutil.ReadAll(resp.Body)
  2160. // if ioErr != nil {
  2161. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2162. // }
  2163. // var respJSON map[string]interface{}
  2164. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2165. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. // return
  2168. // }
  2169. // var resSix10265 ResultSix10265 //1101结果
  2170. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2171. // result, _ := json.Marshal(respJSON)
  2172. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2173. // utils.ErrorLog("解析失败:%v", err)
  2174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. // return
  2176. // }
  2177. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2178. // res2.Output = resSix10265.Output
  2179. // res2.ErrMsg = resSix10265.ErrMsg
  2180. // res2.Cainfo = resSix10265.Cainfo
  2181. // res2.WarnMsg = resSix10265.WarnMsg
  2182. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2183. // res2.Infcode = infocode
  2184. //
  2185. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2186. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2187. // saveLog(result1, result2, "3501", "3501")
  2188. // //saveLog(result, requestLog, "2201", "挂号")
  2189. //
  2190. // var respJSON2 map[string]interface{}
  2191. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2192. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. // return
  2195. // }
  2196. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2197. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2198. // utils.ErrorLog("解析失败:%v", err)
  2199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2200. // return
  2201. // }
  2202. //
  2203. // }
  2204. //
  2205. // if res2.Infcode != -1 {
  2206. // drug.IsPc = 1
  2207. // drug.Bchno = number
  2208. // drug.PcDate = time.Now().Unix()
  2209. // err := service.SaveW(drug)
  2210. // if err == nil {
  2211. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2212. // var struct3502 models.Struct3502
  2213. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2214. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2216. // struct3502.FixmedinsCode = miConfig.Code
  2217. // struct3502.Code = miConfig.Code
  2218. //
  2219. // struct3502.RxFlag = "0"
  2220. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2221. // struct3502.OrgName = miConfig.OrgName
  2222. // struct3502.Opter = roles.UserName
  2223. // struct3502.AccessKey = miConfig.AccessKey
  2224. // struct3502.RequestUrl = miConfig.Url
  2225. // struct3502.SecretKey = miConfig.SecretKey
  2226. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2227. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2228. // struct3502.Url = miConfig.Url
  2229. // struct3502.AppId = miConfig.Cainfo
  2230. // struct3502.AppSecret = miConfig.AppSecret
  2231. // struct3502.Enckey = miConfig.EncKey
  2232. // struct3502.SignKey = miConfig.SignKey
  2233. // struct3502.SecretKey = miConfig.SecretKey
  2234. // struct3502.DrugTracCodg = drug.DrugCode
  2235. //
  2236. // struct3502.Memo = ""
  2237. // struct3502.InvChgType = "108"
  2238. // struct3502.FixmedinsBchno = bg_number
  2239. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2240. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2241. //
  2242. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2243. // result11, result22, _ := service.FJyb3502(struct3502)
  2244. // saveLog(result11, result22, "3502", "3502")
  2245. //
  2246. // var respJSON3 map[string]interface{}
  2247. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2248. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2250. // return
  2251. // }
  2252. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2253. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2254. // utils.ErrorLog("解析失败:%v", err)
  2255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. // return
  2257. // }
  2258. //
  2259. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2260. // data := make(map[string]interface{})
  2261. // data["struct_3502s"] = struct3502
  2262. // client := &http.Client{}
  2263. // bytesData, _ := json.Marshal(data)
  2264. // var req *http.Request
  2265. // if miConfig.MdtrtareaAdmvs == "320921" {
  2266. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2267. // } else {
  2268. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2269. // }
  2270. //
  2271. // resp, _ := client.Do(req)
  2272. // defer resp.Body.Close()
  2273. // body, ioErr := ioutil.ReadAll(resp.Body)
  2274. // if ioErr != nil {
  2275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2276. // }
  2277. // var respJSON map[string]interface{}
  2278. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. // return
  2282. // }
  2283. // var resSix10265 ResultSix10265 //1101结果
  2284. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2285. // result, _ := json.Marshal(respJSON)
  2286. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2287. // utils.ErrorLog("解析失败:%v", err)
  2288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2289. // return
  2290. // }
  2291. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2292. // res3.Output = resSix10265.Output
  2293. // res3.ErrMsg = resSix10265.ErrMsg
  2294. // res3.Cainfo = resSix10265.Cainfo
  2295. // res3.WarnMsg = resSix10265.WarnMsg
  2296. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2297. // res3.Infcode = infocode
  2298. //
  2299. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2300. //
  2301. // data := make(map[string]interface{})
  2302. // data["struct_3502s"] = struct3502
  2303. // client := &http.Client{}
  2304. // bytesData, _ := json.Marshal(data)
  2305. // var req *http.Request
  2306. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2307. // resp, _ := client.Do(req)
  2308. // defer resp.Body.Close()
  2309. // body, ioErr := ioutil.ReadAll(resp.Body)
  2310. // if ioErr != nil {
  2311. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2312. // }
  2313. // var respJSON map[string]interface{}
  2314. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2315. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. // return
  2318. // }
  2319. // var resSix10265 ResultSix10265 //1101结果
  2320. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2321. // result, _ := json.Marshal(respJSON)
  2322. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2323. // utils.ErrorLog("解析失败:%v", err)
  2324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2325. // return
  2326. // }
  2327. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2328. // res3.Output = resSix10265.Output
  2329. // res3.ErrMsg = resSix10265.ErrMsg
  2330. // res3.Cainfo = resSix10265.Cainfo
  2331. // res3.WarnMsg = resSix10265.WarnMsg
  2332. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2333. // res3.Infcode = infocode
  2334. //
  2335. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2336. //
  2337. // data := make(map[string]interface{})
  2338. // data["struct_3501s"] = struct3501
  2339. // client := &http.Client{}
  2340. // bytesData, _ := json.Marshal(data)
  2341. // var req *http.Request
  2342. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2343. // resp, _ := client.Do(req)
  2344. // defer resp.Body.Close()
  2345. // body, ioErr := ioutil.ReadAll(resp.Body)
  2346. // if ioErr != nil {
  2347. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2348. // }
  2349. // var respJSON map[string]interface{}
  2350. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2351. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. // }
  2355. // var resSix10265 ResultSix10265 //1101结果
  2356. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2357. // result, _ := json.Marshal(respJSON)
  2358. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2359. // utils.ErrorLog("解析失败:%v", err)
  2360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. // return
  2362. // }
  2363. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2364. // res2.Output = resSix10265.Output
  2365. // res2.ErrMsg = resSix10265.ErrMsg
  2366. // res2.Cainfo = resSix10265.Cainfo
  2367. // res2.WarnMsg = resSix10265.WarnMsg
  2368. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2369. // res2.Infcode = infocode
  2370. //
  2371. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2372. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2373. // saveLog(result11, result22, "3502", "3502")
  2374. //
  2375. // var respJSON3 map[string]interface{}
  2376. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2379. // return
  2380. // }
  2381. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2382. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2383. // utils.ErrorLog("解析失败:%v", err)
  2384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. // return
  2386. // }
  2387. // }
  2388. // if res3.Infcode == -1 {
  2389. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2390. // c.ServeSuccessJSON(map[string]interface{}{
  2391. // "failed_code": -10,
  2392. // "msg": res3.ErrMsg,
  2393. // })
  2394. // } else {
  2395. // drug.IsBg = 1
  2396. // drug.BgBchno = bg_number
  2397. // service.SaveW(drug)
  2398. // }
  2399. // }
  2400. // } else {
  2401. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2402. // }
  2403. // }
  2404. // //变更
  2405. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2406. // var res3 ResultSix
  2407. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2408. //
  2409. // var struct3502 models.Struct3502
  2410. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2411. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2413. // struct3502.FixmedinsCode = miConfig.Code
  2414. // struct3502.Code = miConfig.Code
  2415. //
  2416. // struct3502.Opter = roles.UserName
  2417. // struct3502.RxFlag = "0"
  2418. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2419. // struct3502.OrgName = miConfig.OrgName
  2420. // struct3502.AccessKey = miConfig.AccessKey
  2421. // struct3502.RequestUrl = miConfig.Url
  2422. // struct3502.SecretKey = miConfig.SecretKey
  2423. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2424. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2425. // struct3502.InvChgType = "108"
  2426. // struct3502.DrugTracCodg = drug.DrugCode
  2427. //
  2428. // struct3502.Url = miConfig.Url
  2429. // struct3502.AppId = miConfig.Cainfo
  2430. // struct3502.AppSecret = miConfig.AppSecret
  2431. // struct3502.Enckey = miConfig.EncKey
  2432. // struct3502.SignKey = miConfig.SignKey
  2433. // struct3502.SecretKey = miConfig.SecretKey
  2434. //
  2435. // struct3502.FixmedinsBchno = bg_number
  2436. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2437. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2438. //
  2439. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2440. // result1, result2, _ := service.FJyb3502(struct3502)
  2441. // saveLog(result1, result2, "3502", "3502")
  2442. // var respJSON3 map[string]interface{}
  2443. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2444. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2446. // return
  2447. // }
  2448. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2449. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2455. // data := make(map[string]interface{})
  2456. // data["struct_3502s"] = struct3502
  2457. // client := &http.Client{}
  2458. // bytesData, _ := json.Marshal(data)
  2459. // var req *http.Request
  2460. // if miConfig.MdtrtareaAdmvs == "320921" {
  2461. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2462. // } else {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2464. // }
  2465. // resp, _ := client.Do(req)
  2466. // defer resp.Body.Close()
  2467. // body, ioErr := ioutil.ReadAll(resp.Body)
  2468. // if ioErr != nil {
  2469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2470. // }
  2471. // var respJSON map[string]interface{}
  2472. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2473. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // var resSix10265 ResultSix10265 //1101结果
  2478. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2479. // result, _ := json.Marshal(respJSON)
  2480. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2486. // res3.Output = resSix10265.Output
  2487. // res3.ErrMsg = resSix10265.ErrMsg
  2488. // res3.Cainfo = resSix10265.Cainfo
  2489. // res3.WarnMsg = resSix10265.WarnMsg
  2490. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2491. // res3.Infcode = infocode
  2492. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2493. //
  2494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2497. //
  2498. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2499. //
  2500. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2501. // saveLog(result1, result2, "3501", "3501")
  2502. // //saveLog(result, requestLog, "2201", "挂号")
  2503. //
  2504. // var respJSON2 map[string]interface{}
  2505. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2508. // return
  2509. // }
  2510. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2511. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2512. // utils.ErrorLog("解析失败:%v", err)
  2513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2514. // return
  2515. // }
  2516. //
  2517. // }
  2518. // if res3.Infcode == -1 {
  2519. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2520. // } else {
  2521. // drug.IsBg = 1
  2522. // drug.BgBchno = bg_number
  2523. // service.SaveW(drug)
  2524. // }
  2525. // }
  2526. // }
  2527. //
  2528. // if len(errs) == 0 {
  2529. // c.ServeSuccessJSON(map[string]interface{}{
  2530. // "msg": "盘存变更成功",
  2531. // })
  2532. // } else {
  2533. // c.ServeSuccessJSON(map[string]interface{}{
  2534. // "failed_code": -10,
  2535. // "msg": errs,
  2536. // })
  2537. // }
  2538. //}
  2539. func (c *HisApiController) DeleteXSandBGTwo() {
  2540. patient_id, _ := c.GetInt64("patient_id")
  2541. admin_user_id, _ := c.GetInt64("admin_user_id")
  2542. times := c.GetString("time", "")
  2543. timeLayout := "2006-01-02"
  2544. loc, _ := time.LoadLocation("Local")
  2545. var stime, etime int64
  2546. if times == "" {
  2547. stime, etime = GetNowTime()
  2548. } else {
  2549. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2550. stime = stmp.Unix()
  2551. etime = stime + 86399
  2552. }
  2553. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2554. var flows []*models.DrugFlow
  2555. for _, item := range advicelist {
  2556. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2557. flows = append(flows, flow...)
  2558. }
  2559. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2561. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2562. var err []string
  2563. for _, item := range flows {
  2564. if item.IsSale == 1 {
  2565. var res FJ3507Result
  2566. var struct3507 models.Struct3507
  2567. struct3507.FixmedinsBchno = item.Bchno
  2568. struct3507.InvDataType = "4"
  2569. struct3507.Opter = roles.UserName
  2570. struct3507.OrgName = miConfig.OrgName
  2571. struct3507.AccessKey = miConfig.AccessKey
  2572. struct3507.RequestUrl = miConfig.Url
  2573. struct3507.FixmedinsCode = miConfig.Code
  2574. struct3507.SecretKey = miConfig.SecretKey
  2575. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2576. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2577. struct3507.Url = miConfig.Url
  2578. struct3507.AppId = miConfig.Cainfo
  2579. struct3507.AppSecret = miConfig.AppSecret
  2580. struct3507.Enckey = miConfig.EncKey
  2581. struct3507.SignKey = miConfig.SignKey
  2582. struct3507.SecretKey = miConfig.SecretKey
  2583. if miConfig.MdtrtareaAdmvs == "350500" {
  2584. result, result1, _ := service.FJyb3507(struct3507)
  2585. saveLog(result, result1, "3507", "3507")
  2586. var respJSON2 map[string]interface{}
  2587. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. return
  2591. }
  2592. userJSONBytes2, _ := json.Marshal(respJSON2)
  2593. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2594. utils.ErrorLog("解析失败:%v", err)
  2595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2596. return
  2597. }
  2598. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2599. data := make(map[string]interface{})
  2600. data["struct_3507s"] = struct3507
  2601. client := &http.Client{}
  2602. bytesData, _ := json.Marshal(data)
  2603. var req *http.Request
  2604. if miConfig.MdtrtareaAdmvs == "320921" {
  2605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2606. } else {
  2607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2608. }
  2609. resp, _ := client.Do(req)
  2610. defer resp.Body.Close()
  2611. body, ioErr := ioutil.ReadAll(resp.Body)
  2612. if ioErr != nil {
  2613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2614. }
  2615. var respJSON map[string]interface{}
  2616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2619. return
  2620. }
  2621. var resSix10265 ResultSix10265 //1101结果
  2622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2623. result, _ := json.Marshal(respJSON)
  2624. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2625. utils.ErrorLog("解析失败:%v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. res.InfRefmsgid = resSix10265.InfRefmsgid
  2630. //res.Output = resSix10265.Output
  2631. res.ErrMsg = resSix10265.ErrMsg
  2632. res.Cainfo = resSix10265.Cainfo
  2633. res.WarnMsg = resSix10265.WarnMsg
  2634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2635. res.Infcode = infocode
  2636. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2637. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2638. saveLog(result2, result1, "3507", "3507")
  2639. var respJSON2 map[string]interface{}
  2640. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. return
  2644. }
  2645. userJSONBytes2, _ := json.Marshal(respJSON2)
  2646. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2647. utils.ErrorLog("解析失败:%v", err)
  2648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. return
  2650. }
  2651. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2652. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2653. saveLog(result2, result1, "3507", "3507")
  2654. var respJSON2 map[string]interface{}
  2655. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. return
  2659. }
  2660. userJSONBytes2, _ := json.Marshal(respJSON2)
  2661. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2662. utils.ErrorLog("解析失败:%v", err)
  2663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2664. return
  2665. }
  2666. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2667. result1, result2 := service.Jxyb3507(struct3507)
  2668. saveLog(result2, result1, "3507", "3507")
  2669. var respJSON2 map[string]interface{}
  2670. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. return
  2674. }
  2675. userJSONBytes2, _ := json.Marshal(respJSON2)
  2676. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2677. utils.ErrorLog("解析失败:%v", err)
  2678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. return
  2680. }
  2681. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2682. result1, result2 := service.AHyb3507(struct3507)
  2683. saveLog(result2, result1, "3507", "3507")
  2684. var respJSON2 map[string]interface{}
  2685. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2688. return
  2689. }
  2690. userJSONBytes2, _ := json.Marshal(respJSON2)
  2691. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2692. utils.ErrorLog("解析失败:%v", err)
  2693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2694. return
  2695. }
  2696. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2697. data := make(map[string]interface{})
  2698. data["struct_3507s"] = struct3507
  2699. client := &http.Client{}
  2700. bytesData, _ := json.Marshal(data)
  2701. var req *http.Request
  2702. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2703. resp, _ := client.Do(req)
  2704. defer resp.Body.Close()
  2705. body, ioErr := ioutil.ReadAll(resp.Body)
  2706. if ioErr != nil {
  2707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2708. }
  2709. var respJSON map[string]interface{}
  2710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2712. }
  2713. var resSix10265 ResultSix10265 //1101结果
  2714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2715. result, _ := json.Marshal(respJSON)
  2716. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2717. utils.ErrorLog("解析失败:%v", err)
  2718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2719. return
  2720. }
  2721. res.InfRefmsgid = resSix10265.InfRefmsgid
  2722. res.ErrMsg = resSix10265.ErrMsg
  2723. res.Cainfo = resSix10265.Cainfo
  2724. res.WarnMsg = resSix10265.WarnMsg
  2725. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2726. res.Infcode = infocode
  2727. }
  2728. if res.Infcode == 0 {
  2729. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2730. item.IsSale = 0
  2731. item.SaleDate = ""
  2732. item.Bchno = ""
  2733. service.SaveDF(item)
  2734. } else {
  2735. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2736. }
  2737. }
  2738. }
  2739. c.ServeSuccessJSON(map[string]interface{}{
  2740. "msg": "删除销售数据成功",
  2741. })
  2742. }
  2743. // 删除
  2744. func (c *HisApiController) DeleteXSandBGThree() {
  2745. id, _ := c.GetInt64("id")
  2746. admin_user_id, _ := c.GetInt64("admin_user_id")
  2747. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2748. var flows []*models.DrugFlow
  2749. for _, item := range advicelist {
  2750. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2751. flows = append(flows, flow...)
  2752. }
  2753. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2754. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2755. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2756. var err []string
  2757. for _, item := range flows {
  2758. if item.IsSale == 1 {
  2759. var res FJ3507Result
  2760. var struct3507 models.Struct3507
  2761. struct3507.FixmedinsBchno = item.Bchno
  2762. struct3507.InvDataType = "4"
  2763. struct3507.Opter = roles.UserName
  2764. struct3507.OrgName = miConfig.OrgName
  2765. struct3507.AccessKey = miConfig.AccessKey
  2766. struct3507.RequestUrl = miConfig.Url
  2767. struct3507.FixmedinsCode = miConfig.Code
  2768. struct3507.SecretKey = miConfig.SecretKey
  2769. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2770. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2771. struct3507.Url = miConfig.Url
  2772. struct3507.AppId = miConfig.Cainfo
  2773. struct3507.AppSecret = miConfig.AppSecret
  2774. struct3507.Enckey = miConfig.EncKey
  2775. struct3507.SignKey = miConfig.SignKey
  2776. struct3507.SecretKey = miConfig.SecretKey
  2777. if miConfig.MdtrtareaAdmvs == "350500" {
  2778. result, result1, _ := service.FJyb3507(struct3507)
  2779. saveLog(result, result1, "3507", "3507")
  2780. var respJSON2 map[string]interface{}
  2781. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. return
  2785. }
  2786. userJSONBytes2, _ := json.Marshal(respJSON2)
  2787. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2788. utils.ErrorLog("解析失败:%v", err)
  2789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2790. return
  2791. }
  2792. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2793. data := make(map[string]interface{})
  2794. data["struct_3507s"] = struct3507
  2795. client := &http.Client{}
  2796. bytesData, _ := json.Marshal(data)
  2797. var req *http.Request
  2798. if miConfig.MdtrtareaAdmvs == "320921" {
  2799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2800. } else {
  2801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2802. }
  2803. resp, _ := client.Do(req)
  2804. defer resp.Body.Close()
  2805. body, ioErr := ioutil.ReadAll(resp.Body)
  2806. if ioErr != nil {
  2807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2808. }
  2809. var respJSON map[string]interface{}
  2810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. return
  2814. }
  2815. var resSix10265 ResultSix10265 //1101结果
  2816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2817. result, _ := json.Marshal(respJSON)
  2818. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2819. utils.ErrorLog("解析失败:%v", err)
  2820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2821. return
  2822. }
  2823. res.InfRefmsgid = resSix10265.InfRefmsgid
  2824. //res.Output = resSix10265.Output
  2825. res.ErrMsg = resSix10265.ErrMsg
  2826. res.Cainfo = resSix10265.Cainfo
  2827. res.WarnMsg = resSix10265.WarnMsg
  2828. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2829. res.Infcode = infocode
  2830. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2831. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2832. saveLog(result2, result1, "3507", "3507")
  2833. var respJSON2 map[string]interface{}
  2834. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2837. return
  2838. }
  2839. userJSONBytes2, _ := json.Marshal(respJSON2)
  2840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2841. utils.ErrorLog("解析失败:%v", err)
  2842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2843. return
  2844. }
  2845. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2846. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2847. saveLog(result2, result1, "3507", "3507")
  2848. var respJSON2 map[string]interface{}
  2849. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2852. return
  2853. }
  2854. userJSONBytes2, _ := json.Marshal(respJSON2)
  2855. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2856. utils.ErrorLog("解析失败:%v", err)
  2857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2858. return
  2859. }
  2860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2861. result1, result2 := service.Jxyb3507(struct3507)
  2862. saveLog(result2, result1, "3507", "3507")
  2863. var respJSON2 map[string]interface{}
  2864. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. userJSONBytes2, _ := json.Marshal(respJSON2)
  2870. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2871. utils.ErrorLog("解析失败:%v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2876. result1, result2 := service.AHyb3507(struct3507)
  2877. saveLog(result2, result1, "3507", "3507")
  2878. var respJSON2 map[string]interface{}
  2879. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2882. return
  2883. }
  2884. userJSONBytes2, _ := json.Marshal(respJSON2)
  2885. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2886. utils.ErrorLog("解析失败:%v", err)
  2887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2888. return
  2889. }
  2890. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2891. data := make(map[string]interface{})
  2892. data["struct_3507s"] = struct3507
  2893. client := &http.Client{}
  2894. bytesData, _ := json.Marshal(data)
  2895. var req *http.Request
  2896. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2897. resp, _ := client.Do(req)
  2898. defer resp.Body.Close()
  2899. body, ioErr := ioutil.ReadAll(resp.Body)
  2900. if ioErr != nil {
  2901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2902. }
  2903. var respJSON map[string]interface{}
  2904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. }
  2907. var resSix10265 ResultSix10265 //1101结果
  2908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2909. result, _ := json.Marshal(respJSON)
  2910. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. return
  2914. }
  2915. res.InfRefmsgid = resSix10265.InfRefmsgid
  2916. res.ErrMsg = resSix10265.ErrMsg
  2917. res.Cainfo = resSix10265.Cainfo
  2918. res.WarnMsg = resSix10265.WarnMsg
  2919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2920. res.Infcode = infocode
  2921. }
  2922. if res.Infcode == 0 {
  2923. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2924. item.IsSale = 0
  2925. item.SaleDate = ""
  2926. item.Bchno = ""
  2927. service.SaveDF(item)
  2928. } else {
  2929. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2930. }
  2931. }
  2932. }
  2933. c.ServeSuccessJSON(map[string]interface{}{
  2934. "msg": "删除销售数据成功",
  2935. })
  2936. }
  2937. // 获取当天起止时间戳
  2938. func GetNowTime() (int64, int64) {
  2939. t := time.Now()
  2940. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2941. timesamp := addTime.Unix()
  2942. return timesamp, timesamp + 86399
  2943. }
  2944. func (c *HisApiController) ChangeDrugfour() {
  2945. patient_id, _ := c.GetInt64("patient_id")
  2946. admin_user_id, _ := c.GetInt64("admin_user_id")
  2947. times := c.GetString("time", "")
  2948. timeLayout := "2006-01-02"
  2949. loc, _ := time.LoadLocation("Local")
  2950. var stime, etime int64
  2951. if times == "" {
  2952. stime, etime = GetNowTime()
  2953. } else {
  2954. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2955. stime = stmp.Unix()
  2956. etime = stime + 86399
  2957. }
  2958. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2959. var flows []*models.DrugFlow
  2960. for _, item := range advicelist {
  2961. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2962. flows = append(flows, flow...)
  2963. }
  2964. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2965. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2966. var err []string
  2967. for _, item := range flows {
  2968. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2969. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2970. if prescription.OrderStatus == 2 {
  2971. if item.IsSale == 0 {
  2972. var res FJ3507Result
  2973. var res3507for10188 FJ3507ResultFor10188
  2974. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2975. //进行商品销售接口
  2976. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2977. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2978. var respJSON3 map[string]interface{}
  2979. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2982. return
  2983. }
  2984. userJSONBytes3, _ := json.Marshal(respJSON3)
  2985. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2986. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2987. utils.ErrorLog("解析失败:%v", err)
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2989. return
  2990. }
  2991. //if res3507for10188.Infcode
  2992. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2993. //res.Output = resSix10265.Output
  2994. res.ErrMsg = res3507for10188.ErrMsg
  2995. res.Cainfo = res3507for10188.Cainfo
  2996. res.WarnMsg = res3507for10188.WarnMsg
  2997. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2998. res.Infcode = infocode
  2999. } else {
  3000. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3001. utils.ErrorLog("解析失败:%v", err)
  3002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3003. return
  3004. }
  3005. }
  3006. if res.Infcode == 0 {
  3007. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3008. item.IsSale = 1
  3009. item.Bchno = number
  3010. item.SaleDate = time.Now().Format("2006-01-02")
  3011. service.SaveDF(item)
  3012. } else {
  3013. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3014. }
  3015. }
  3016. } else { //还没结,提示用户去结算,并药品追溯上传
  3017. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3018. }
  3019. }
  3020. }
  3021. str := strings.Join(err, " ")
  3022. saveLog(str, str, "3505", "3505自动上传日志")
  3023. c.ServeSuccessJSON(map[string]interface{}{
  3024. "status": "1",
  3025. "msg": err,
  3026. })
  3027. }
  3028. func (c *HisApiController) ChangeDrugFive() {
  3029. id, _ := c.GetInt64("id")
  3030. admin_user_id, _ := c.GetInt64("admin_user_id")
  3031. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3032. var flows []*models.DrugFlow
  3033. for _, item := range advicelist {
  3034. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3035. flows = append(flows, flow...)
  3036. }
  3037. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3039. var err []string
  3040. for _, item := range flows {
  3041. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3042. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3043. if prescription.OrderStatus == 2 {
  3044. if item.IsSale == 0 {
  3045. var res FJ3507Result
  3046. var res3507for10188 FJ3507ResultFor10188
  3047. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3048. //进行商品销售接口
  3049. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3050. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3051. var respJSON3 map[string]interface{}
  3052. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3055. return
  3056. }
  3057. userJSONBytes3, _ := json.Marshal(respJSON3)
  3058. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3059. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3060. utils.ErrorLog("解析失败:%v", err)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3062. return
  3063. }
  3064. //if res3507for10188.Infcode
  3065. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3066. //res.Output = resSix10265.Output
  3067. res.ErrMsg = res3507for10188.ErrMsg
  3068. res.Cainfo = res3507for10188.Cainfo
  3069. res.WarnMsg = res3507for10188.WarnMsg
  3070. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3071. res.Infcode = infocode
  3072. } else {
  3073. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3074. utils.ErrorLog("解析失败:%v", err)
  3075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3076. return
  3077. }
  3078. }
  3079. if res.Infcode == 0 {
  3080. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3081. item.IsSale = 1
  3082. item.Bchno = number
  3083. item.SaleDate = time.Now().Format("2006-01-02")
  3084. service.SaveDF(item)
  3085. } else {
  3086. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3087. }
  3088. }
  3089. } else { //还没结,提示用户去结算,并药品追溯上传
  3090. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3091. }
  3092. }
  3093. }
  3094. str := strings.Join(err, " ")
  3095. saveLog(str, str, "3505", "3505自动上传日志")
  3096. c.ServeSuccessJSON(map[string]interface{}{
  3097. "status": "1",
  3098. "msg": err,
  3099. })
  3100. }
  3101. //func (c *HisApiController) ChangeDrugfour() {
  3102. // patient_id, _ := c.GetInt64("patient_id")
  3103. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3104. // //id_arr := strings.Split(ids, ",")
  3105. // times := c.GetString("time", "")
  3106. // timeLayout := "2006-01-02"
  3107. // loc, _ := time.LoadLocation("Local")
  3108. // var stime, etime int64
  3109. // if times == "" {
  3110. // stime, etime = GetNowTime()
  3111. // } else {
  3112. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3113. // stime = stmp.Unix()
  3114. // etime = stime + 86399
  3115. // }
  3116. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3117. // var flows []*models.DrugFlow
  3118. // for _, item := range advicelist {
  3119. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3120. // flows = append(flows, flow...)
  3121. // }
  3122. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3123. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3124. // var err []string
  3125. //
  3126. // for _, item := range flows {
  3127. // var res3 ResultSix
  3128. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3129. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3130. // if prescription.OrderStatus == 2 {
  3131. // //已经结算
  3132. // //判断是否已经销售
  3133. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3134. // //是否已经变更 1是 0否
  3135. // if item.IsChange == 0 { //没变更,进行变更操作
  3136. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3137. //
  3138. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3139. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3140. // var respJSON3 map[string]interface{}
  3141. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3142. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. // return
  3145. // }
  3146. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3147. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3148. // utils.ErrorLog("解析失败:%v", err)
  3149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3150. // return
  3151. // }
  3152. // if res3.Infcode == 0 {
  3153. // item.IsChange = 1
  3154. // item.BgBchno = bg_number
  3155. // service.SaveDF2(item)
  3156. // } else {
  3157. //
  3158. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3159. // }
  3160. // }
  3161. // } else { //没销售,
  3162. // var res FJ3507Result
  3163. // var res3507for10188 FJ3507ResultFor10188
  3164. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3165. //
  3166. // //进行商品销售接口
  3167. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3168. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3169. // var respJSON3 map[string]interface{}
  3170. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. // return
  3174. // }
  3175. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3176. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3177. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3178. // utils.ErrorLog("解析失败:%v", err)
  3179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3180. // return
  3181. // }
  3182. // //if res3507for10188.Infcode
  3183. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3184. // //res.Output = resSix10265.Output
  3185. // res.ErrMsg = res3507for10188.ErrMsg
  3186. // res.Cainfo = res3507for10188.Cainfo
  3187. // res.WarnMsg = res3507for10188.WarnMsg
  3188. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3189. // res.Infcode = infocode
  3190. // } else {
  3191. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3192. // utils.ErrorLog("解析失败:%v", err)
  3193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. // return
  3195. // }
  3196. //
  3197. // }
  3198. // if res.Infcode == 0 {
  3199. // item.IsSale = 1
  3200. // item.Bchno = number
  3201. // item.SaleDate = time.Now().Format("2006-01-02")
  3202. //
  3203. // err5 := service.SaveDF(item)
  3204. // if err5 == nil {
  3205. // if item.IsChange == 0 { //没变更,进行变更操作
  3206. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3207. //
  3208. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3209. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3210. //
  3211. // var respJSON3 map[string]interface{}
  3212. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3213. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3215. // return
  3216. // }
  3217. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3218. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3219. // utils.ErrorLog("解析失败:%v", err)
  3220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3221. // return
  3222. // }
  3223. // //if res3507for10188.Infcode
  3224. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3225. // //res.Output = resSix10265.Output
  3226. // res3.ErrMsg = res3507for10188.ErrMsg
  3227. // res3.Cainfo = res3507for10188.Cainfo
  3228. // res3.WarnMsg = res3507for10188.WarnMsg
  3229. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3230. // res3.Infcode = infocode
  3231. // } else {
  3232. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3233. // utils.ErrorLog("解析失败:%v", err)
  3234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3235. // return
  3236. // }
  3237. // }
  3238. // if res3.Infcode == 0 {
  3239. // item.IsChange = 1
  3240. // item.BgBchno = bg_number
  3241. // service.SaveDF2(item)
  3242. // } else {
  3243. //
  3244. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3245. // }
  3246. // }
  3247. // }
  3248. // } else {
  3249. //
  3250. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3251. // }
  3252. // }
  3253. //
  3254. // } else { //还没结,提示用户去结算,并药品追溯上传
  3255. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3256. // }
  3257. // }
  3258. // }
  3259. // if len(err) == 0 {
  3260. // c.ServeSuccessJSON(map[string]interface{}{
  3261. // "msg": "销售变更成功",
  3262. // })
  3263. // } else {
  3264. // c.ServeSuccessJSON(map[string]interface{}{
  3265. // "failed_code": -10,
  3266. // "msg": err,
  3267. // })
  3268. // }
  3269. //}
  3270. func (c *HisApiController) ChangeDrug() {
  3271. ids := c.GetString("ids")
  3272. id_arr := strings.Split(ids, ",")
  3273. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3274. admin_user_id, _ := c.GetInt64("admin_user_id")
  3275. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3277. var err []string
  3278. for _, item := range flows {
  3279. var res3 ResultSix
  3280. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3281. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3282. if prescription.OrderStatus == 2 {
  3283. //已经结算
  3284. //判断是否已经销售
  3285. if item.IsSale == 1 { //是否已经销售,1是 0否
  3286. //是否已经变更 1是 0否
  3287. if item.IsChange == 0 { //没变更,进行变更操作
  3288. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3289. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3290. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3291. var respJSON3 map[string]interface{}
  3292. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3295. return
  3296. }
  3297. userJSONBytes3, _ := json.Marshal(respJSON3)
  3298. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3299. utils.ErrorLog("解析失败:%v", err)
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3301. return
  3302. }
  3303. if res3.Infcode == 0 {
  3304. item.IsChange = 1
  3305. item.BgBchno = bg_number
  3306. service.SaveDF2(item)
  3307. } else {
  3308. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3309. }
  3310. }
  3311. } else { //没销售,
  3312. var res FJ3507Result
  3313. var res3507for10188 FJ3507ResultFor10188
  3314. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3315. //进行商品销售接口
  3316. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3317. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3318. var respJSON3 map[string]interface{}
  3319. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. return
  3323. }
  3324. userJSONBytes3, _ := json.Marshal(respJSON3)
  3325. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3326. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3327. utils.ErrorLog("解析失败:%v", err)
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3329. return
  3330. }
  3331. //if res3507for10188.Infcode
  3332. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3333. //res.Output = resSix10265.Output
  3334. res.ErrMsg = res3507for10188.ErrMsg
  3335. res.Cainfo = res3507for10188.Cainfo
  3336. res.WarnMsg = res3507for10188.WarnMsg
  3337. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3338. res.Infcode = infocode
  3339. } else {
  3340. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3341. utils.ErrorLog("解析失败:%v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. }
  3346. if res.Infcode == 0 {
  3347. item.IsSale = 1
  3348. item.Bchno = number
  3349. item.SaleDate = time.Now().Format("2006-01-02")
  3350. err5 := service.SaveDF(item)
  3351. if err5 == nil {
  3352. if item.IsChange == 0 { //没变更,进行变更操作
  3353. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3354. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3355. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3356. var respJSON3 map[string]interface{}
  3357. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3360. return
  3361. }
  3362. userJSONBytes3, _ := json.Marshal(respJSON3)
  3363. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3364. utils.ErrorLog("解析失败:%v", err)
  3365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3366. return
  3367. }
  3368. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3369. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3370. utils.ErrorLog("解析失败:%v", err)
  3371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3372. return
  3373. }
  3374. //if res3507for10188.Infcode
  3375. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3376. //res.Output = resSix10265.Output
  3377. res3.ErrMsg = res3507for10188.ErrMsg
  3378. res3.Cainfo = res3507for10188.Cainfo
  3379. res3.WarnMsg = res3507for10188.WarnMsg
  3380. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3381. res3.Infcode = infocode
  3382. } else {
  3383. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3384. utils.ErrorLog("解析失败:%v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. }
  3389. if res3.Infcode == 0 {
  3390. item.IsChange = 1
  3391. item.BgBchno = bg_number
  3392. service.SaveDF2(item)
  3393. } else {
  3394. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3395. }
  3396. }
  3397. }
  3398. } else {
  3399. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3400. }
  3401. }
  3402. } else { //还没结算
  3403. var res3507for10188 FJ3507ResultFor10188
  3404. if item.IsChange == 0 { //没变更,进行变更操作
  3405. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3406. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3407. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3408. var respJSON3 map[string]interface{}
  3409. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. userJSONBytes3, _ := json.Marshal(respJSON3)
  3415. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3416. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3417. utils.ErrorLog("解析失败:%v", err)
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. return
  3420. }
  3421. //if res3507for10188.Infcode
  3422. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3423. //res.Output = resSix10265.Output
  3424. res3.ErrMsg = res3507for10188.ErrMsg
  3425. res3.Cainfo = res3507for10188.Cainfo
  3426. res3.WarnMsg = res3507for10188.WarnMsg
  3427. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3428. res3.Infcode = infocode
  3429. } else {
  3430. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3431. utils.ErrorLog("解析失败:%v", err)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. }
  3436. if res3.Infcode == 0 {
  3437. item.IsChange = 1
  3438. item.BgBchno = bg_number
  3439. service.SaveDF2(item)
  3440. } else {
  3441. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3442. }
  3443. }
  3444. }
  3445. } else if item.ConsumableType == 7 {
  3446. var res3507for10188 FJ3507ResultFor10188
  3447. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3448. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3449. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3450. //判断是否已经销售
  3451. if item.IsSale == 2 { //是否已经销售,1是 0否
  3452. //是否已经变更 1是 0否
  3453. if item.IsChange == 0 { //没变更,进行变更操作
  3454. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3455. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3456. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3457. var respJSON3 map[string]interface{}
  3458. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. userJSONBytes3, _ := json.Marshal(respJSON3)
  3464. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3465. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3466. utils.ErrorLog("解析失败:%v", err)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. //if res3507for10188.Infcode
  3471. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3472. //res.Output = resSix10265.Output
  3473. res3.ErrMsg = res3507for10188.ErrMsg
  3474. res3.Cainfo = res3507for10188.Cainfo
  3475. res3.WarnMsg = res3507for10188.WarnMsg
  3476. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3477. res3.Infcode = infocode
  3478. } else {
  3479. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3480. utils.ErrorLog("解析失败:%v", err)
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. return
  3483. }
  3484. }
  3485. if res3.Infcode == 0 {
  3486. item.IsChange = 1
  3487. item.BgBchno = bg_number
  3488. service.SaveDF2(item)
  3489. } else {
  3490. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3491. }
  3492. }
  3493. } else { //没销售,
  3494. //进行商品销售退货接口
  3495. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3496. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3497. saveLog(result111, result222, "3506", "销售退货")
  3498. var res7 FJ3507Result
  3499. //进行商品销售接口
  3500. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3501. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3502. var respJSON3 map[string]interface{}
  3503. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3506. return
  3507. }
  3508. userJSONBytes3, _ := json.Marshal(respJSON3)
  3509. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3510. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3511. utils.ErrorLog("解析失败:%v", err)
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3513. return
  3514. }
  3515. //if res3507for10188.Infcode
  3516. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3517. //res.Output = resSix10265.Output
  3518. res7.ErrMsg = res3507for10188.ErrMsg
  3519. res7.Cainfo = res3507for10188.Cainfo
  3520. res7.WarnMsg = res3507for10188.WarnMsg
  3521. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3522. res7.Infcode = infocode
  3523. } else {
  3524. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3525. utils.ErrorLog("解析失败:%v", err)
  3526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3527. return
  3528. }
  3529. }
  3530. if res7.Infcode == 0 {
  3531. item.IsSale = 2
  3532. item.SaleDate = item.SaleDate
  3533. item.Bchno = number
  3534. service.SaveDF(item)
  3535. if item.IsChange == 0 { //没变更,进行变更操作
  3536. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3537. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3538. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3539. var respJSON3 map[string]interface{}
  3540. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3543. return
  3544. }
  3545. userJSONBytes3, _ := json.Marshal(respJSON3)
  3546. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3547. // utils.ErrorLog("解析失败:%v", err)
  3548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3549. // return
  3550. //}
  3551. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3552. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3553. utils.ErrorLog("解析失败:%v", err)
  3554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3555. return
  3556. }
  3557. //if res3507for10188.Infcode
  3558. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3559. //res.Output = resSix10265.Output
  3560. res3.ErrMsg = res3507for10188.ErrMsg
  3561. res3.Cainfo = res3507for10188.Cainfo
  3562. res3.WarnMsg = res3507for10188.WarnMsg
  3563. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3564. res3.Infcode = infocode
  3565. } else {
  3566. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3567. utils.ErrorLog("解析失败:%v", err)
  3568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3569. return
  3570. }
  3571. }
  3572. if res3.Infcode == 0 {
  3573. item.IsChange = 1
  3574. item.BgBchno = bg_number
  3575. service.SaveDF2(item)
  3576. } else {
  3577. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3578. }
  3579. }
  3580. } else {
  3581. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3582. }
  3583. }
  3584. } else { //还没结算
  3585. if item.IsChange == 0 { //没变更,进行变更操作
  3586. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3587. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3588. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3589. var respJSON3 map[string]interface{}
  3590. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3593. return
  3594. }
  3595. userJSONBytes3, _ := json.Marshal(respJSON3)
  3596. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3597. // utils.ErrorLog("解析失败:%v", err)
  3598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3599. // return
  3600. //}
  3601. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3602. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3603. utils.ErrorLog("解析失败:%v", err)
  3604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3605. return
  3606. }
  3607. //if res3507for10188.Infcode
  3608. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3609. //res.Output = resSix10265.Output
  3610. res3.ErrMsg = res3507for10188.ErrMsg
  3611. res3.Cainfo = res3507for10188.Cainfo
  3612. res3.WarnMsg = res3507for10188.WarnMsg
  3613. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3614. res3.Infcode = infocode
  3615. } else {
  3616. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3617. utils.ErrorLog("解析失败:%v", err)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. }
  3622. if res3.Infcode == 0 {
  3623. item.IsChange = 1
  3624. item.BgBchno = bg_number
  3625. service.SaveDF2(item)
  3626. } else {
  3627. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3628. }
  3629. }
  3630. }
  3631. }
  3632. }
  3633. if len(err) == 0 {
  3634. c.ServeSuccessJSON(map[string]interface{}{
  3635. "msg": "销售变更成功",
  3636. })
  3637. } else {
  3638. c.ServeSuccessJSON(map[string]interface{}{
  3639. "failed_code": -10,
  3640. "msg": err,
  3641. })
  3642. }
  3643. }
  3644. func (c *HisApiController) ChangeDrugtwo() {
  3645. //ids := c.GetString("ids")
  3646. //id_arr := strings.Split(ids, ",")
  3647. flows, _ := service.GetNewDrugFlowInfothree123()
  3648. admin_user_id, _ := c.GetInt64("admin_user_id")
  3649. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3651. var err []string
  3652. for _, item := range flows {
  3653. var res3 ResultSix
  3654. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3655. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3656. if prescription.OrderStatus == 2 {
  3657. //已经结算
  3658. //判断是否已经销售
  3659. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3660. // //是否已经变更 1是 0否
  3661. // if item.IsChange == 0 { //没变更,进行变更操作
  3662. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3663. //
  3664. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3665. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3666. // var respJSON3 map[string]interface{}
  3667. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3668. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3670. // return
  3671. // }
  3672. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3673. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3674. // utils.ErrorLog("解析失败:%v", err)
  3675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. // return
  3677. // }
  3678. // if res3.Infcode == 0 {
  3679. // item.IsChange = 1
  3680. // item.BgBchno = bg_number
  3681. // service.SaveDF2(item)
  3682. // } else {
  3683. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3684. // }
  3685. // }
  3686. //}
  3687. //else
  3688. { //没销售,
  3689. var res FJ3507Result
  3690. var res3507for10188 FJ3507ResultFor10188
  3691. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3692. //进行商品销售接口
  3693. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3694. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3695. var respJSON3 map[string]interface{}
  3696. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3699. return
  3700. }
  3701. userJSONBytes3, _ := json.Marshal(respJSON3)
  3702. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3703. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3704. utils.ErrorLog("解析失败:%v", err)
  3705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3706. return
  3707. }
  3708. //if res3507for10188.Infcode
  3709. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3710. //res.Output = resSix10265.Output
  3711. res.ErrMsg = res3507for10188.ErrMsg
  3712. res.Cainfo = res3507for10188.Cainfo
  3713. res.WarnMsg = res3507for10188.WarnMsg
  3714. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3715. res.Infcode = infocode
  3716. } else {
  3717. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3718. utils.ErrorLog("解析失败:%v", err)
  3719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3720. return
  3721. }
  3722. }
  3723. if res.Infcode == 0 {
  3724. item.IsSale = 1
  3725. item.Bchno = number
  3726. item.SaleDate = time.Now().Format("2006-01-02")
  3727. service.SaveDF(item)
  3728. //if err5 == nil {
  3729. // if item.IsChange == 0 { //没变更,进行变更操作
  3730. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3731. //
  3732. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3733. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3734. //
  3735. // var respJSON3 map[string]interface{}
  3736. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3737. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. // return
  3740. // }
  3741. //
  3742. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3743. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3744. // utils.ErrorLog("解析失败:%v", err)
  3745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. // return
  3747. // }
  3748. // //if res3507for10188.Infcode
  3749. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3750. // //res.Output = resSix10265.Output
  3751. // res3.ErrMsg = res3507for10188.ErrMsg
  3752. // res3.Cainfo = res3507for10188.Cainfo
  3753. // res3.WarnMsg = res3507for10188.WarnMsg
  3754. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3755. // res3.Infcode = infocode
  3756. // } else {
  3757. //
  3758. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3759. // utils.ErrorLog("解析失败:%v", err)
  3760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. // return
  3762. // }
  3763. //
  3764. // }
  3765. //
  3766. // if res3.Infcode == 0 {
  3767. // item.IsChange = 1
  3768. // item.BgBchno = bg_number
  3769. // service.SaveDF2(item)
  3770. // } else {
  3771. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3772. // }
  3773. // }
  3774. //}
  3775. } else {
  3776. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3777. }
  3778. }
  3779. } else { //还没结算
  3780. var res3507for10188 FJ3507ResultFor10188
  3781. if item.IsChange == 0 { //没变更,进行变更操作
  3782. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3783. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3784. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3785. var respJSON3 map[string]interface{}
  3786. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. userJSONBytes3, _ := json.Marshal(respJSON3)
  3792. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3793. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3794. utils.ErrorLog("解析失败:%v", err)
  3795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. return
  3797. }
  3798. //if res3507for10188.Infcode
  3799. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3800. //res.Output = resSix10265.Output
  3801. res3.ErrMsg = res3507for10188.ErrMsg
  3802. res3.Cainfo = res3507for10188.Cainfo
  3803. res3.WarnMsg = res3507for10188.WarnMsg
  3804. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3805. res3.Infcode = infocode
  3806. } else {
  3807. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3808. utils.ErrorLog("解析失败:%v", err)
  3809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3810. return
  3811. }
  3812. }
  3813. if res3.Infcode == 0 {
  3814. item.IsChange = 1
  3815. item.BgBchno = bg_number
  3816. service.SaveDF2(item)
  3817. } else {
  3818. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3819. }
  3820. }
  3821. }
  3822. }
  3823. //if item.ConsumableType == 7 {
  3824. // var res3507for10188 FJ3507ResultFor10188
  3825. //
  3826. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3827. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3828. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3829. // //判断是否已经销售
  3830. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3831. // //是否已经变更 1是 0否
  3832. // if item.IsChange == 0 { //没变更,进行变更操作
  3833. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3834. //
  3835. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3836. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3837. //
  3838. // var respJSON3 map[string]interface{}
  3839. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3840. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3842. // return
  3843. // }
  3844. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3845. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3846. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3847. // utils.ErrorLog("解析失败:%v", err)
  3848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3849. // return
  3850. // }
  3851. // //if res3507for10188.Infcode
  3852. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3853. // //res.Output = resSix10265.Output
  3854. // res3.ErrMsg = res3507for10188.ErrMsg
  3855. // res3.Cainfo = res3507for10188.Cainfo
  3856. // res3.WarnMsg = res3507for10188.WarnMsg
  3857. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3858. // res3.Infcode = infocode
  3859. // } else {
  3860. //
  3861. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3862. // utils.ErrorLog("解析失败:%v", err)
  3863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. // return
  3865. // }
  3866. //
  3867. // }
  3868. // if res3.Infcode == 0 {
  3869. // item.IsChange = 1
  3870. // item.BgBchno = bg_number
  3871. // service.SaveDF2(item)
  3872. // } else {
  3873. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3874. // }
  3875. // }
  3876. // } else { //没销售,
  3877. // //进行商品销售退货接口
  3878. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3879. //
  3880. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3881. // saveLog(result111, result222, "3506", "销售退货")
  3882. // var res7 FJ3507Result
  3883. //
  3884. // //进行商品销售接口
  3885. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3886. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3887. // var respJSON3 map[string]interface{}
  3888. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3889. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3891. // return
  3892. // }
  3893. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3894. //
  3895. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3896. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3897. // utils.ErrorLog("解析失败:%v", err)
  3898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3899. // return
  3900. // }
  3901. // //if res3507for10188.Infcode
  3902. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3903. // //res.Output = resSix10265.Output
  3904. // res7.ErrMsg = res3507for10188.ErrMsg
  3905. // res7.Cainfo = res3507for10188.Cainfo
  3906. // res7.WarnMsg = res3507for10188.WarnMsg
  3907. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3908. // res7.Infcode = infocode
  3909. // } else {
  3910. //
  3911. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3912. // utils.ErrorLog("解析失败:%v", err)
  3913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3914. // return
  3915. // }
  3916. //
  3917. // }
  3918. // if res7.Infcode == 0 {
  3919. // item.IsSale = 2
  3920. // item.SaleDate = item.SaleDate
  3921. // item.Bchno = number
  3922. // service.SaveDF(item)
  3923. // if item.IsChange == 0 { //没变更,进行变更操作
  3924. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3925. //
  3926. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3927. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3928. //
  3929. // var respJSON3 map[string]interface{}
  3930. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3931. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. // return
  3934. // }
  3935. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3936. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3937. // // utils.ErrorLog("解析失败:%v", err)
  3938. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. // // return
  3940. // //}
  3941. //
  3942. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3943. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3944. // utils.ErrorLog("解析失败:%v", err)
  3945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. // return
  3947. // }
  3948. // //if res3507for10188.Infcode
  3949. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3950. // //res.Output = resSix10265.Output
  3951. // res3.ErrMsg = res3507for10188.ErrMsg
  3952. // res3.Cainfo = res3507for10188.Cainfo
  3953. // res3.WarnMsg = res3507for10188.WarnMsg
  3954. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3955. // res3.Infcode = infocode
  3956. // } else {
  3957. //
  3958. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3959. // utils.ErrorLog("解析失败:%v", err)
  3960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3961. // return
  3962. // }
  3963. //
  3964. // }
  3965. // if res3.Infcode == 0 {
  3966. // item.IsChange = 1
  3967. // item.BgBchno = bg_number
  3968. // service.SaveDF2(item)
  3969. // } else {
  3970. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3971. // }
  3972. // }
  3973. // } else {
  3974. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3975. // }
  3976. // }
  3977. // } else { //还没结算
  3978. // if item.IsChange == 0 { //没变更,进行变更操作
  3979. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3980. //
  3981. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3982. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3983. //
  3984. // var respJSON3 map[string]interface{}
  3985. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3986. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3987. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. // return
  3989. // }
  3990. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3991. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3992. // // utils.ErrorLog("解析失败:%v", err)
  3993. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. // // return
  3995. // //}
  3996. //
  3997. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3998. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3999. // utils.ErrorLog("解析失败:%v", err)
  4000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4001. // return
  4002. // }
  4003. // //if res3507for10188.Infcode
  4004. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4005. // //res.Output = resSix10265.Output
  4006. // res3.ErrMsg = res3507for10188.ErrMsg
  4007. // res3.Cainfo = res3507for10188.Cainfo
  4008. // res3.WarnMsg = res3507for10188.WarnMsg
  4009. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4010. // res3.Infcode = infocode
  4011. // } else {
  4012. //
  4013. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4014. // utils.ErrorLog("解析失败:%v", err)
  4015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4016. // return
  4017. // }
  4018. //
  4019. // }
  4020. // if res3.Infcode == 0 {
  4021. // item.IsChange = 1
  4022. // item.BgBchno = bg_number
  4023. // service.SaveDF2(item)
  4024. // } else {
  4025. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4026. // }
  4027. // }
  4028. // }
  4029. //}
  4030. }
  4031. if len(err) == 0 {
  4032. c.ServeSuccessJSON(map[string]interface{}{
  4033. "msg": "销售变更成功",
  4034. })
  4035. } else {
  4036. c.ServeSuccessJSON(map[string]interface{}{
  4037. "failed_code": -10,
  4038. "msg": err,
  4039. })
  4040. }
  4041. }
  4042. func (c *HisApiController) ChangeDrugthree() {
  4043. //ids := c.GetString("ids")
  4044. //id_arr := strings.Split(ids, ",")
  4045. flows, _ := service.GetNewDrugFlowInfothree()
  4046. admin_user_id, _ := c.GetInt64("admin_user_id")
  4047. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4048. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4049. var err []string
  4050. for _, item := range flows {
  4051. var res3 ResultSix
  4052. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4053. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4054. if prescription.OrderStatus == 2 {
  4055. //已经结算
  4056. //判断是否已经销售
  4057. if item.IsSale == 1 { //是否已经销售,1是 0否
  4058. //是否已经变更 1是 0否
  4059. if item.IsChange == 0 { //没变更,进行变更操作
  4060. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4061. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4062. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4063. var respJSON3 map[string]interface{}
  4064. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. return
  4068. }
  4069. userJSONBytes3, _ := json.Marshal(respJSON3)
  4070. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4071. utils.ErrorLog("解析失败:%v", err)
  4072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4073. return
  4074. }
  4075. if res3.Infcode == 0 {
  4076. item.IsChange = 1
  4077. item.BgBchno = bg_number
  4078. service.SaveDF2(item)
  4079. } else {
  4080. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4081. }
  4082. }
  4083. } else { //没销售,
  4084. var res FJ3507Result
  4085. var res3507for10188 FJ3507ResultFor10188
  4086. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4087. //进行商品销售接口
  4088. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4089. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4090. var respJSON3 map[string]interface{}
  4091. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4094. return
  4095. }
  4096. userJSONBytes3, _ := json.Marshal(respJSON3)
  4097. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4098. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4099. utils.ErrorLog("解析失败:%v", err)
  4100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4101. return
  4102. }
  4103. //if res3507for10188.Infcode
  4104. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4105. //res.Output = resSix10265.Output
  4106. res.ErrMsg = res3507for10188.ErrMsg
  4107. res.Cainfo = res3507for10188.Cainfo
  4108. res.WarnMsg = res3507for10188.WarnMsg
  4109. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4110. res.Infcode = infocode
  4111. } else {
  4112. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4113. utils.ErrorLog("解析失败:%v", err)
  4114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4115. return
  4116. }
  4117. }
  4118. if res.Infcode == 0 {
  4119. item.IsSale = 1
  4120. item.Bchno = number
  4121. item.SaleDate = time.Now().Format("2006-01-02")
  4122. err5 := service.SaveDF(item)
  4123. if err5 == nil {
  4124. if item.IsChange == 0 { //没变更,进行变更操作
  4125. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4126. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4127. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4128. var respJSON3 map[string]interface{}
  4129. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4132. return
  4133. }
  4134. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4135. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4136. utils.ErrorLog("解析失败:%v", err)
  4137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4138. return
  4139. }
  4140. //if res3507for10188.Infcode
  4141. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4142. //res.Output = resSix10265.Output
  4143. res3.ErrMsg = res3507for10188.ErrMsg
  4144. res3.Cainfo = res3507for10188.Cainfo
  4145. res3.WarnMsg = res3507for10188.WarnMsg
  4146. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4147. res3.Infcode = infocode
  4148. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4149. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4150. utils.ErrorLog("解析失败:%v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. //if res3507for10188.Infcode
  4155. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4156. //res.Output = resSix10265.Output
  4157. res3.ErrMsg = res3507for10188.ErrMsg
  4158. res3.Cainfo = res3507for10188.Cainfo
  4159. res3.WarnMsg = res3507for10188.WarnMsg
  4160. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4161. res3.Infcode = infocode
  4162. } else {
  4163. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4164. utils.ErrorLog("解析失败:%v", err)
  4165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4166. return
  4167. }
  4168. }
  4169. if res3.Infcode == 0 {
  4170. item.IsChange = 1
  4171. item.BgBchno = bg_number
  4172. service.SaveDF2(item)
  4173. } else {
  4174. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4175. }
  4176. }
  4177. }
  4178. } else {
  4179. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4180. }
  4181. }
  4182. } else { //还没结算
  4183. var res3507for10188 FJ3507ResultFor10188
  4184. if item.IsChange == 0 { //没变更,进行变更操作
  4185. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4186. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4187. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4188. var respJSON3 map[string]interface{}
  4189. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4192. return
  4193. }
  4194. userJSONBytes3, _ := json.Marshal(respJSON3)
  4195. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4196. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4197. utils.ErrorLog("解析失败:%v", err)
  4198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4199. return
  4200. }
  4201. //if res3507for10188.Infcode
  4202. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4203. //res.Output = resSix10265.Output
  4204. res3.ErrMsg = res3507for10188.ErrMsg
  4205. res3.Cainfo = res3507for10188.Cainfo
  4206. res3.WarnMsg = res3507for10188.WarnMsg
  4207. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4208. res3.Infcode = infocode
  4209. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4210. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4211. utils.ErrorLog("解析失败:%v", err)
  4212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4213. return
  4214. }
  4215. //if res3507for10188.Infcode
  4216. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4217. //res.Output = resSix10265.Output
  4218. res3.ErrMsg = res3507for10188.ErrMsg
  4219. res3.Cainfo = res3507for10188.Cainfo
  4220. res3.WarnMsg = res3507for10188.WarnMsg
  4221. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4222. res3.Infcode = infocode
  4223. } else {
  4224. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4225. utils.ErrorLog("解析失败:%v", err)
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. return
  4228. }
  4229. }
  4230. if res3.Infcode == 0 {
  4231. item.IsChange = 1
  4232. item.BgBchno = bg_number
  4233. service.SaveDF2(item)
  4234. } else {
  4235. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4236. }
  4237. }
  4238. }
  4239. } else if item.ConsumableType == 7 {
  4240. var res3507for10188 FJ3507ResultFor10188
  4241. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4242. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4243. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4244. //判断是否已经销售
  4245. if item.IsSale == 2 { //是否已经销售,1是 0否
  4246. //是否已经变更 1是 0否
  4247. if item.IsChange == 0 { //没变更,进行变更操作
  4248. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4249. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4250. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4251. var respJSON3 map[string]interface{}
  4252. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4255. return
  4256. }
  4257. userJSONBytes3, _ := json.Marshal(respJSON3)
  4258. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4259. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4260. utils.ErrorLog("解析失败:%v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. //if res3507for10188.Infcode
  4265. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4266. //res.Output = resSix10265.Output
  4267. res3.ErrMsg = res3507for10188.ErrMsg
  4268. res3.Cainfo = res3507for10188.Cainfo
  4269. res3.WarnMsg = res3507for10188.WarnMsg
  4270. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4271. res3.Infcode = infocode
  4272. } else {
  4273. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4274. utils.ErrorLog("解析失败:%v", err)
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. return
  4277. }
  4278. }
  4279. if res3.Infcode == 0 {
  4280. item.IsChange = 1
  4281. item.BgBchno = bg_number
  4282. service.SaveDF2(item)
  4283. } else {
  4284. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4285. }
  4286. }
  4287. } else { //没销售,
  4288. //进行商品销售退货接口
  4289. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4290. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4291. saveLog(result111, result222, "3506", "销售退货")
  4292. var res7 FJ3507Result
  4293. //进行商品销售接口
  4294. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4295. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4296. var respJSON3 map[string]interface{}
  4297. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4300. return
  4301. }
  4302. userJSONBytes3, _ := json.Marshal(respJSON3)
  4303. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4304. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4305. utils.ErrorLog("解析失败:%v", err)
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4307. return
  4308. }
  4309. //if res3507for10188.Infcode
  4310. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4311. //res.Output = resSix10265.Output
  4312. res7.ErrMsg = res3507for10188.ErrMsg
  4313. res7.Cainfo = res3507for10188.Cainfo
  4314. res7.WarnMsg = res3507for10188.WarnMsg
  4315. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4316. res7.Infcode = infocode
  4317. } else {
  4318. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4319. utils.ErrorLog("解析失败:%v", err)
  4320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4321. return
  4322. }
  4323. }
  4324. if res7.Infcode == 0 {
  4325. item.IsSale = 2
  4326. item.SaleDate = item.SaleDate
  4327. item.Bchno = number
  4328. service.SaveDF(item)
  4329. if item.IsChange == 0 { //没变更,进行变更操作
  4330. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4331. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4332. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4333. var respJSON3 map[string]interface{}
  4334. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4337. return
  4338. }
  4339. userJSONBytes3, _ := json.Marshal(respJSON3)
  4340. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4341. // utils.ErrorLog("解析失败:%v", err)
  4342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. // return
  4344. //}
  4345. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4346. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4347. utils.ErrorLog("解析失败:%v", err)
  4348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. return
  4350. }
  4351. //if res3507for10188.Infcode
  4352. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4353. //res.Output = resSix10265.Output
  4354. res3.ErrMsg = res3507for10188.ErrMsg
  4355. res3.Cainfo = res3507for10188.Cainfo
  4356. res3.WarnMsg = res3507for10188.WarnMsg
  4357. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4358. res3.Infcode = infocode
  4359. } else {
  4360. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4361. utils.ErrorLog("解析失败:%v", err)
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. return
  4364. }
  4365. }
  4366. if res3.Infcode == 0 {
  4367. item.IsChange = 1
  4368. item.BgBchno = bg_number
  4369. service.SaveDF2(item)
  4370. } else {
  4371. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4372. }
  4373. }
  4374. } else {
  4375. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4376. }
  4377. }
  4378. } else { //还没结算
  4379. if item.IsChange == 0 { //没变更,进行变更操作
  4380. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4381. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4382. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4383. var respJSON3 map[string]interface{}
  4384. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4387. return
  4388. }
  4389. userJSONBytes3, _ := json.Marshal(respJSON3)
  4390. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4391. // utils.ErrorLog("解析失败:%v", err)
  4392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. // return
  4394. //}
  4395. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4396. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4397. utils.ErrorLog("解析失败:%v", err)
  4398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. return
  4400. }
  4401. //if res3507for10188.Infcode
  4402. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4403. //res.Output = resSix10265.Output
  4404. res3.ErrMsg = res3507for10188.ErrMsg
  4405. res3.Cainfo = res3507for10188.Cainfo
  4406. res3.WarnMsg = res3507for10188.WarnMsg
  4407. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4408. res3.Infcode = infocode
  4409. } else {
  4410. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4411. utils.ErrorLog("解析失败:%v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. }
  4416. if res3.Infcode == 0 {
  4417. item.IsChange = 1
  4418. item.BgBchno = bg_number
  4419. service.SaveDF2(item)
  4420. } else {
  4421. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4422. }
  4423. }
  4424. }
  4425. }
  4426. }
  4427. if len(err) == 0 {
  4428. c.ServeSuccessJSON(map[string]interface{}{
  4429. "msg": "销售变更成功",
  4430. })
  4431. } else {
  4432. c.ServeSuccessJSON(map[string]interface{}{
  4433. "failed_code": -10,
  4434. "msg": err,
  4435. })
  4436. }
  4437. }
  4438. func (c *HisApiController) ChangeDrugTen() {
  4439. start_time_str := c.GetString("start_time")
  4440. end_time_str := c.GetString("end_time")
  4441. //ids := c.GetString("ids")
  4442. //id_arr := strings.Split(ids, ",")
  4443. timeLayout := "2006-01-02"
  4444. loc, _ := time.LoadLocation("Local")
  4445. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4446. recordStartTime := theStartTime.Unix()
  4447. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4448. recordEndTime := theEndTime.Unix()
  4449. //timestamp := int64(1729612800)
  4450. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4451. admin_user_id, _ := c.GetInt64("admin_user_id")
  4452. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4454. var err []string
  4455. for _, item := range flows {
  4456. var res3 ResultSix
  4457. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4458. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4459. continue
  4460. }
  4461. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4462. continue
  4463. }
  4464. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4465. if prescription.OrderStatus == 2 {
  4466. //已经结算
  4467. //判断 是否已经销售
  4468. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4469. ////是否已经变更 1是 0否
  4470. //if item.IsChange == 0 { //没变更,进行变更操作
  4471. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4472. //
  4473. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4474. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4475. // var respJSON3 map[string]interface{}
  4476. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4477. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4479. // return
  4480. // }
  4481. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4482. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4483. // utils.ErrorLog("解析失败:%v", err)
  4484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4485. // return
  4486. // }
  4487. // if res3.Infcode == 0 {
  4488. // item.IsChange = 1
  4489. // item.BgBchno = bg_number
  4490. // service.SaveDF2(item)
  4491. // } else {
  4492. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4493. // }
  4494. //}
  4495. //} else
  4496. if item.IsSale == 0 { //没销售,
  4497. var res FJ3507Result
  4498. var res3507for10188 FJ3507ResultFor10188
  4499. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4500. //进行商品销售接口
  4501. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4502. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4503. var respJSON3 map[string]interface{}
  4504. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4507. return
  4508. }
  4509. userJSONBytes3, _ := json.Marshal(respJSON3)
  4510. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. //if res3507for10188.Infcode
  4517. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4518. //res.Output = resSix10265.Output
  4519. res.ErrMsg = res3507for10188.ErrMsg
  4520. res.Cainfo = res3507for10188.Cainfo
  4521. res.WarnMsg = res3507for10188.WarnMsg
  4522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4523. res.Infcode = infocode
  4524. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4525. } else {
  4526. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4527. utils.ErrorLog("解析失败:%v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. }
  4532. if res.Infcode == 0 {
  4533. item.IsSale = 1
  4534. item.Bchno = number
  4535. item.SaleDate = time.Now().Format("2006-01-02")
  4536. err5 := service.SaveDF(item)
  4537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4538. //if err5 == nil {
  4539. //
  4540. // if item.IsChange == 1 { //没变更,进行变更操作
  4541. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4542. //
  4543. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4544. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4545. //
  4546. // var respJSON3 map[string]interface{}
  4547. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4548. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. // return
  4551. // }
  4552. //
  4553. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4554. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4555. // utils.ErrorLog("解析失败:%v", err)
  4556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. // return
  4558. // }
  4559. // //if res3507for10188.Infcode
  4560. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4561. // //res.Output = resSix10265.Output
  4562. // res3.ErrMsg = res3507for10188.ErrMsg
  4563. // res3.Cainfo = res3507for10188.Cainfo
  4564. // res3.WarnMsg = res3507for10188.WarnMsg
  4565. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4566. // res3.Infcode = infocode
  4567. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4568. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4569. // utils.ErrorLog("解析失败:%v", err)
  4570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. // return
  4572. // }
  4573. // //if res3507for10188.Infcode
  4574. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4575. // //res.Output = resSix10265.Output
  4576. // res3.ErrMsg = res3507for10188.ErrMsg
  4577. // res3.Cainfo = res3507for10188.Cainfo
  4578. // res3.WarnMsg = res3507for10188.WarnMsg
  4579. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4580. // res3.Infcode = infocode
  4581. //
  4582. // } else {
  4583. //
  4584. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4585. // utils.ErrorLog("解析失败:%v", err)
  4586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. // return
  4588. // }
  4589. //
  4590. // }
  4591. //
  4592. // if res3.Infcode == 0 {
  4593. // item.IsChange = 1
  4594. // item.BgBchno = bg_number
  4595. // service.SaveDF2(item)
  4596. // return
  4597. // } else {
  4598. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4599. // }
  4600. // }
  4601. //}
  4602. } else {
  4603. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4604. }
  4605. }
  4606. }
  4607. } else if item.ConsumableType == 7 {
  4608. var res3507for10188 FJ3507ResultFor10188
  4609. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4610. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4611. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4612. //判断是否已经销售
  4613. if item.IsSale == 2 { //是否已经销售,1是 0否
  4614. //是否已经变更 1是 0否
  4615. if item.IsChange == 0 { //没变更,进行变更操作
  4616. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4617. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4618. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4619. var respJSON3 map[string]interface{}
  4620. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4623. return
  4624. }
  4625. userJSONBytes3, _ := json.Marshal(respJSON3)
  4626. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4627. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4628. utils.ErrorLog("解析失败:%v", err)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. //if res3507for10188.Infcode
  4633. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4634. //res.Output = resSix10265.Output
  4635. res3.ErrMsg = res3507for10188.ErrMsg
  4636. res3.Cainfo = res3507for10188.Cainfo
  4637. res3.WarnMsg = res3507for10188.WarnMsg
  4638. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4639. res3.Infcode = infocode
  4640. } else {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. }
  4647. if res3.Infcode == 0 {
  4648. item.IsChange = 1
  4649. item.BgBchno = bg_number
  4650. service.SaveDF2(item)
  4651. } else {
  4652. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4653. }
  4654. }
  4655. } else { //没销售,
  4656. //进行商品销售退货接口
  4657. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4658. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4659. saveLog(result111, result222, "3506", "销售退货")
  4660. var res7 FJ3507Result
  4661. //进行商品销售接口
  4662. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4663. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4664. var respJSON3 map[string]interface{}
  4665. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4668. return
  4669. }
  4670. userJSONBytes3, _ := json.Marshal(respJSON3)
  4671. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4672. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4673. utils.ErrorLog("解析失败:%v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. //if res3507for10188.Infcode
  4678. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4679. //res.Output = resSix10265.Output
  4680. res7.ErrMsg = res3507for10188.ErrMsg
  4681. res7.Cainfo = res3507for10188.Cainfo
  4682. res7.WarnMsg = res3507for10188.WarnMsg
  4683. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4684. res7.Infcode = infocode
  4685. } else {
  4686. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4687. utils.ErrorLog("解析失败:%v", err)
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4689. return
  4690. }
  4691. }
  4692. if res7.Infcode == 0 {
  4693. item.IsSale = 2
  4694. item.SaleDate = item.SaleDate
  4695. item.Bchno = number
  4696. service.SaveDF(item)
  4697. if item.IsChange == 0 { //没变更,进行变更操作
  4698. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4699. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4700. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4701. var respJSON3 map[string]interface{}
  4702. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. userJSONBytes3, _ := json.Marshal(respJSON3)
  4708. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4709. // utils.ErrorLog("解析失败:%v", err)
  4710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4711. // return
  4712. //}
  4713. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4714. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4715. utils.ErrorLog("解析失败:%v", err)
  4716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4717. return
  4718. }
  4719. //if res3507for10188.Infcode
  4720. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4721. //res.Output = resSix10265.Output
  4722. res3.ErrMsg = res3507for10188.ErrMsg
  4723. res3.Cainfo = res3507for10188.Cainfo
  4724. res3.WarnMsg = res3507for10188.WarnMsg
  4725. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4726. res3.Infcode = infocode
  4727. } else {
  4728. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4729. utils.ErrorLog("解析失败:%v", err)
  4730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. }
  4734. if res3.Infcode == 0 {
  4735. item.IsChange = 1
  4736. item.BgBchno = bg_number
  4737. service.SaveDF2(item)
  4738. } else {
  4739. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4740. }
  4741. }
  4742. } else {
  4743. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4744. }
  4745. }
  4746. } else { //还没结算
  4747. if item.IsChange == 0 { //没变更,进行变更操作
  4748. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4749. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4750. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4751. var respJSON3 map[string]interface{}
  4752. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. userJSONBytes3, _ := json.Marshal(respJSON3)
  4758. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4759. // utils.ErrorLog("解析失败:%v", err)
  4760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. // return
  4762. //}
  4763. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4764. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. return
  4768. }
  4769. //if res3507for10188.Infcode
  4770. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4771. //res.Output = resSix10265.Output
  4772. res3.ErrMsg = res3507for10188.ErrMsg
  4773. res3.Cainfo = res3507for10188.Cainfo
  4774. res3.WarnMsg = res3507for10188.WarnMsg
  4775. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4776. res3.Infcode = infocode
  4777. } else {
  4778. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4779. utils.ErrorLog("解析失败:%v", err)
  4780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4781. return
  4782. }
  4783. }
  4784. if res3.Infcode == 0 {
  4785. item.IsChange = 1
  4786. item.BgBchno = bg_number
  4787. service.SaveDF2(item)
  4788. } else {
  4789. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4790. }
  4791. }
  4792. }
  4793. }
  4794. }
  4795. if len(err) == 0 {
  4796. c.ServeSuccessJSON(map[string]interface{}{
  4797. "msg": "销售变更成功",
  4798. })
  4799. } else {
  4800. c.ServeSuccessJSON(map[string]interface{}{
  4801. "failed_code": -10,
  4802. "msg": err,
  4803. })
  4804. }
  4805. }
  4806. func ChangeDrugTenone() {
  4807. //ids := c.GetString("ids")
  4808. //id_arr := strings.Split(ids, ",")
  4809. now := time.Now()
  4810. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4811. //timestamp := int64(1729612800)
  4812. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4813. admin_user_id := int64(2463)
  4814. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4815. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4816. var err []string
  4817. for _, item := range flows {
  4818. var res3 ResultSix
  4819. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4820. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4821. continue
  4822. }
  4823. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4824. continue
  4825. }
  4826. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4827. if prescription.OrderStatus == 2 {
  4828. //已经结算
  4829. //判断是否已经销售
  4830. if item.IsSale == 1 { //是否已经销售,1是 0否
  4831. //是否已经变更 1是 0否
  4832. if item.IsChange == 0 { //没变更,进行变更操作
  4833. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4834. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4835. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4836. var respJSON3 map[string]interface{}
  4837. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4839. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4840. return
  4841. }
  4842. userJSONBytes3, _ := json.Marshal(respJSON3)
  4843. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. if res3.Infcode == 0 {
  4849. item.IsChange = 1
  4850. item.BgBchno = bg_number
  4851. service.SaveDF2(item)
  4852. } else {
  4853. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4854. }
  4855. }
  4856. } else { //没销售,
  4857. var res FJ3507Result
  4858. var res3507for10188 FJ3507ResultFor10188
  4859. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4860. //进行商品销售接口
  4861. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4862. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4863. var respJSON3 map[string]interface{}
  4864. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4866. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. userJSONBytes3, _ := json.Marshal(respJSON3)
  4870. {
  4871. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4872. utils.ErrorLog("解析失败:%v", err)
  4873. return
  4874. }
  4875. //if res3507for10188.Infcode
  4876. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4877. //res.Output = resSix10265.Output
  4878. res.ErrMsg = res3507for10188.ErrMsg
  4879. res.Cainfo = res3507for10188.Cainfo
  4880. res.WarnMsg = res3507for10188.WarnMsg
  4881. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4882. res.Infcode = infocode
  4883. }
  4884. if res.Infcode == 0 {
  4885. item.IsSale = 1
  4886. item.Bchno = number
  4887. item.SaleDate = time.Now().Format("2006-01-02")
  4888. err5 := service.SaveDF(item)
  4889. if err5 == nil {
  4890. if item.IsChange == 1 { //没变更,进行变更操作
  4891. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4892. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4893. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4894. var respJSON3 map[string]interface{}
  4895. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4897. return
  4898. }
  4899. {
  4900. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4901. utils.ErrorLog("解析失败:%v", err)
  4902. return
  4903. }
  4904. //if res3507for10188.Infcode
  4905. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4906. //res.Output = resSix10265.Output
  4907. res3.ErrMsg = res3507for10188.ErrMsg
  4908. res3.Cainfo = res3507for10188.Cainfo
  4909. res3.WarnMsg = res3507for10188.WarnMsg
  4910. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4911. res3.Infcode = infocode
  4912. }
  4913. if res3.Infcode == 0 {
  4914. item.IsChange = 1
  4915. item.BgBchno = bg_number
  4916. service.SaveDF2(item)
  4917. } else {
  4918. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4919. }
  4920. }
  4921. }
  4922. } else {
  4923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4924. }
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4931. var struct3502 models.Struct3502
  4932. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4933. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4935. struct3502.FixmedinsCode = miConfig.Code
  4936. struct3502.Code = miConfig.Code
  4937. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4938. struct3502.Opter = role.UserName
  4939. struct3502.RxFlag = "1"
  4940. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4941. struct3502.OrgName = miConfig.OrgName
  4942. struct3502.AccessKey = miConfig.AccessKey
  4943. struct3502.RequestUrl = miConfig.Url
  4944. struct3502.SecretKey = miConfig.SecretKey
  4945. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4946. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4947. struct3502.Url = miConfig.Url
  4948. struct3502.AppId = miConfig.Cainfo
  4949. struct3502.AppSecret = miConfig.AppSecret
  4950. struct3502.Enckey = miConfig.EncKey
  4951. struct3502.SignKey = miConfig.SignKey
  4952. struct3502.SecretKey = miConfig.SecretKey
  4953. struct3502.InvChgType = chgType
  4954. struct3502.FixmedinsBchno = number
  4955. struct3502.Cnt = strconv.FormatInt(count, 10)
  4956. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4957. //result1, result2, _ := service.FJyb3502(struct3502)
  4958. if miConfig.MdtrtareaAdmvs == "350500" {
  4959. result1, result2, _ := service.FJyb3502(struct3502)
  4960. //saveLog(result1, result2, "3502", "3502")
  4961. return result1, result2
  4962. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4963. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4964. return result1, result2
  4965. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4966. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4967. return result1, result2
  4968. } else {
  4969. data := make(map[string]interface{})
  4970. data["struct_3502s"] = struct3502
  4971. client := &http.Client{}
  4972. bytesData, _ := json.Marshal(data)
  4973. var req *http.Request
  4974. if miConfig.MdtrtareaAdmvs == "320921" {
  4975. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4976. } else {
  4977. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4978. }
  4979. resp, _ := client.Do(req)
  4980. defer resp.Body.Close()
  4981. body, ioErr := ioutil.ReadAll(resp.Body)
  4982. if ioErr != nil {
  4983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4984. }
  4985. var respJSON map[string]interface{}
  4986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4988. }
  4989. //var resSix10265 ResultSix10265 //1101结果
  4990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4991. result, _ := json.Marshal(respJSON)
  4992. return string(result), ""
  4993. }
  4994. }
  4995. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4996. var struct3505 models.Struct3505
  4997. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4998. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5000. struct3505.FixmedinsBchno = number
  5001. struct3505.Opter = role.UserName
  5002. struct3505.Bchno = "---"
  5003. struct3505.FixmedinsCode = miConfig.Code
  5004. struct3505.Code = miConfig.Code
  5005. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5006. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5007. struct3505.PrscDrName = roles.UserName
  5008. if org_id == 10191 {
  5009. struct3505.PharName = "刘水山"
  5010. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5011. }
  5012. if org_id == 10188 {
  5013. struct3505.PharName = "李汉清"
  5014. struct3505.PharPracCertNo = "30220200932022010034"
  5015. }
  5016. if org_id == 10217 {
  5017. struct3505.PharName = "张敏"
  5018. struct3505.PharPracCertNo = "30220230432090100108"
  5019. }
  5020. if org_id == 10318 {
  5021. struct3505.PharName = "邹刘阳"
  5022. struct3505.PharPracCertNo = "210441200001378"
  5023. }
  5024. if org_id == 10402 {
  5025. struct3505.PharName = "刘韶健"
  5026. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5027. }
  5028. if org_id == 9919 {
  5029. struct3505.PharName = "周君权"
  5030. struct3505.PharPracCertNo = "089644396094401375"
  5031. }
  5032. if org_id == 10644 {
  5033. struct3505.PharName = "陈金娣"
  5034. struct3505.PharPracCertNo = "20181441500320100066"
  5035. }
  5036. if org_id == 10567 {
  5037. struct3505.PharName = "范小兰"
  5038. struct3505.PharPracCertNo = "0200102079485"
  5039. }
  5040. if org_id == 10721 {
  5041. struct3505.PharName = "孙莉侠"
  5042. struct3505.PharPracCertNo = "060399"
  5043. }
  5044. if org_id == 10726 {
  5045. struct3505.PharName = "彭建福"
  5046. struct3505.PharPracCertNo = "D445281006261"
  5047. }
  5048. if org_id == 10265 {
  5049. struct3505.PharName = "李彩星"
  5050. struct3505.PharPracCertNo = "20171110600110100019"
  5051. }
  5052. if org_id == 10028 {
  5053. struct3505.PharName = "曾细平"
  5054. struct3505.PharPracCertNo = "D440307022134"
  5055. }
  5056. if org_id == 10138 {
  5057. struct3505.PharName = "彭斯遥"
  5058. struct3505.PharPracCertNo = "30220200943042010052"
  5059. }
  5060. if org_id == 10278 {
  5061. struct3505.PharName = "彭斯遥"
  5062. struct3505.PharPracCertNo = "30220200943042010052"
  5063. }
  5064. if org_id == 10610 {
  5065. struct3505.PharName = "彭斯遥"
  5066. struct3505.PharPracCertNo = "30220200943042010052"
  5067. }
  5068. if org_id == 10537 {
  5069. struct3505.PharName = "彭斯遥"
  5070. struct3505.PharPracCertNo = "30220200943042010052"
  5071. }
  5072. if org_id == 9504 {
  5073. struct3505.PharName = "资美红"
  5074. struct3505.PharPracCertNo = "D440904006635"
  5075. }
  5076. if org_id == 10480 {
  5077. struct3505.PharName = "陈思"
  5078. struct3505.PharPracCertNo = "30220240434110010470"
  5079. }
  5080. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5081. struct3505.SetlId = order.SetlId
  5082. struct3505.MdtrtSn = order.MdtrtId
  5083. struct3505.ManuLotnum = drug.BatchNumber
  5084. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5085. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5086. struct3505.RxFlag = "1"
  5087. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5088. struct3505.TrdnFlag = "0"
  5089. } else {
  5090. struct3505.TrdnFlag = "1"
  5091. }
  5092. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5093. struct3505.TrdnFlag = "1"
  5094. }
  5095. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5096. struct3505.TrdnFlag = "0"
  5097. }
  5098. struct3505.RtalDocno = order.Number
  5099. struct3505.PsnCertType = "01"
  5100. struct3505.CertNo = order.Certno
  5101. struct3505.PsnNo = order.PsnNo
  5102. struct3505.PsnName = order.PsnName
  5103. struct3505.Url = miConfig.Url
  5104. struct3505.AppId = miConfig.Cainfo
  5105. struct3505.AppSecret = miConfig.AppSecret
  5106. struct3505.Enckey = miConfig.EncKey
  5107. struct3505.SignKey = miConfig.SignKey
  5108. struct3505.SecretKey = miConfig.SecretKey
  5109. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5110. struct3505.SelRetnCnt = strValue
  5111. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5112. struct3505.SelRetnOpterName = role.UserName
  5113. if order.IsMedicineInsurance == 1 {
  5114. struct3505.MdtrtSetlType = "1"
  5115. } else {
  5116. struct3505.MdtrtSetlType = "2"
  5117. }
  5118. struct3505.OrgName = miConfig.OrgName
  5119. struct3505.AccessKey = miConfig.AccessKey
  5120. struct3505.RequestUrl = miConfig.Url
  5121. struct3505.SecretKey = miConfig.SecretKey
  5122. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5123. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5124. struct3505.Cainfo = miConfig.Cainfo
  5125. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5126. if miConfig.MdtrtareaAdmvs == "350500" {
  5127. result1, result2, _ := service.FJyb3505(struct3505)
  5128. return result1, result2
  5129. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5130. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5131. return result1, result2
  5132. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5133. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5134. return result1, result2
  5135. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5136. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5137. return result1, result2
  5138. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5139. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5140. return result1, result2
  5141. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5142. data := make(map[string]interface{})
  5143. data["struct_3505s"] = struct3505
  5144. client := &http.Client{}
  5145. bytesData, _ := json.Marshal(data)
  5146. var req *http.Request
  5147. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5148. resp, _ := client.Do(req)
  5149. defer resp.Body.Close()
  5150. body, ioErr := ioutil.ReadAll(resp.Body)
  5151. if ioErr != nil {
  5152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5153. }
  5154. var respJSON map[string]interface{}
  5155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5157. }
  5158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5159. result, _ := json.Marshal(respJSON)
  5160. return string(result), ""
  5161. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5162. data := make(map[string]interface{})
  5163. data["struct_3505s"] = struct3505
  5164. client := &http.Client{}
  5165. bytesData, _ := json.Marshal(data)
  5166. var req *http.Request
  5167. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5168. resp, _ := client.Do(req)
  5169. defer resp.Body.Close()
  5170. body, ioErr := ioutil.ReadAll(resp.Body)
  5171. if ioErr != nil {
  5172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5173. }
  5174. var respJSON map[string]interface{}
  5175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5177. }
  5178. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5179. if status == "0" {
  5180. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5181. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5182. }
  5183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5184. result, _ := json.Marshal(respJSON)
  5185. return string(result), ""
  5186. } else {
  5187. data := make(map[string]interface{})
  5188. data["struct_3505s"] = struct3505
  5189. client := &http.Client{}
  5190. bytesData, _ := json.Marshal(data)
  5191. var req *http.Request
  5192. if miConfig.MdtrtareaAdmvs == "320921" {
  5193. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5194. } else {
  5195. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5196. }
  5197. resp, _ := client.Do(req)
  5198. defer resp.Body.Close()
  5199. body, ioErr := ioutil.ReadAll(resp.Body)
  5200. if ioErr != nil {
  5201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5202. }
  5203. var respJSON map[string]interface{}
  5204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5206. }
  5207. //var resSix10265 ResultSix10265 //1101结果
  5208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5209. result, _ := json.Marshal(respJSON)
  5210. return string(result), ""
  5211. }
  5212. }
  5213. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5214. var struct3505 models.Struct3505
  5215. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5216. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5217. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5218. struct3505.FixmedinsBchno = number
  5219. struct3505.Opter = role.UserName
  5220. struct3505.FixmedinsCode = miConfig.Code
  5221. struct3505.Code = miConfig.Code
  5222. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5223. struct3505.PrscDrName = roles.UserName
  5224. if org_id == 10191 {
  5225. struct3505.PharName = "刘水山"
  5226. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5227. }
  5228. if org_id == 10188 {
  5229. struct3505.PharName = "李汉清"
  5230. struct3505.PharPracCertNo = "30220200932022010034"
  5231. }
  5232. if org_id == 10217 {
  5233. struct3505.PharName = "张敏"
  5234. struct3505.PharPracCertNo = "30220230432090100108"
  5235. }
  5236. if org_id == 10318 {
  5237. struct3505.PharName = "邹刘阳"
  5238. struct3505.PharPracCertNo = "210441200001378"
  5239. }
  5240. if org_id == 10402 {
  5241. struct3505.PharName = "刘韶健"
  5242. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5243. }
  5244. if org_id == 9919 {
  5245. struct3505.PharName = "周君权"
  5246. struct3505.PharPracCertNo = "089644396094401375"
  5247. }
  5248. if org_id == 10644 {
  5249. struct3505.PharName = "陈金娣"
  5250. struct3505.PharPracCertNo = "20181441500320100066"
  5251. }
  5252. if org_id == 10567 {
  5253. struct3505.PharName = "范小兰"
  5254. struct3505.PharPracCertNo = "0200102079485"
  5255. }
  5256. if org_id == 10721 {
  5257. struct3505.PharName = "孙莉侠"
  5258. struct3505.PharPracCertNo = "060399"
  5259. }
  5260. if org_id == 10726 {
  5261. struct3505.PharName = "彭建福"
  5262. struct3505.PharPracCertNo = "D445281006261"
  5263. }
  5264. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5265. struct3505.SetlId = order.SetlId
  5266. struct3505.MdtrtSn = order.MdtrtId
  5267. struct3505.ManuLotnum = drug.Number
  5268. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5269. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5270. struct3505.RxFlag = "1"
  5271. struct3505.TrdnFlag = "0"
  5272. struct3505.RtalDocno = order.Number
  5273. struct3505.PsnCertType = "01"
  5274. struct3505.CertNo = order.Certno
  5275. struct3505.PsnNo = order.PsnNo
  5276. struct3505.PsnName = order.PsnName
  5277. struct3505.Url = miConfig.Url
  5278. struct3505.AppId = miConfig.Cainfo
  5279. struct3505.AppSecret = miConfig.AppSecret
  5280. struct3505.Enckey = miConfig.EncKey
  5281. struct3505.SignKey = miConfig.SignKey
  5282. struct3505.SecretKey = miConfig.SecretKey
  5283. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5284. struct3505.SelRetnCnt = strValue
  5285. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5286. struct3505.SelRetnOpterName = role.UserName
  5287. if order.IsMedicineInsurance == 1 {
  5288. struct3505.MdtrtSetlType = "1"
  5289. } else {
  5290. struct3505.MdtrtSetlType = "2"
  5291. }
  5292. struct3505.OrgName = miConfig.OrgName
  5293. struct3505.AccessKey = miConfig.AccessKey
  5294. struct3505.RequestUrl = miConfig.Url
  5295. struct3505.SecretKey = miConfig.SecretKey
  5296. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5297. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5298. struct3505.Cainfo = miConfig.Cainfo
  5299. struct3505.DrugTracCodg = drug.DrugCode
  5300. if miConfig.MdtrtareaAdmvs == "350500" {
  5301. result1, result2, _ := service.FJyb3505(struct3505)
  5302. return result1, result2
  5303. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5304. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5305. return result1, result2
  5306. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5307. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5308. return result1, result2
  5309. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5310. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5311. return result1, result2
  5312. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5313. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5314. return result1, result2
  5315. } else {
  5316. data := make(map[string]interface{})
  5317. data["struct_3505s"] = struct3505
  5318. client := &http.Client{}
  5319. bytesData, _ := json.Marshal(data)
  5320. var req *http.Request
  5321. if miConfig.MdtrtareaAdmvs == "320921" {
  5322. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5323. } else {
  5324. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5325. }
  5326. resp, _ := client.Do(req)
  5327. defer resp.Body.Close()
  5328. body, ioErr := ioutil.ReadAll(resp.Body)
  5329. if ioErr != nil {
  5330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5331. }
  5332. var respJSON map[string]interface{}
  5333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5335. }
  5336. //var resSix10265 ResultSix10265 //1101结果
  5337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5338. result, _ := json.Marshal(respJSON)
  5339. return string(result), ""
  5340. }
  5341. }
  5342. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5343. var struct3506 models.Struct3506
  5344. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5345. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5346. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5347. struct3506.FixmedinsCode = miConfig.Code
  5348. struct3506.Code = miConfig.Code
  5349. struct3506.FixmedinsBchno = number
  5350. struct3506.Opter = role.UserName
  5351. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5352. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5353. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5354. struct3506.MdtrtSn = order.MdtrtId
  5355. struct3506.ExpyEnd = ""
  5356. struct3506.RxFlag = "0"
  5357. struct3506.TrdnFlag = "1"
  5358. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5359. struct3506.SelRetnCnt = strValue
  5360. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5361. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5362. struct3506.SelRetnOpterName = role.UserName
  5363. struct3506.OrgName = miConfig.OrgName
  5364. struct3506.AccessKey = miConfig.AccessKey
  5365. struct3506.RequestUrl = miConfig.Url
  5366. struct3506.SecretKey = miConfig.SecretKey
  5367. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5368. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5369. struct3506.Url = miConfig.Url
  5370. struct3506.AppId = miConfig.Cainfo
  5371. struct3506.AppSecret = miConfig.AppSecret
  5372. struct3506.Enckey = miConfig.EncKey
  5373. struct3506.SignKey = miConfig.SignKey
  5374. struct3506.SecretKey = miConfig.SecretKey
  5375. struct3506.DrugTracCodg = drug.DrugCode
  5376. if miConfig.MdtrtareaAdmvs == "350500" {
  5377. result1, result2, _ := service.FJyb3506(struct3506)
  5378. return result1, result2
  5379. } else {
  5380. data := make(map[string]interface{})
  5381. data["struct_3506s"] = struct3506
  5382. client := &http.Client{}
  5383. bytesData, _ := json.Marshal(data)
  5384. var req *http.Request
  5385. if miConfig.MdtrtareaAdmvs == "320921" {
  5386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5387. } else {
  5388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5389. }
  5390. resp, _ := client.Do(req)
  5391. defer resp.Body.Close()
  5392. body, ioErr := ioutil.ReadAll(resp.Body)
  5393. if ioErr != nil {
  5394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5395. }
  5396. var respJSON map[string]interface{}
  5397. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5399. }
  5400. //var resSix10265 ResultSix10265 //1101结果
  5401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5402. result, _ := json.Marshal(respJSON)
  5403. return string(result), ""
  5404. }
  5405. }
  5406. func (c *HisApiController) Get1318() {
  5407. adminUser := c.GetAdminUserInfo()
  5408. admin_user_id, _ := c.GetInt64("admin_user_id")
  5409. code := c.GetString("code")
  5410. code = ""
  5411. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5413. api := ""
  5414. if miConfig.MdtrtareaAdmvs == "320921" {
  5415. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5416. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5417. } else {
  5418. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5419. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5420. }
  5421. resp, requestErr := http.Get(api)
  5422. if requestErr != nil {
  5423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5424. return
  5425. }
  5426. body, ioErr := ioutil.ReadAll(resp.Body)
  5427. if ioErr != nil {
  5428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5430. return
  5431. }
  5432. var respJSON map[string]interface{}
  5433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5436. return
  5437. }
  5438. //var res Result2406
  5439. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5440. result, _ := json.Marshal(respJSON)
  5441. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5442. utils.ErrorLog("解析失败:%v", err)
  5443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5444. return
  5445. }
  5446. if res.Infcode == "0" {
  5447. c.ServeSuccessJSON(map[string]interface{}{
  5448. "result": "",
  5449. })
  5450. } else {
  5451. c.ServeSuccessJSON(map[string]interface{}{
  5452. "failed_code": -10,
  5453. "msg": res.ErrMsg,
  5454. })
  5455. */return
  5456. //}
  5457. }
  5458. func (c *HisApiController) Get2503() {
  5459. adminUser := c.GetAdminUserInfo()
  5460. admin_user_id, _ := c.GetInt64("admin_user_id")
  5461. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5462. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5463. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5464. }
  5465. func (c *HisApiController) Get2406() {
  5466. id, _ := c.GetInt64("id")
  5467. record_time := c.GetString("record_time")
  5468. his_patient_id, _ := c.GetInt64("his_patient_id")
  5469. admin_user_id, _ := c.GetInt64("admin_user_id")
  5470. diagnosis_id := c.GetString("diagnosis")
  5471. timeLayout := "2006-01-02"
  5472. loc, _ := time.LoadLocation("Local")
  5473. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5474. if err != nil {
  5475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5476. return
  5477. }
  5478. recordDateTime := theTime.Unix()
  5479. adminUser := c.GetAdminUserInfo()
  5480. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5481. var config []*models.HisXtDiagnoseConfig
  5482. for _, item := range diagnosis_ids {
  5483. id, _ := strconv.ParseInt(item, 10, 64)
  5484. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5485. config = append(config, &diagnosisConfig)
  5486. }
  5487. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5488. fmt.Println(his_patient_id)
  5489. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5490. //timestamp := time.Now().Unix()
  5491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5492. var patientPrescription models.HisPrescriptionInfo
  5493. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5494. if patientPrescription.ID == 0 {
  5495. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5496. }
  5497. var res2 Result2406
  5498. if miConfig.MdtrtareaAdmvs == "341203" {
  5499. data := make(map[string]interface{})
  5500. client := &http.Client{}
  5501. data["psn_no"] = his.PsnNo
  5502. data["mdtrt_id"] = his.Number
  5503. data["operator"] = roles.UserName
  5504. data["cert_no"] = his.IdCardNo
  5505. data["org_name"] = miConfig.OrgName
  5506. data["psn_name"] = his.Name
  5507. data["ipt_otp_no"] = his.IptOtpNo
  5508. data["ipt_psn_sp_flag_type"] = "0901"
  5509. data["ipt_psn_sp_flag"] = "1"
  5510. data["fixmedins_code"] = miConfig.Code
  5511. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5512. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5513. data["url"] = miConfig.Url
  5514. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5515. bytesData, _ := json.Marshal(data)
  5516. var req *http.Request
  5517. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5518. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5519. resp, _ := client.Do(req)
  5520. defer resp.Body.Close()
  5521. body, ioErr := ioutil.ReadAll(resp.Body)
  5522. if ioErr != nil {
  5523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5525. return
  5526. }
  5527. var respJSON map[string]interface{}
  5528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5534. if status == "0" {
  5535. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5536. c.ServeSuccessJSON(map[string]interface{}{
  5537. "failed_code": -10,
  5538. "msg": err_msg,
  5539. })
  5540. return
  5541. }
  5542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5543. userJSONBytes, _ := json.Marshal(respJSON)
  5544. fmt.Println("log")
  5545. fmt.Println(string(userJSONBytes))
  5546. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5547. utils.ErrorLog("解析失败:%v", err)
  5548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5549. return
  5550. }
  5551. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5552. data := make(map[string]interface{})
  5553. client := &http.Client{}
  5554. data["psn_no"] = his.PsnNo
  5555. data["mdtrt_id"] = his.Number
  5556. data["operator"] = roles.UserName
  5557. data["cert_no"] = his.IdCardNo
  5558. data["org_name"] = miConfig.OrgName
  5559. data["psn_name"] = his.Name
  5560. data["ipt_otp_no"] = his.IptOtpNo
  5561. data["ipt_psn_sp_flag_type"] = "0901"
  5562. data["ipt_psn_sp_flag"] = "1"
  5563. data["fixmedins_code"] = miConfig.Code
  5564. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5565. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5566. data["url"] = miConfig.Url
  5567. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5568. bytesData, _ := json.Marshal(data)
  5569. var req *http.Request
  5570. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5571. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5572. resp, _ := client.Do(req)
  5573. defer resp.Body.Close()
  5574. body, ioErr := ioutil.ReadAll(resp.Body)
  5575. if ioErr != nil {
  5576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5578. return
  5579. }
  5580. var respJSON map[string]interface{}
  5581. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5584. return
  5585. }
  5586. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5587. if status == "0" {
  5588. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5589. c.ServeSuccessJSON(map[string]interface{}{
  5590. "failed_code": -10,
  5591. "msg": err_msg,
  5592. })
  5593. return
  5594. }
  5595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5596. userJSONBytes, _ := json.Marshal(respJSON)
  5597. fmt.Println("log")
  5598. fmt.Println(string(userJSONBytes))
  5599. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5600. utils.ErrorLog("解析失败:%v", err)
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. }
  5605. if res2.Infcode != 0 {
  5606. adminUser := c.GetAdminUserInfo()
  5607. errlog := &models.HisOrderError{
  5608. UserOrgId: adminUser.CurrentOrgId,
  5609. Ctime: time.Now().Unix(),
  5610. Mtime: time.Now().Unix(),
  5611. ErrMsg: res2.ErrMsg,
  5612. Status: 1,
  5613. PatientId: id,
  5614. RecordTime: recordDateTime,
  5615. Stage: 3,
  5616. }
  5617. service.CreateErrMsgLog(errlog)
  5618. c.ServeSuccessJSON(map[string]interface{}{
  5619. "failed_code": -10,
  5620. "msg": res2.ErrMsg,
  5621. })
  5622. return
  5623. } else {
  5624. c.ServeSuccessJSON(map[string]interface{}{
  5625. "msg": "上传成功",
  5626. })
  5627. return
  5628. }
  5629. }
  5630. func (c *HisApiController) Get4105() {
  5631. }
  5632. func (c *HisApiController) Post5302() {
  5633. patient_id, _ := c.GetInt64("id")
  5634. admin_user_id, _ := c.GetInt64("admin_user_id")
  5635. p, _ := service.GetHisPatientById(patient_id)
  5636. adminUser := c.GetAdminUserInfo()
  5637. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5638. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5639. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5640. }
  5641. func (c *HisApiController) Get4104() {
  5642. }
  5643. type Output struct {
  5644. CertNo string `json:"certno"`
  5645. PsnName string `json:"psn_name"`
  5646. CardNo string `json:"card_no"`
  5647. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5648. CardSN string `json:"card_sn"`
  5649. PsnCertType string `json:"psn_cert_type"`
  5650. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5651. MdtrtCertType string `json:"mdtrt_cert_type"`
  5652. QRCode string `json:"qrCode"`
  5653. EcToken string `json:"ecToken"`
  5654. }
  5655. type AHResponse struct {
  5656. Body AHBody `json:"body"`
  5657. Code int `json:"code"`
  5658. CSBCode int `json:"csbCode"`
  5659. Message string `json:"message"`
  5660. RequestID string `json:"requestId"`
  5661. State struct{} `json:"state"`
  5662. }
  5663. type AHBody struct {
  5664. ErrMsg string `json:"err_msg"`
  5665. InfRefMsgID string `json:"inf_refmsgid"`
  5666. InfCode int `json:"infcode"`
  5667. Output struct {
  5668. Result []struct {
  5669. BasMednFlag string `json:"bas_medn_flag"`
  5670. ChldMedcFlag string `json:"chld_medc_flag"`
  5671. ChrgitmLv string `json:"chrgitm_lv"`
  5672. Cnt float64 `json:"cnt"`
  5673. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5674. DrtReimFlag string `json:"drt_reim_flag"`
  5675. FeedetlSn string `json:"feedetl_sn"`
  5676. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5677. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5678. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5679. ListSpItemFlag string `json:"list_sp_item_flag"`
  5680. LmtUsedFlag string `json:"lmt_used_flag"`
  5681. MedChrgitmType string `json:"med_chrgitm_type"`
  5682. Memo string `json:"memo"`
  5683. OverlmtAmt float64 `json:"overlmt_amt"`
  5684. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5685. Pric float64 `json:"pric"`
  5686. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5687. SelfpayProp float64 `json:"selfpay_prop"`
  5688. } `json:"result"`
  5689. } `json:"output"`
  5690. }
  5691. type Response struct {
  5692. Output Output `json:"output"`
  5693. Infcode int `json:"infcode"`
  5694. InfRefMsgID string `json:"inf_refmsgid"`
  5695. RefMsgTime string `json:"refmsg_time"`
  5696. RespondTime string `json:"respond_time"`
  5697. ErrMsg string `json:"err_msg"`
  5698. WarnMsg string `json:"warn_msg"`
  5699. SignType string `json:"signtype"`
  5700. CAInfo string `json:"cainfo"`
  5701. }
  5702. func (c *HisApiController) Getquerydata() {
  5703. query_type, _ := c.GetInt64("type")
  5704. refd_setl_flag := c.GetString("refd_setl_flag")
  5705. med_type := c.GetString("med_type")
  5706. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5707. cert_no := c.GetString("cert_no")
  5708. psn_no := c.GetString("psn_no")
  5709. start_time := c.GetString("start_time")
  5710. end_time := c.GetString("end_time")
  5711. page, _ := c.GetInt64("page")
  5712. limit, _ := c.GetInt64("limit")
  5713. var bp models.BusinessParams5262
  5714. bp.RefdSetlFlag = refd_setl_flag
  5715. bp.MedType = med_type
  5716. bp.Certno = cert_no
  5717. bp.Psnno = psn_no
  5718. bp.QBegntime = start_time
  5719. bp.QEndtime = end_time
  5720. if query_type == 1 { //本地
  5721. Post5262(c, bp, page, limit)
  5722. } else { //异地
  5723. Post5267(c, bp, page, limit)
  5724. }
  5725. }
  5726. func (c *HisApiController) Drugscheck() {
  5727. admin_user_id, _ := c.GetInt64("admin_user_id")
  5728. adminUser := c.GetAdminUserInfo()
  5729. var queryResult []QueryResult
  5730. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5731. for _, item := range drugs {
  5732. result := QueryResult{
  5733. ID: item.ID,
  5734. Name: item.DrugName,
  5735. Code: item.MedicalInsuranceNumber,
  5736. List_type_code: "101",
  5737. }
  5738. queryResult = append(queryResult, result)
  5739. }
  5740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5741. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5742. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5743. for _, item := range queryResult {
  5744. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  5745. }
  5746. }
  5747. func (c *HisApiController) Goodcheck() {
  5748. admin_user_id, _ := c.GetInt64("admin_user_id")
  5749. adminUser := c.GetAdminUserInfo()
  5750. var queryResult []QueryResult
  5751. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5752. for _, item := range goods {
  5753. result := QueryResult{
  5754. ID: item.ID,
  5755. Name: item.GoodName,
  5756. Code: item.SocialSecurityDirectoryCode,
  5757. List_type_code: "301",
  5758. }
  5759. queryResult = append(queryResult, result)
  5760. }
  5761. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5762. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5764. for _, item := range queryResult {
  5765. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  5766. //service.Hnyb3302(miConfig.OrgName,role.UserName,miConfig.Code,miConfig.InsuplcAdmdvs,miConfig.MdtrtareaAdmvs,miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url,miConfig.AccessKey,miConfig.SecretKey)
  5767. }
  5768. }
  5769. func (c *HisApiController) Projectcheck() {
  5770. admin_user_id, _ := c.GetInt64("admin_user_id")
  5771. adminUser := c.GetAdminUserInfo()
  5772. var queryResult []QueryResult
  5773. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5774. for _, item := range projects {
  5775. result := QueryResult{
  5776. ID: item.ID,
  5777. Name: item.ProjectName,
  5778. Code: item.MedicalCode,
  5779. List_type_code: "201",
  5780. }
  5781. queryResult = append(queryResult, result)
  5782. }
  5783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5784. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5785. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5786. for _, item := range queryResult {
  5787. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  5788. }
  5789. }
  5790. //func (c *HisApiController)CancleDia(){
  5791. //
  5792. // id, _ := c.GetInt64("id")
  5793. // record_time := c.GetString("record_time")
  5794. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5795. //
  5796. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5797. //
  5798. // diagnosis_id := c.GetString("diagnosis")
  5799. // sick_type, _ := c.GetInt64("sick_type")
  5800. // reg_type, _ := c.GetInt64("p_type")
  5801. // begin_time := c.GetString("begin_time")
  5802. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5803. //
  5804. //
  5805. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5806. //
  5807. // fmt.Println(acct_used_flag)
  5808. //
  5809. //
  5810. // timeLayout := "2006-01-02"
  5811. // loc, _ := time.LoadLocation("Local")
  5812. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5813. // if err != nil {
  5814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5815. // return
  5816. // }
  5817. // recordDateTime := theTime.Unix()
  5818. // adminUser := c.GetAdminUserInfo()
  5819. //
  5820. //
  5821. //
  5822. //
  5823. //
  5824. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5825. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5826. // var patientPrescription models.HisPrescriptionInfo
  5827. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5828. // if patientPrescription.ID == 0 {
  5829. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5830. // }
  5831. // //if patientPrescription.Do
  5832. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5833. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5834. //
  5835. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5836. //
  5837. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5838. //
  5839. // var config []*models.HisXtDiagnoseConfig
  5840. // for _, item := range diagnosis_ids {
  5841. // id, _ := strconv.ParseInt(item, 10, 64)
  5842. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5843. // config = append(config, &diagnosisConfig)
  5844. // }
  5845. //
  5846. // sickConfig, _ := service.FindSickById(sick_type)
  5847. //
  5848. //
  5849. // data := make(map[string]interface{})
  5850. // client := &http.Client{}
  5851. // data["psn_no"] = his.PsnNo
  5852. // data["mdtrt_id"] = his.Number
  5853. // data["doctor"] = roles.UserName
  5854. // data["department"] = department.Name
  5855. // data["org_name"] = miConfig.OrgName
  5856. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5857. // data["doctor_id"] = doctor_info.DoctorNumber
  5858. // data["new_doctor_name"] = doctor_info.UserName
  5859. // data["fixmedins_code"] = miConfig.Code
  5860. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5861. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5862. // data["secret_key"] = miConfig.SecretKey
  5863. // data["sick_code"] = sickConfig.CountryCode
  5864. // data["sick_name"] = sickConfig.ClassName
  5865. // data["url"] = miConfig.Url
  5866. // data["ak"] = miConfig.AccessKey
  5867. // data["begin_time"] = begin_time
  5868. // data["cainfo"] = miConfig.Cainfo
  5869. // data["is_vaild"] = "0"
  5870. //
  5871. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5872. // data["config"] = config
  5873. // bytesData, _ := json.Marshal(data)
  5874. //
  5875. // var req *http.Request
  5876. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5877. // resp, _ := client.Do(req)
  5878. // defer resp.Body.Close()
  5879. // body, ioErr := ioutil.ReadAll(resp.Body)
  5880. // if ioErr != nil {
  5881. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5883. // return
  5884. // }
  5885. // var respJSON map[string]interface{}
  5886. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5889. // return
  5890. // }
  5891. //
  5892. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5893. // userJSONBytes, _ := json.Marshal(respJSON)
  5894. // fmt.Println("log")
  5895. // fmt.Println(string(userJSONBytes))
  5896. //
  5897. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5898. // utils.ErrorLog("解析失败:%v", err)
  5899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. // return
  5901. // }
  5902. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5903. // res2.Output = ressix10265.Output
  5904. // res2.ErrMsg = ressix10265.ErrMsg
  5905. // res2.Cainfo = ressix10265.Cainfo
  5906. // res2.WarnMsg = ressix10265.WarnMsg
  5907. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5908. // res2.Infcode = infocode
  5909. //
  5910. //}
  5911. func (c *HisApiController) Get4102() {
  5912. order_id, _ := c.GetInt64("order_id")
  5913. admin_user_id, _ := c.GetInt64("admin_user_id")
  5914. stas_type := c.GetString("stas_type")
  5915. order, _ := service.GetHisOrderByIDTwo(order_id)
  5916. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5917. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5918. var pp models.PublicParams
  5919. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5920. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5921. pp.FixmedinsName = miConfig.OrgName
  5922. pp.FixmedinsCode = miConfig.Code
  5923. pp.RequestUrl = miConfig.Url
  5924. pp.Cainfo = miConfig.Cainfo
  5925. pp.SecretKey = miConfig.SecretKey
  5926. pp.AccessKey = miConfig.AccessKey
  5927. pp.OpterName = curRoles.UserName
  5928. if miConfig.MdtrtareaAdmvs == "350500" {
  5929. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5930. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5931. saveLog(result, request, "4102", "清单确认")
  5932. var dat map[string]interface{}
  5933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5934. fmt.Println(dat)
  5935. } else {
  5936. fmt.Println(err)
  5937. }
  5938. var empty ResultFourteen
  5939. userJSONBytes, _ := json.Marshal(dat)
  5940. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5941. utils.ErrorLog("解析失败:%v", err)
  5942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5943. return
  5944. }
  5945. if empty.Infcode == 0 {
  5946. c.ServeSuccessJSON(map[string]interface{}{
  5947. "msg": "确认成功",
  5948. })
  5949. return
  5950. }
  5951. } else {
  5952. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5953. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5954. result3, request3 := service.Jxyb4105(pp)
  5955. saveLog(result, request, "4102", "清单确认")
  5956. saveLog(result2, request2, "4103", "清单确认")
  5957. saveLog(result3, request3, "4105", "清单统计")
  5958. var dat map[string]interface{}
  5959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5960. fmt.Println(dat)
  5961. } else {
  5962. fmt.Println(err)
  5963. }
  5964. var empty ResultFourteen
  5965. userJSONBytes, _ := json.Marshal(dat)
  5966. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5967. utils.ErrorLog("解析失败:%v", err)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. if empty.Infcode == 0 {
  5972. c.ServeSuccessJSON(map[string]interface{}{
  5973. "msg": "确认成功",
  5974. })
  5975. return
  5976. }
  5977. }
  5978. }
  5979. // 对账权限查询
  5980. func (c *HisApiController) Get3260() {
  5981. admin_user_id, _ := c.GetInt64("admin_user_id")
  5982. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5983. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5984. var api string
  5985. var res models.JSResult3260
  5986. if miConfig.MdtrtareaAdmvs == "320921" {
  5987. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5988. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5989. } else {
  5990. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5991. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5992. }
  5993. resp, requestErr := http.Get(api)
  5994. if requestErr != nil {
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. body, ioErr := ioutil.ReadAll(resp.Body)
  5999. if ioErr != nil {
  6000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. var respJSON map[string]interface{}
  6005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. return
  6009. }
  6010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6011. result, _ := json.Marshal(respJSON)
  6012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6013. utils.ErrorLog("解析失败:%v", err)
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. return
  6016. }
  6017. if res.Infcode == "0" {
  6018. c.ServeSuccessJSON(map[string]interface{}{
  6019. "result": res.Output.Data,
  6020. })
  6021. } else {
  6022. c.ServeSuccessJSON(map[string]interface{}{
  6023. "failed_code": -10,
  6024. "msg": res.ErrMsg,
  6025. })
  6026. return
  6027. }
  6028. }
  6029. func (c *HisApiController) Get3261() {
  6030. admin_user_id, _ := c.GetInt64("admin_user_id")
  6031. //month := c.GetString("month")
  6032. startTime := c.GetString("start_time")
  6033. //endTime, _ := c.GetString("end_time")
  6034. times := strings.Split(startTime, "-")
  6035. stmt_mon := times[0] + times[1]
  6036. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6037. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6038. var api string
  6039. var res models.JSResult3261
  6040. //var res10265 Result5301For10265
  6041. if miConfig.MdtrtareaAdmvs == "320921" {
  6042. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6043. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6044. } else {
  6045. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6046. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6047. }
  6048. resp, requestErr := http.Get(api)
  6049. if requestErr != nil {
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. return
  6052. }
  6053. body, ioErr := ioutil.ReadAll(resp.Body)
  6054. if ioErr != nil {
  6055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6057. return
  6058. }
  6059. var respJSON map[string]interface{}
  6060. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6066. result, _ := json.Marshal(respJSON)
  6067. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6068. utils.ErrorLog("解析失败:%v", err)
  6069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6070. return
  6071. }
  6072. if res.Infcode == "0" {
  6073. c.ServeSuccessJSON(map[string]interface{}{
  6074. "result": res.Output,
  6075. })
  6076. } else {
  6077. c.ServeSuccessJSON(map[string]interface{}{
  6078. "failed_code": -10,
  6079. "msg": res.ErrMsg,
  6080. })
  6081. return
  6082. }
  6083. }
  6084. type TempFun struct {
  6085. FundKey string
  6086. FundCode string
  6087. }
  6088. func (c *HisApiController) Get3262() {
  6089. admin_user_id, _ := c.GetInt64("admin_user_id")
  6090. startTime := c.GetString("start_time")
  6091. endTime := c.GetString("end_time")
  6092. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6094. //timeLayout := "2006-01-02"
  6095. //loc, _ := time.LoadLocation("Local")
  6096. //var theStartTIme int64
  6097. //if len(startTime) > 0 {
  6098. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6099. // if err != nil {
  6100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6101. // return
  6102. // }
  6103. // theStartTIme = theTime.Unix()
  6104. //}
  6105. //var theEndtTIme int64
  6106. //if len(endTime) > 0 {
  6107. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6108. // if err != nil {
  6109. // utils.ErrorLog(err.Error())
  6110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6111. // return
  6112. // }
  6113. // theEndtTIme = theTime.Unix()
  6114. //}
  6115. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6116. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6117. for _, team := range datas {
  6118. fmt.Println(team.PsnTime)
  6119. for _, team_two := range datas_two {
  6120. fmt.Println(team_two.PsnTime)
  6121. if team.FundKey == team_two.FundKey {
  6122. fmt.Println(team_two.PsnTime)
  6123. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6124. fmt.Println(team.PsnTime)
  6125. }
  6126. }
  6127. }
  6128. fmt.Println("1111")
  6129. fmt.Println(datas)
  6130. fmt.Println("1111")
  6131. var twos []models.FixMonRecDetailFileInTwo
  6132. for _, team := range datas {
  6133. var two models.FixMonRecDetailFileInTwo
  6134. two.MedType = team.MedType
  6135. two.Insutype = team.Insutype
  6136. two.PsnType = team.PsnType
  6137. two.MedType = team.MedType
  6138. two.FixBlngAdmdvs = "999999"
  6139. two.InsuAdmdvs = "555555"
  6140. two.PsnTime = team.PsnTime
  6141. two.PsnCnt = team.PsnCnt
  6142. two.FundKey = team.FundKey
  6143. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6144. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6145. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6146. two.MedfeeSumAmt = ms
  6147. two.InscpAmt = ia
  6148. two.FundPaySumAmt = fps
  6149. twos = append(twos, two)
  6150. }
  6151. //startTime := c.GetString("start_time")
  6152. //endTime, _ := c.GetString("end_time")
  6153. times := strings.Split(startTime, "-")
  6154. stmt_mon := times[0] + times[1]
  6155. var funs []models.FundDetail
  6156. for _, item := range datas {
  6157. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6158. funs = append(funs, fun...)
  6159. }
  6160. var funInfos []models.Fund
  6161. //for _, item := range funs {
  6162. // var rf []models.FundInfo
  6163. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6164. // for _, subitem := range rf {
  6165. // var fund models.Fund
  6166. // fund.FundCode = subitem.FundPayType
  6167. // fund.FundName = subitem.FundPayTypeName
  6168. // fund.FundAmt = subitem.FundPayAmt
  6169. // fund.FundKey = item.FundKey
  6170. // fund.InsuAdmdvs = "555555"
  6171. // fund.FixBlngAdmdvs = "999999"
  6172. // funInfos = append(funInfos, fund)
  6173. // }
  6174. //}
  6175. var tempFuns []TempFun
  6176. for _, funInfo := range funInfos {
  6177. var tempFun TempFun
  6178. tempFun.FundKey = funInfo.FundKey
  6179. tempFun.FundCode = funInfo.FundCode
  6180. tempFuns = append(tempFuns, tempFun)
  6181. }
  6182. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6183. fmt.Println(tempFuns)
  6184. var funInfosTwo []models.Fund
  6185. decimal.DivisionPrecision = 2
  6186. for _, item := range tempFuns {
  6187. var fund models.Fund
  6188. for _, subItem := range funInfos {
  6189. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6190. fund.FundKey = subItem.FundKey
  6191. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6192. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6193. fund.FundName = subItem.FundName
  6194. fund.FundCode = subItem.FundCode
  6195. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6196. }
  6197. }
  6198. funInfosTwo = append(funInfosTwo, fund)
  6199. }
  6200. fmt.Println("funInfosTwo")
  6201. fmt.Println(funInfosTwo)
  6202. var upld_btch string
  6203. var empty models.JSResultEmpty
  6204. data := make(map[string]interface{})
  6205. data["org_name"] = miConfig.OrgName
  6206. data["doctor"] = curRoles.UserName
  6207. data["doctor_name"] = curRoles.UserName
  6208. data["fixmedins_code"] = miConfig.Code
  6209. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6210. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6211. data["secret_key"] = miConfig.SecretKey
  6212. data["url"] = miConfig.Url
  6213. data["ak"] = miConfig.AccessKey
  6214. data["cainfo"] = miConfig.Cainfo
  6215. data["datas"] = twos
  6216. data["fund"] = funInfosTwo
  6217. fmt.Println(twos)
  6218. month := time.Unix(1557042972, 0).Format("1")
  6219. year := time.Now().Format("2006")
  6220. month = time.Now().Format("01")
  6221. day := time.Now().Format("02")
  6222. hour := time.Now().Format("15")
  6223. min := time.Now().Format("04")
  6224. sec := time.Now().Format("05")
  6225. fix_fill_date := year + month + day + hour + min + sec
  6226. data["fix_fill_dept"] = miConfig.OrgName
  6227. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6228. data["fix_fill_psn"] = curRoles.UserName
  6229. data["fix_fill_date"] = fix_fill_date
  6230. data["stmt_loc"] = "2"
  6231. data["setl_mon"] = stmt_mon
  6232. upld_btch = "0"
  6233. data["upld_btch"] = upld_btch
  6234. //fmt.Println(data)
  6235. client := &http.Client{}
  6236. bytesData, _ := json.Marshal(data)
  6237. var req *http.Request
  6238. if miConfig.MdtrtareaAdmvs == "320921" {
  6239. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6240. } else {
  6241. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6242. }
  6243. resp, _ := client.Do(req)
  6244. defer resp.Body.Close()
  6245. body, ioErr := ioutil.ReadAll(resp.Body)
  6246. if ioErr != nil {
  6247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6249. }
  6250. var respJSON map[string]interface{}
  6251. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6254. }
  6255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6256. //fmt.Println(respJSON)
  6257. result, _ := json.Marshal(respJSON)
  6258. //fmt.Println(result)
  6259. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6260. utils.ErrorLog("解析失败:%v", err)
  6261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6262. }
  6263. if empty.Infcode != "0" {
  6264. c.ServeSuccessJSON(map[string]interface{}{
  6265. "failed_code": -10,
  6266. "msg": empty.ErrMsg,
  6267. })
  6268. return
  6269. } else {
  6270. c.ServeSuccessJSON(map[string]interface{}{
  6271. "msg": "上传成功",
  6272. })
  6273. return
  6274. }
  6275. }
  6276. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6277. newArr = make([]TempFun, 0)
  6278. for i := 0; i < len(arr); i++ {
  6279. repeat := false
  6280. for j := i + 1; j < len(arr); j++ {
  6281. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6282. repeat = true
  6283. break
  6284. }
  6285. }
  6286. if !repeat {
  6287. newArr = append(newArr, arr[i])
  6288. }
  6289. }
  6290. return
  6291. }
  6292. func (c *HisApiController) Get3263() {
  6293. admin_user_id, _ := c.GetInt64("admin_user_id")
  6294. startTime := c.GetString("start_time")
  6295. //endTime, _ := c.GetString("end_time")
  6296. times := strings.Split(startTime, "-")
  6297. setl_mon := times[0] + times[1]
  6298. upld_btch := "0"
  6299. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6301. var result3263 models.JSResult3263
  6302. data := make(map[string]interface{})
  6303. data["org_name"] = miConfig.OrgName
  6304. data["doctor"] = curRoles.UserName
  6305. data["doctor_name"] = curRoles.UserName
  6306. data["fixmedins_code"] = miConfig.Code
  6307. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6308. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6309. data["secret_key"] = miConfig.SecretKey
  6310. data["url"] = miConfig.Url
  6311. data["ak"] = miConfig.AccessKey
  6312. data["cainfo"] = miConfig.Cainfo
  6313. data["setl_mon"] = setl_mon
  6314. data["stmt_loc"] = "2"
  6315. data["upld_btch"] = upld_btch
  6316. client := &http.Client{}
  6317. bytesData, _ := json.Marshal(data)
  6318. var req *http.Request
  6319. if miConfig.MdtrtareaAdmvs == "320921" {
  6320. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6321. } else {
  6322. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6323. }
  6324. resp, _ := client.Do(req)
  6325. defer resp.Body.Close()
  6326. body, ioErr := ioutil.ReadAll(resp.Body)
  6327. if ioErr != nil {
  6328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6330. }
  6331. var respJSON map[string]interface{}
  6332. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6335. }
  6336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6337. fmt.Println(respJSON)
  6338. result, _ := json.Marshal(respJSON)
  6339. fmt.Println(result)
  6340. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6341. utils.ErrorLog("解析失败:%v", err)
  6342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6343. }
  6344. if result3263.Infcode != "0" {
  6345. c.ServeSuccessJSON(map[string]interface{}{
  6346. "failed_code": -10,
  6347. "msg": result3263.ErrMsg,
  6348. })
  6349. return
  6350. } else {
  6351. c.ServeSuccessJSON(map[string]interface{}{
  6352. "list": result3263.Output,
  6353. })
  6354. return
  6355. }
  6356. }
  6357. func (c *HisApiController) Get3264() {
  6358. admin_user_id, _ := c.GetInt64("admin_user_id")
  6359. startTime := c.GetString("start_time")
  6360. //endTime, _ := c.GetString("end_time")
  6361. times := strings.Split(startTime, "-")
  6362. setl_mon := times[0] + times[1]
  6363. upld_btch := "0"
  6364. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6366. //solidify_id := []
  6367. var result3263 models.JSResult3263
  6368. data := make(map[string]interface{})
  6369. data["org_name"] = miConfig.OrgName
  6370. data["doctor"] = curRoles.UserName
  6371. data["doctor_name"] = curRoles.UserName
  6372. data["fixmedins_code"] = miConfig.Code
  6373. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6375. data["secret_key"] = miConfig.SecretKey
  6376. data["url"] = miConfig.Url
  6377. data["ak"] = miConfig.AccessKey
  6378. data["cainfo"] = miConfig.Cainfo
  6379. data["setl_mon"] = setl_mon
  6380. data["stmt_loc"] = "2"
  6381. data["upld_btch"] = upld_btch
  6382. client := &http.Client{}
  6383. bytesData, _ := json.Marshal(data)
  6384. var req3263 *http.Request
  6385. if miConfig.MdtrtareaAdmvs == "320921" {
  6386. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6387. } else {
  6388. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6389. }
  6390. resp, _ := client.Do(req3263)
  6391. defer resp.Body.Close()
  6392. body, ioErr := ioutil.ReadAll(resp.Body)
  6393. if ioErr != nil {
  6394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6396. }
  6397. var respJSON3263 map[string]interface{}
  6398. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6401. }
  6402. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6403. fmt.Println(respJSON3263)
  6404. result, _ := json.Marshal(respJSON3263)
  6405. fmt.Println(result)
  6406. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6407. utils.ErrorLog("解析失败:%v", err)
  6408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6409. }
  6410. var ids []string
  6411. for _, item := range result3263.Output {
  6412. ids = append(ids, item.SolidifyID)
  6413. }
  6414. var empty models.JSResultEmpty
  6415. data2 := make(map[string]interface{})
  6416. data2["org_name"] = miConfig.OrgName
  6417. data2["doctor"] = curRoles.UserName
  6418. data2["doctor_name"] = curRoles.UserName
  6419. data2["fixmedins_code"] = miConfig.Code
  6420. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6421. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6422. data2["secret_key"] = miConfig.SecretKey
  6423. data2["url"] = miConfig.Url
  6424. data2["ak"] = miConfig.AccessKey
  6425. data2["cainfo"] = miConfig.Cainfo
  6426. data2["setl_mon"] = setl_mon
  6427. data2["stmt_loc"] = "2"
  6428. data2["upld_btch"] = upld_btch
  6429. data2["solidify_id"] = ids
  6430. client2 := &http.Client{}
  6431. bytesData2, _ := json.Marshal(data2)
  6432. var req *http.Request
  6433. if miConfig.MdtrtareaAdmvs == "320921" {
  6434. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6435. } else {
  6436. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6437. }
  6438. resp2, _ := client2.Do(req)
  6439. defer resp.Body.Close()
  6440. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6441. if ioErr2 != nil {
  6442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. }
  6445. var respJSON map[string]interface{}
  6446. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6449. }
  6450. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6451. fmt.Println(respJSON)
  6452. result2, _ := json.Marshal(respJSON)
  6453. fmt.Println(result2)
  6454. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6455. utils.ErrorLog("解析失败:%v", err)
  6456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6457. }
  6458. if empty.Infcode != "0" {
  6459. c.ServeSuccessJSON(map[string]interface{}{
  6460. "failed_code": -10,
  6461. "msg": empty.ErrMsg,
  6462. })
  6463. return
  6464. } else {
  6465. c.ServeSuccessJSON(map[string]interface{}{
  6466. "msg": "",
  6467. })
  6468. return
  6469. }
  6470. }
  6471. func (c *HisApiController) Get3265() {
  6472. admin_user_id, _ := c.GetInt64("admin_user_id")
  6473. startTime := c.GetString("start_time")
  6474. //endTime, _ := c.GetString("end_time")
  6475. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6476. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6477. times := strings.Split(startTime, "-")
  6478. setl_mon := times[0] + times[1]
  6479. var upld_btch string
  6480. upld_btch = "0"
  6481. //var empty models.JSResultEmpty
  6482. var result3265 models.JSResult3264
  6483. var result3263 models.JSResult3263
  6484. data2 := make(map[string]interface{})
  6485. data2["org_name"] = miConfig.OrgName
  6486. data2["doctor"] = curRoles.UserName
  6487. data2["doctor_name"] = curRoles.UserName
  6488. data2["fixmedins_code"] = miConfig.Code
  6489. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6490. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6491. data2["secret_key"] = miConfig.SecretKey
  6492. data2["url"] = miConfig.Url
  6493. data2["ak"] = miConfig.AccessKey
  6494. data2["cainfo"] = miConfig.Cainfo
  6495. data2["setl_mon"] = setl_mon
  6496. data2["stmt_loc"] = "2"
  6497. data2["upld_btch"] = upld_btch
  6498. client2 := &http.Client{}
  6499. bytesData2, _ := json.Marshal(data2)
  6500. var req3263 *http.Request
  6501. if miConfig.MdtrtareaAdmvs == "320921" {
  6502. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6503. } else {
  6504. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6505. }
  6506. resp2, _ := client2.Do(req3263)
  6507. defer resp2.Body.Close()
  6508. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6509. if ioErr2 != nil {
  6510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6512. }
  6513. var respJSON3263 map[string]interface{}
  6514. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6517. }
  6518. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6519. fmt.Println(respJSON3263)
  6520. result2, _ := json.Marshal(respJSON3263)
  6521. fmt.Println(result2)
  6522. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6523. utils.ErrorLog("解析失败:%v", err)
  6524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6525. }
  6526. var ids []string
  6527. for _, item := range result3263.Output {
  6528. ids = append(ids, item.SolidifyID)
  6529. }
  6530. data := make(map[string]interface{})
  6531. data["org_name"] = miConfig.OrgName
  6532. data["doctor"] = curRoles.UserName
  6533. data["doctor_name"] = curRoles.UserName
  6534. data["fixmedins_code"] = miConfig.Code
  6535. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6536. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6537. data["secret_key"] = miConfig.SecretKey
  6538. data["url"] = miConfig.Url
  6539. data["ak"] = miConfig.AccessKey
  6540. data["cainfo"] = miConfig.Cainfo
  6541. data["setl_mon"] = setl_mon
  6542. data["solidify_id"] = ids
  6543. month := time.Unix(1557042972, 0).Format("1")
  6544. year := time.Now().Format("2006")
  6545. month = time.Now().Format("01")
  6546. day := time.Now().Format("02")
  6547. hour := time.Now().Format("15")
  6548. min := time.Now().Format("04")
  6549. sec := time.Now().Format("05")
  6550. fix_fill_date := year + month + day + hour + min + sec
  6551. data["fix_fill_dept"] = miConfig.OrgName
  6552. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6553. data["fix_fill_psn"] = curRoles.UserName
  6554. data["fix_fill_date"] = fix_fill_date
  6555. data["stmt_loc"] = "2"
  6556. data["upld_btch"] = upld_btch
  6557. client := &http.Client{}
  6558. bytesData, _ := json.Marshal(data)
  6559. var req *http.Request
  6560. if miConfig.MdtrtareaAdmvs == "320921" {
  6561. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6562. } else {
  6563. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6564. }
  6565. resp, _ := client.Do(req)
  6566. defer resp.Body.Close()
  6567. body, ioErr := ioutil.ReadAll(resp.Body)
  6568. if ioErr != nil {
  6569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. }
  6572. var respJSON map[string]interface{}
  6573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. }
  6577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6578. fmt.Println(respJSON)
  6579. result, _ := json.Marshal(respJSON)
  6580. fmt.Println(result)
  6581. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6582. utils.ErrorLog("解析失败:%v", err)
  6583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6584. }
  6585. if result3265.Infcode != "0" {
  6586. c.ServeSuccessJSON(map[string]interface{}{
  6587. "failed_code": -10,
  6588. "msg": result3265.ErrMsg,
  6589. })
  6590. return
  6591. } else {
  6592. c.ServeSuccessJSON(map[string]interface{}{
  6593. "info": result3265.Output,
  6594. })
  6595. return
  6596. }
  6597. }
  6598. func (c *HisApiController) Get3266() {
  6599. admin_user_id, _ := c.GetInt64("admin_user_id")
  6600. startTime := c.GetString("start_time")
  6601. //endTime, _ := c.GetString("end_time")
  6602. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6603. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6604. times := strings.Split(startTime, "-")
  6605. stmt_mon := times[0] + times[1]
  6606. var upld_btch string
  6607. //var empty models.JSResultEmpty
  6608. var result3265 models.JSResult3264
  6609. data := make(map[string]interface{})
  6610. data["org_name"] = miConfig.OrgName
  6611. data["doctor"] = curRoles.UserName
  6612. data["doctor_name"] = curRoles.UserName
  6613. data["fixmedins_code"] = miConfig.Code
  6614. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6615. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6616. data["secret_key"] = miConfig.SecretKey
  6617. data["url"] = miConfig.Url
  6618. data["ak"] = miConfig.AccessKey
  6619. data["cainfo"] = miConfig.Cainfo
  6620. data["setl_mon"] = stmt_mon
  6621. month := time.Unix(1557042972, 0).Format("1")
  6622. year := time.Now().Format("2006")
  6623. month = time.Now().Format("01")
  6624. day := time.Now().Format("02")
  6625. hour := time.Now().Format("15")
  6626. min := time.Now().Format("04")
  6627. sec := time.Now().Format("05")
  6628. fix_fill_date := year + month + day + hour + min + sec
  6629. data["fix_fill_dept"] = miConfig.OrgName
  6630. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6631. data["fix_fill_psn"] = curRoles.UserName
  6632. data["fix_fill_date"] = fix_fill_date
  6633. data["stmt_loc"] = "2"
  6634. upld_btch = "0"
  6635. data["upld_btch"] = upld_btch
  6636. client := &http.Client{}
  6637. bytesData, _ := json.Marshal(data)
  6638. var req *http.Request
  6639. if miConfig.MdtrtareaAdmvs == "320921" {
  6640. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6641. } else {
  6642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6643. }
  6644. resp, _ := client.Do(req)
  6645. defer resp.Body.Close()
  6646. body, ioErr := ioutil.ReadAll(resp.Body)
  6647. if ioErr != nil {
  6648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. }
  6651. var respJSON map[string]interface{}
  6652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6655. }
  6656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6657. fmt.Println(respJSON)
  6658. result, _ := json.Marshal(respJSON)
  6659. fmt.Println(result)
  6660. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6661. utils.ErrorLog("解析失败:%v", err)
  6662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6663. }
  6664. if result3265.Infcode != "0" {
  6665. c.ServeSuccessJSON(map[string]interface{}{
  6666. "failed_code": -10,
  6667. "msg": result3265.ErrMsg,
  6668. })
  6669. return
  6670. } else {
  6671. c.ServeSuccessJSON(map[string]interface{}{
  6672. "info": result3265.Output,
  6673. })
  6674. return
  6675. }
  6676. }
  6677. func (c *HisApiController) Get3267() {
  6678. admin_user_id, _ := c.GetInt64("admin_user_id")
  6679. startTime := c.GetString("start_time")
  6680. //endTime, _ := c.GetString("end_time")
  6681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6683. times := strings.Split(startTime, "-")
  6684. setl_mon := times[0] + times[1]
  6685. var upld_btch string
  6686. //var empty models.JSResultEmpty
  6687. var result3265 models.JSResult3264
  6688. upld_btch = "0"
  6689. data := make(map[string]interface{})
  6690. data["org_name"] = miConfig.OrgName
  6691. data["doctor"] = curRoles.UserName
  6692. data["doctor_name"] = curRoles.UserName
  6693. data["fixmedins_code"] = miConfig.Code
  6694. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6695. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6696. data["secret_key"] = miConfig.SecretKey
  6697. data["url"] = miConfig.Url
  6698. data["ak"] = miConfig.AccessKey
  6699. data["cainfo"] = miConfig.Cainfo
  6700. data["setl_mon"] = setl_mon
  6701. data["stmt_loc"] = "2"
  6702. data["upld_btch"] = upld_btch
  6703. client := &http.Client{}
  6704. bytesData, _ := json.Marshal(data)
  6705. var req *http.Request
  6706. if miConfig.MdtrtareaAdmvs == "320921" {
  6707. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6708. } else {
  6709. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6710. }
  6711. resp, _ := client.Do(req)
  6712. defer resp.Body.Close()
  6713. body, ioErr := ioutil.ReadAll(resp.Body)
  6714. if ioErr != nil {
  6715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. }
  6718. var respJSON map[string]interface{}
  6719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6722. }
  6723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6724. fmt.Println(respJSON)
  6725. result, _ := json.Marshal(respJSON)
  6726. fmt.Println(result)
  6727. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6728. utils.ErrorLog("解析失败:%v", err)
  6729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6730. }
  6731. if result3265.Infcode != "0" {
  6732. c.ServeSuccessJSON(map[string]interface{}{
  6733. "failed_code": -10,
  6734. "msg": result3265.ErrMsg,
  6735. })
  6736. return
  6737. } else {
  6738. c.ServeSuccessJSON(map[string]interface{}{
  6739. "info": result3265.Output.Data,
  6740. })
  6741. return
  6742. }
  6743. }
  6744. func (c *HisApiController) Get3268() {
  6745. admin_user_id, _ := c.GetInt64("admin_user_id")
  6746. startTime := c.GetString("start_time")
  6747. endTime := c.GetString("end_time")
  6748. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6750. times := strings.Split(startTime, "-")
  6751. setl_mon := times[0] + times[1]
  6752. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6753. var twos []models.FixMonRecDetailFileInTwo
  6754. var funs []models.FundDetail
  6755. for _, item := range datas {
  6756. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6757. funs = append(funs, fun...)
  6758. }
  6759. var funInfos []models.Fund
  6760. //for _, item := range funs {
  6761. // var rf []models.FundInfo
  6762. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6763. // for _, subitem := range rf {
  6764. // var fund models.Fund
  6765. // fund.FundCode = subitem.FundPayType
  6766. // fund.FundName = subitem.FundPayTypeName
  6767. // fund.FundAmt = subitem.FundPayAmt
  6768. // fund.FundKey = item.FundKey
  6769. // fund.InsuAdmdvs = "555555"
  6770. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6771. // funInfos = append(funInfos, fund)
  6772. // }
  6773. //}
  6774. for _, team := range datas {
  6775. var two models.FixMonRecDetailFileInTwo
  6776. two.SetlDate = time.Now().Format("2006-01-02")
  6777. two.MedType = team.MedType
  6778. two.Insutype = team.Insutype
  6779. two.PsnType = team.PsnType
  6780. two.MedType = team.MedType
  6781. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6782. two.InsuAdmdvs = team.InsuAdmdvs
  6783. two.PsnTime = team.PsnTime
  6784. two.PsnCnt = team.PsnCnt
  6785. two.FundKey = team.FundKey
  6786. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6787. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6788. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6789. two.MedfeeSumAmt = ms
  6790. two.InscpAmt = ia
  6791. two.FundPaySumAmt = fps
  6792. twos = append(twos, two)
  6793. }
  6794. var upld_btch string
  6795. upld_btch = "0"
  6796. var empty models.JSResultEmpty
  6797. data := make(map[string]interface{})
  6798. data["org_name"] = miConfig.OrgName
  6799. data["doctor"] = curRoles.UserName
  6800. data["doctor_name"] = curRoles.UserName
  6801. data["fixmedins_code"] = miConfig.Code
  6802. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6803. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6804. data["secret_key"] = miConfig.SecretKey
  6805. data["url"] = miConfig.Url
  6806. data["ak"] = miConfig.AccessKey
  6807. data["cainfo"] = miConfig.Cainfo
  6808. data["datas"] = twos
  6809. data["fund"] = funInfos
  6810. data["setl_mon"] = setl_mon
  6811. month := time.Unix(1557042972, 0).Format("1")
  6812. year := time.Now().Format("2006")
  6813. month = time.Now().Format("01")
  6814. day := time.Now().Format("02")
  6815. hour := time.Now().Format("15")
  6816. min := time.Now().Format("04")
  6817. sec := time.Now().Format("05")
  6818. fix_fill_date := year + month + day + hour + min + sec
  6819. data["fix_fill_dept"] = miConfig.OrgName
  6820. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6821. data["fix_fill_psn"] = curRoles.UserName
  6822. data["fix_fill_date"] = fix_fill_date
  6823. data["stmt_loc"] = "2"
  6824. data["upld_btch"] = upld_btch
  6825. client := &http.Client{}
  6826. bytesData, _ := json.Marshal(data)
  6827. var req *http.Request
  6828. if miConfig.MdtrtareaAdmvs == "320921" {
  6829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6830. } else {
  6831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6832. }
  6833. resp, _ := client.Do(req)
  6834. defer resp.Body.Close()
  6835. body, ioErr := ioutil.ReadAll(resp.Body)
  6836. if ioErr != nil {
  6837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6839. }
  6840. var respJSON map[string]interface{}
  6841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. }
  6845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6846. fmt.Println(respJSON)
  6847. result, _ := json.Marshal(respJSON)
  6848. fmt.Println(result)
  6849. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6850. utils.ErrorLog("解析失败:%v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. }
  6853. if empty.Infcode != "0" {
  6854. c.ServeSuccessJSON(map[string]interface{}{
  6855. "failed_code": -10,
  6856. "msg": empty.ErrMsg,
  6857. })
  6858. return
  6859. } else {
  6860. c.ServeSuccessJSON(map[string]interface{}{
  6861. "msg": "上传成功",
  6862. })
  6863. return
  6864. }
  6865. }
  6866. func (c *HisApiController) Get3269() {
  6867. admin_user_id, _ := c.GetInt64("admin_user_id")
  6868. startTime := c.GetString("start_time")
  6869. //endTime, _ := c.GetString("end_time")
  6870. times := strings.Split(startTime, "-")
  6871. setl_mon := times[0] + times[1]
  6872. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6873. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6874. var result3263 models.JSResult3263
  6875. data := make(map[string]interface{})
  6876. data["org_name"] = miConfig.OrgName
  6877. data["doctor"] = curRoles.UserName
  6878. data["doctor_name"] = curRoles.UserName
  6879. data["fixmedins_code"] = miConfig.Code
  6880. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6881. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6882. data["secret_key"] = miConfig.SecretKey
  6883. data["url"] = miConfig.Url
  6884. data["ak"] = miConfig.AccessKey
  6885. data["cainfo"] = miConfig.Cainfo
  6886. data["setl_mon"] = setl_mon
  6887. data["stmt_loc"] = "2"
  6888. client := &http.Client{}
  6889. bytesData, _ := json.Marshal(data)
  6890. var req *http.Request
  6891. if miConfig.MdtrtareaAdmvs == "320921" {
  6892. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6893. } else {
  6894. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6895. }
  6896. resp, _ := client.Do(req)
  6897. defer resp.Body.Close()
  6898. body, ioErr := ioutil.ReadAll(resp.Body)
  6899. if ioErr != nil {
  6900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. }
  6903. var respJSON map[string]interface{}
  6904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. }
  6908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6909. fmt.Println(respJSON)
  6910. result, _ := json.Marshal(respJSON)
  6911. fmt.Println(result)
  6912. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6913. utils.ErrorLog("解析失败:%v", err)
  6914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6915. }
  6916. if result3263.Infcode != "0" {
  6917. c.ServeSuccessJSON(map[string]interface{}{
  6918. "failed_code": -10,
  6919. "msg": result3263.ErrMsg,
  6920. })
  6921. return
  6922. } else {
  6923. c.ServeSuccessJSON(map[string]interface{}{
  6924. "msg": "上传成功",
  6925. })
  6926. return
  6927. }
  6928. }
  6929. func (c *HisApiController) Get3270() {
  6930. admin_user_id, _ := c.GetInt64("admin_user_id")
  6931. startTime := c.GetString("start_time")
  6932. //endTime, _ := c.GetString("end_time")
  6933. times := strings.Split(startTime, "-")
  6934. setl_mon := times[0] + times[1]
  6935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6936. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6937. var result3263 models.JSResult3263
  6938. data2 := make(map[string]interface{})
  6939. data2["org_name"] = miConfig.OrgName
  6940. data2["doctor"] = curRoles.UserName
  6941. data2["doctor_name"] = curRoles.UserName
  6942. data2["fixmedins_code"] = miConfig.Code
  6943. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6944. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6945. data2["secret_key"] = miConfig.SecretKey
  6946. data2["url"] = miConfig.Url
  6947. data2["ak"] = miConfig.AccessKey
  6948. data2["cainfo"] = miConfig.Cainfo
  6949. data2["setl_mon"] = setl_mon
  6950. data2["stmt_loc"] = "2"
  6951. client2 := &http.Client{}
  6952. bytesData2, _ := json.Marshal(data2)
  6953. var req3263 *http.Request
  6954. if miConfig.MdtrtareaAdmvs == "320921" {
  6955. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6956. } else {
  6957. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6958. }
  6959. resp2, _ := client2.Do(req3263)
  6960. defer resp2.Body.Close()
  6961. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6962. if ioErr2 != nil {
  6963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. }
  6966. var respJSON3263 map[string]interface{}
  6967. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6970. }
  6971. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6972. fmt.Println(respJSON3263)
  6973. result2, _ := json.Marshal(respJSON3263)
  6974. fmt.Println(result2)
  6975. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6976. utils.ErrorLog("解析失败:%v", err)
  6977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6978. }
  6979. var ids []string
  6980. for _, item := range result3263.Output {
  6981. ids = append(ids, item.SolidifyID)
  6982. }
  6983. var result3264 models.JSResult3264
  6984. data := make(map[string]interface{})
  6985. data["org_name"] = miConfig.OrgName
  6986. data["doctor"] = curRoles.UserName
  6987. data["doctor_name"] = curRoles.UserName
  6988. data["fixmedins_code"] = miConfig.Code
  6989. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6990. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6991. data["secret_key"] = miConfig.SecretKey
  6992. data["url"] = miConfig.Url
  6993. data["ak"] = miConfig.AccessKey
  6994. data["cainfo"] = miConfig.Cainfo
  6995. data["setl_mon"] = setl_mon
  6996. data["stmt_loc"] = "2"
  6997. data["solidify_id"] = ids
  6998. client := &http.Client{}
  6999. bytesData, _ := json.Marshal(data)
  7000. var req *http.Request
  7001. if miConfig.MdtrtareaAdmvs == "320921" {
  7002. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7003. } else {
  7004. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7005. }
  7006. resp, _ := client.Do(req)
  7007. defer resp.Body.Close()
  7008. body, ioErr := ioutil.ReadAll(resp.Body)
  7009. if ioErr != nil {
  7010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7012. }
  7013. var respJSON map[string]interface{}
  7014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7017. }
  7018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7019. fmt.Println(respJSON)
  7020. result, _ := json.Marshal(respJSON)
  7021. fmt.Println(result)
  7022. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7023. utils.ErrorLog("解析失败:%v", err)
  7024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7025. }
  7026. if result3264.Infcode != "0" {
  7027. c.ServeSuccessJSON(map[string]interface{}{
  7028. "failed_code": -10,
  7029. "msg": result3264.ErrMsg,
  7030. })
  7031. return
  7032. } else {
  7033. c.ServeSuccessJSON(map[string]interface{}{
  7034. "info": result3264.Output,
  7035. })
  7036. return
  7037. }
  7038. }
  7039. func (c *HisApiController) Get3271() {
  7040. admin_user_id, _ := c.GetInt64("admin_user_id")
  7041. startTime := c.GetString("start_time")
  7042. //endTime, _ := c.GetString("end_time")
  7043. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7044. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7045. times := strings.Split(startTime, "-")
  7046. setl_mon := times[0] + times[1]
  7047. //var empty models.JSResultEmpty
  7048. var result3265 models.JSResult3264
  7049. var result3263 models.JSResult3263
  7050. data2 := make(map[string]interface{})
  7051. data2["org_name"] = miConfig.OrgName
  7052. data2["doctor"] = curRoles.UserName
  7053. data2["doctor_name"] = curRoles.UserName
  7054. data2["fixmedins_code"] = miConfig.Code
  7055. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7056. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7057. data2["secret_key"] = miConfig.SecretKey
  7058. data2["url"] = miConfig.Url
  7059. data2["ak"] = miConfig.AccessKey
  7060. data2["cainfo"] = miConfig.Cainfo
  7061. data2["setl_mon"] = setl_mon
  7062. data2["stmt_loc"] = "2"
  7063. client2 := &http.Client{}
  7064. bytesData2, _ := json.Marshal(data2)
  7065. var req3263 *http.Request
  7066. if miConfig.MdtrtareaAdmvs == "320921" {
  7067. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7068. } else {
  7069. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7070. }
  7071. resp2, _ := client2.Do(req3263)
  7072. defer resp2.Body.Close()
  7073. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7074. if ioErr2 != nil {
  7075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7077. }
  7078. var respJSON3263 map[string]interface{}
  7079. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. }
  7083. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. fmt.Println(respJSON3263)
  7085. result2, _ := json.Marshal(respJSON3263)
  7086. fmt.Println(result2)
  7087. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7088. utils.ErrorLog("解析失败:%v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. }
  7091. var ids []string
  7092. for _, item := range result3263.Output {
  7093. ids = append(ids, item.SolidifyID)
  7094. }
  7095. data := make(map[string]interface{})
  7096. data["org_name"] = miConfig.OrgName
  7097. data["doctor"] = curRoles.UserName
  7098. data["doctor_name"] = curRoles.UserName
  7099. data["fixmedins_code"] = miConfig.Code
  7100. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7101. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7102. data["secret_key"] = miConfig.SecretKey
  7103. data["url"] = miConfig.Url
  7104. data["ak"] = miConfig.AccessKey
  7105. data["cainfo"] = miConfig.Cainfo
  7106. data["setl_mon"] = setl_mon
  7107. data["solidify_id"] = ids
  7108. month := time.Unix(1557042972, 0).Format("1")
  7109. year := time.Now().Format("2006")
  7110. month = time.Now().Format("01")
  7111. day := time.Now().Format("02")
  7112. hour := time.Now().Format("15")
  7113. min := time.Now().Format("04")
  7114. sec := time.Now().Format("05")
  7115. fix_fill_date := year + month + day + hour + min + sec
  7116. data["fix_fill_dept"] = miConfig.OrgName
  7117. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7118. data["fix_fill_psn"] = curRoles.UserName
  7119. data["fix_fill_date"] = fix_fill_date
  7120. data["stmt_loc"] = "2"
  7121. client := &http.Client{}
  7122. bytesData, _ := json.Marshal(data)
  7123. var req *http.Request
  7124. if miConfig.MdtrtareaAdmvs == "320921" {
  7125. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7126. } else {
  7127. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7128. }
  7129. resp, _ := client.Do(req)
  7130. defer resp.Body.Close()
  7131. body, ioErr := ioutil.ReadAll(resp.Body)
  7132. if ioErr != nil {
  7133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7135. }
  7136. var respJSON map[string]interface{}
  7137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. }
  7141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7142. fmt.Println(respJSON)
  7143. result, _ := json.Marshal(respJSON)
  7144. fmt.Println(result)
  7145. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7146. utils.ErrorLog("解析失败:%v", err)
  7147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. }
  7149. if result3265.Infcode != "0" {
  7150. c.ServeSuccessJSON(map[string]interface{}{
  7151. "failed_code": -10,
  7152. "msg": result3265.ErrMsg,
  7153. })
  7154. return
  7155. } else {
  7156. c.ServeSuccessJSON(map[string]interface{}{
  7157. "info": result3265.Output.Data,
  7158. })
  7159. return
  7160. }
  7161. }
  7162. func (c *HisApiController) Get3272() {
  7163. admin_user_id, _ := c.GetInt64("admin_user_id")
  7164. startTime := c.GetString("start_time")
  7165. //endTime, _ := c.GetString("end_time")
  7166. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7167. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7168. times := strings.Split(startTime, "-")
  7169. setl_mon := times[0] + times[1]
  7170. var upld_btch string
  7171. //var empty models.JSResultEmpty
  7172. var result3265 models.JSResult3264
  7173. data := make(map[string]interface{})
  7174. data["org_name"] = miConfig.OrgName
  7175. data["doctor"] = curRoles.UserName
  7176. data["doctor_name"] = curRoles.UserName
  7177. data["fixmedins_code"] = miConfig.Code
  7178. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7180. data["secret_key"] = miConfig.SecretKey
  7181. data["url"] = miConfig.Url
  7182. data["ak"] = miConfig.AccessKey
  7183. data["cainfo"] = miConfig.Cainfo
  7184. data["setl_mon"] = setl_mon
  7185. month := time.Unix(1557042972, 0).Format("1")
  7186. year := time.Now().Format("2006")
  7187. month = time.Now().Format("01")
  7188. day := time.Now().Format("02")
  7189. hour := time.Now().Format("15")
  7190. min := time.Now().Format("04")
  7191. sec := time.Now().Format("05")
  7192. fix_fill_date := year + month + day + hour + min + sec
  7193. data["fix_fill_dept"] = miConfig.OrgName
  7194. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7195. data["fix_fill_psn"] = curRoles.UserName
  7196. data["fix_fill_date"] = fix_fill_date
  7197. data["stmt_loc"] = "2"
  7198. data["upld_btch"] = upld_btch
  7199. client := &http.Client{}
  7200. bytesData, _ := json.Marshal(data)
  7201. var req *http.Request
  7202. if miConfig.MdtrtareaAdmvs == "320921" {
  7203. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7204. } else {
  7205. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7206. }
  7207. resp, _ := client.Do(req)
  7208. defer resp.Body.Close()
  7209. body, ioErr := ioutil.ReadAll(resp.Body)
  7210. if ioErr != nil {
  7211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. }
  7214. var respJSON map[string]interface{}
  7215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. }
  7219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7220. fmt.Println(respJSON)
  7221. result, _ := json.Marshal(respJSON)
  7222. fmt.Println(result)
  7223. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7224. utils.ErrorLog("解析失败:%v", err)
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. }
  7227. if result3265.Infcode != "0" {
  7228. c.ServeSuccessJSON(map[string]interface{}{
  7229. "failed_code": -10,
  7230. "msg": result3265.ErrMsg,
  7231. })
  7232. return
  7233. } else {
  7234. c.ServeSuccessJSON(map[string]interface{}{
  7235. "info": result3265.Output,
  7236. })
  7237. return
  7238. }
  7239. }
  7240. func (c *HisApiController) Get3273() {
  7241. admin_user_id, _ := c.GetInt64("admin_user_id")
  7242. startTime := c.GetString("start_time")
  7243. //endTime, _ := c.GetString("end_time")
  7244. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7245. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7246. times := strings.Split(startTime, "-")
  7247. setl_mon := times[0] + times[1]
  7248. var result3265 models.JSResult3264
  7249. data := make(map[string]interface{})
  7250. data["org_name"] = miConfig.OrgName
  7251. data["doctor"] = curRoles.UserName
  7252. data["doctor_name"] = curRoles.UserName
  7253. data["fixmedins_code"] = miConfig.Code
  7254. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7255. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7256. data["secret_key"] = miConfig.SecretKey
  7257. data["url"] = miConfig.Url
  7258. data["ak"] = miConfig.AccessKey
  7259. data["cainfo"] = miConfig.Cainfo
  7260. data["setl_mon"] = setl_mon
  7261. data["stmt_loc"] = "2"
  7262. client := &http.Client{}
  7263. bytesData, _ := json.Marshal(data)
  7264. var req *http.Request
  7265. if miConfig.MdtrtareaAdmvs == "320921" {
  7266. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7267. } else {
  7268. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7269. }
  7270. resp, _ := client.Do(req)
  7271. defer resp.Body.Close()
  7272. body, ioErr := ioutil.ReadAll(resp.Body)
  7273. if ioErr != nil {
  7274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7276. }
  7277. var respJSON map[string]interface{}
  7278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. }
  7282. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7283. fmt.Println(respJSON)
  7284. result, _ := json.Marshal(respJSON)
  7285. fmt.Println(result)
  7286. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7287. utils.ErrorLog("解析失败:%v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. }
  7290. if result3265.Infcode != "0" {
  7291. c.ServeSuccessJSON(map[string]interface{}{
  7292. "failed_code": -10,
  7293. "msg": result3265.ErrMsg,
  7294. })
  7295. return
  7296. } else {
  7297. c.ServeSuccessJSON(map[string]interface{}{
  7298. "info": result3265.Output.Data,
  7299. })
  7300. return
  7301. }
  7302. }
  7303. func (c *HisApiController) Get3274() {
  7304. //if miConfig.MdtrtareaAdmvs == "320921" {
  7305. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7306. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7307. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7308. //
  7309. //} else {
  7310. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7311. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7312. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7313. //
  7314. //}
  7315. }
  7316. func (c *HisApiController) Get3275() {
  7317. //if miConfig.MdtrtareaAdmvs == "320921" {
  7318. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7319. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7320. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7321. //
  7322. //} else {
  7323. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7324. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7325. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7326. //
  7327. //}
  7328. }
  7329. func (c *HisApiController) Get3276() {
  7330. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7331. //month := c.GetString("month")
  7332. //
  7333. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7334. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7335. //var api string
  7336. //var res Result5301
  7337. //
  7338. //if miConfig.MdtrtareaAdmvs == "320921" {
  7339. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7340. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7341. //} else {
  7342. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7343. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7344. //}
  7345. //
  7346. //resp, requestErr := http.Get(api)
  7347. //if requestErr != nil {
  7348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. // return
  7350. //}
  7351. //
  7352. //body, ioErr := ioutil.ReadAll(resp.Body)
  7353. //if ioErr != nil {
  7354. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. // return
  7357. //}
  7358. //var respJSON map[string]interface{}
  7359. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7360. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. // return
  7363. //}
  7364. //
  7365. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7366. //result, _ := json.Marshal(respJSON)
  7367. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7368. // utils.ErrorLog("解析失败:%v", err)
  7369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. // return
  7371. //}
  7372. }
  7373. func (c *HisApiController) Get3277() {
  7374. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7375. //month := c.GetString("month")
  7376. //
  7377. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7378. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7379. //var api string
  7380. //var res Result5301
  7381. //
  7382. //if miConfig.MdtrtareaAdmvs == "320921" {
  7383. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7384. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7385. //} else {
  7386. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7387. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7388. //}
  7389. //
  7390. //resp, requestErr := http.Get(api)
  7391. //if requestErr != nil {
  7392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. // return
  7394. //}
  7395. //
  7396. //body, ioErr := ioutil.ReadAll(resp.Body)
  7397. //if ioErr != nil {
  7398. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7400. // return
  7401. //}
  7402. //var respJSON map[string]interface{}
  7403. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7404. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. // return
  7407. //}
  7408. //
  7409. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7410. //result, _ := json.Marshal(respJSON)
  7411. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7412. // utils.ErrorLog("解析失败:%v", err)
  7413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7414. // return
  7415. //}
  7416. }
  7417. //func (c *HisApiController) GetCFYLJG001() {
  7418. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7419. // patient_id, _ := c.GetInt64("patient_id")
  7420. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7421. // record_time := c.GetString("record_time")
  7422. // admin_user_id = 3626
  7423. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7424. // psn, _ := service.GetPsnByPatientId(patient_id)
  7425. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7426. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7427. // var cFYLJG001 models.CFYLJG001
  7428. //
  7429. // timeLayout := "2006-01-02"
  7430. // loc, _ := time.LoadLocation("Local")
  7431. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7432. // if err != nil {
  7433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7434. // return
  7435. // }
  7436. // recordDateTime := theTime.Unix()
  7437. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7438. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7439. //
  7440. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7441. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7442. //
  7443. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7444. //
  7445. // for _, item := range prescriptions {
  7446. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7447. // if his.IdCardType == 1 {
  7448. // bas := strings.Split(psn.CardInfo, "|")
  7449. // basNumber := bas[1]
  7450. // fmt.Println(basNumber)
  7451. // card_sn := bas[3]
  7452. // card_no := bas[2]
  7453. // cFYLJG001.MdtrtCertType = "03"
  7454. // cFYLJG001.CardSn = card_sn
  7455. // cFYLJG001.MdtrtCertNo = card_no
  7456. // cFYLJG001.EcToken = ""
  7457. // cFYLJG001.AuthNo = ""
  7458. // } else if his.IdCardType == 2 {
  7459. // cFYLJG001.MdtrtCertType = "02"
  7460. // cFYLJG001.CardSn = ""
  7461. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7462. // cFYLJG001.EcToken = ""
  7463. // cFYLJG001.AuthNo = ""
  7464. // } else if his.IdCardType == 4 {
  7465. // cFYLJG001.MdtrtCertType = "01"
  7466. // cFYLJG001.CardSn = ""
  7467. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7468. // cFYLJG001.EcToken = psn.VerifyNumber
  7469. // cFYLJG001.AuthNo = ""
  7470. // }
  7471. // cFYLJG001.BizTypeCode = "01"
  7472. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7473. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7474. // cFYLJG001.RxTypeCode = "1"
  7475. // tempTime := time.Unix(item.PreTime, 0)
  7476. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7477. // cFYLJG001.PrscTime = timeFormatOne
  7478. // var count float64
  7479. // if item.Type == 1 {
  7480. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7481. // count = count + sumItem.PrescribingNumber
  7482. // }
  7483. // }
  7484. // cFYLJG001.RxDrugCnt = count
  7485. // cFYLJG001.ValiDays = "5"
  7486. // ts := time.Unix(item.PreTime, 0)
  7487. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7488. // tempTime3 := time.Unix(record_time2, 0)
  7489. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7490. // cFYLJG001.ValiEndTime = timeFormat3
  7491. // cFYLJG001.RxCotnFlag = "0"
  7492. // for _, subItem := range item.HisDoctorAdviceInfo {
  7493. // var drug models.RxDrug
  7494. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7495. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7496. // drug.RxItemTypeCode = "11"
  7497. //
  7498. // drug.DrugDosform = "乳膏剂" //TODO
  7499. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7500. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7501. // }
  7502. //
  7503. // drug.MedcWayDscr = subItem.DeliveryWay
  7504. //
  7505. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7506. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7507. // drug.MedcBegntime = timeFormatTwo
  7508. // if subItem.Day > 0 {
  7509. // ts := time.Unix(subItem.StartTime, 0)
  7510. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7511. // tempTime4 := time.Unix(record_time, 0)
  7512. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7513. // drug.MedcEndtime = timeFormat5
  7514. // } else {
  7515. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7516. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7517. // drug.MedcEndtime = timeFormatTwo
  7518. // }
  7519. //
  7520. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7521. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7522. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7523. // drug.DrugCnt = subItem.PrescribingNumber
  7524. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7525. // drug.DrugGenname = subItem.AdviceName
  7526. // drug.MedcWayCodg = subItem.DeliveryWay
  7527. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7528. // drug.SinDoscnt = subItem.SingleDose
  7529. // drug.SinDosunt = subItem.SingleDoseUnit
  7530. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7531. // drug.UsedFrquName = subItem.ExecutionFrequency
  7532. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7533. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7534. // drug.HospApprFlag = "1"
  7535. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7536. // }
  7537. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7538. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7539. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7540. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7541. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7542. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7543. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7544. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7545. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7546. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7547. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7548. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7549. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7550. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7551. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7552. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7553. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7554. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7555. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7556. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7557. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7558. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7559. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7560. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7561. // tempTime2 := time.Now().Unix()
  7562. // tempTime6 := time.Unix(tempTime2, 0)
  7563. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7564. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7565. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7566. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7567. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7568. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7569. //
  7570. // //memo := make(map[string]interface{})
  7571. // //inputData := make(map[string]interface{}, 0)
  7572. //
  7573. // //type MyData struct {
  7574. // // Insutype string `json:"insutype"`
  7575. // //}
  7576. // //
  7577. // // data := MyData{
  7578. // // Insutype: his.Insutype,
  7579. // //}
  7580. // //
  7581. //
  7582. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7583. // var config []*models.HisXtDiagnoseConfig
  7584. // for _, item := range diagnosis_ids {
  7585. // id, _ := strconv.ParseInt(item, 10, 64)
  7586. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7587. // config = append(config, &diagnosisConfig)
  7588. // }
  7589. // for index, subitem := range config {
  7590. // if index == 0 {
  7591. // var dia models.DiseInfo
  7592. // dia.DiagType = "1"
  7593. // dia.MaindiagFlag = "1"
  7594. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7595. // dia.DiagCode = subitem.CountryCode
  7596. // dia.DiagName = subitem.ClassName
  7597. // dia.DiagDept = "肾内科"
  7598. // dia.DiagDrNo = doctor.DoctorNumber
  7599. // dia.DiagDrName = doctor.UserName
  7600. // tempTime3 := time.Unix(item.PreTime, 0)
  7601. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7602. // dia.DiagTime = timeFormatTwo
  7603. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7604. // } else {
  7605. // var dia models.DiseInfo
  7606. // dia.DiagType = "1"
  7607. // dia.MaindiagFlag = "0"
  7608. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7609. // dia.DiagCode = subitem.CountryCode
  7610. // dia.DiagName = subitem.ClassName
  7611. // dia.DiagDept = "肾内科"
  7612. // dia.DiagDrNo = doctor.DoctorNumber
  7613. // dia.DiagDrName = doctor.UserName
  7614. // tempTime3 := time.Unix(item.PreTime, 0)
  7615. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7616. // dia.DiagTime = timeFormatTwo
  7617. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7618. // }
  7619. // }
  7620. // if miConfig.MdtrtareaAdmvs == "340699" {
  7621. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7622. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7623. //
  7624. // } else {
  7625. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7626. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7627. //
  7628. // }
  7629. //
  7630. // var res ResultCFYLJG001
  7631. // var respJSON2 map[string]interface{}
  7632. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7633. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7635. // return
  7636. // }
  7637. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7638. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7639. // utils.ErrorLog("解析失败:%v", err)
  7640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. // return
  7642. // }
  7643. // if res.Infcode == -1 {
  7644. // c.ServeSuccessJSON(map[string]interface{}{
  7645. // "failed_code": -10,
  7646. // "msg": res.ErrMsg,
  7647. // })
  7648. // return
  7649. //
  7650. // } else {
  7651. // var flow models.HisPrescriptionFlow
  7652. // flow.Ctime = time.Now().Unix()
  7653. // flow.SignDigest = ""
  7654. // flow.RxTraceCode = res.Output.RxTraceCode
  7655. // flow.HiRxno = res.Output.HiRxno
  7656. // flow.MID = his.Number
  7657. // flow.Status = 1
  7658. // flow.DCode = doctor_info.DoctorNumber
  7659. // flow.OriginalRxFile = ""
  7660. // flow.OriginalValue = ""
  7661. // flow.SignCertDn = ""
  7662. // flow.UserOrgId = 10454
  7663. // flow.SignCertSn = ""
  7664. // flow.Mtime = time.Now().Unix()
  7665. //
  7666. // service.Createflow(&flow)
  7667. // c.ServeSuccessJSON(map[string]interface{}{
  7668. // "msg": "上传成功",
  7669. // })
  7670. // }
  7671. // }
  7672. //}
  7673. //func (c *HisApiController) GetCFYLJG002() {
  7674. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7675. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7676. // record_time := c.GetString("record_time")
  7677. // admin_user_id = 3626
  7678. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7679. // //id, _ := c.GetInt64("id")
  7680. // admin_user_id = 3626
  7681. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7682. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7683. //
  7684. // flow, _ := service.Getflowtwo(his.Number)
  7685. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7686. // //record_time := c.GetString("record_time")
  7687. // patient_id, _ := c.GetInt64("patient_id")
  7688. // //patient_id = 23834
  7689. // //record_time = "2023-09-18"
  7690. // timeLayout := "2006-01-02"
  7691. // loc, _ := time.LoadLocation("Local")
  7692. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7693. // if err != nil {
  7694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7695. // return
  7696. // }
  7697. // recordDateTime := theTime.Unix()
  7698. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7699. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7700. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7701. //
  7702. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7703. //
  7704. // inputData := make(map[string]interface{})
  7705. // inputData["rxTraceCode"] = flow.RxTraceCode
  7706. // inputData["hiRxno"] = flow.HiRxno
  7707. // inputData["mdtrtId"] = flow.MID
  7708. // inputData["patnName"] = his.PsnName
  7709. // inputData["psnCertType"] = his.PsnCertType
  7710. // inputData["certno"] = his.Certno
  7711. // inputData["fixmedinsName"] = miConfig.OrgName
  7712. // inputData["fixmedinsCode"] = miConfig.Code
  7713. // inputData["drCode"] = doctor_info.DoctorNumber
  7714. // inputData["prscDrName"] = doctor_info.UserName
  7715. // inputData["pharDeptName"] = dept.Name
  7716. // inputData["pharDeptCode"] = dept.Number
  7717. // inputData["pharProfttlCodg"] = dept.Name
  7718. // inputData["pharProfttlName"] = ""
  7719. // inputData["pharCode"] = "HY440309002107"
  7720. // inputData["pharCertType"] = "01"
  7721. // inputData["pharCertno"] = "430482199408260023"
  7722. // inputData["pharName"] = "彭斯遥"
  7723. // inputData["pharPracCertNo"] = ""
  7724. // tempTime2 := time.Unix(info.Ctime, 0)
  7725. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7726. // inputData["pharChkTime"] = timeFormatTwo
  7727. //
  7728. // bytesData, _ := json.Marshal(inputData)
  7729. // fmt.Println(string(bytesData))
  7730. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7731. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7732. // if err != nil {
  7733. // fmt.Println("Error reading PDF file:", err)
  7734. // return
  7735. // }
  7736. //
  7737. // // 将 PDF 文件内容进行 Base64 编码
  7738. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7739. //
  7740. // fmt.Println(err)
  7741. //
  7742. // if miConfig.MdtrtareaAdmvs == "340699" {
  7743. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7744. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7745. //
  7746. // } else {
  7747. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7748. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7749. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7750. //
  7751. // }
  7752. //
  7753. // var res2 Result002
  7754. // var respJSON2 map[string]interface{}
  7755. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. // return
  7759. // }
  7760. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7761. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7762. // utils.ErrorLog("解析失败:%v", err)
  7763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. // return
  7765. // }
  7766. // if res2.Infcode == 0 {
  7767. // flow.Ctime = time.Now().Unix()
  7768. // flow.SignDigest = res2.Output.SignDigest
  7769. // flow.RxFile = res2.Output.RxFile
  7770. // flow.MID = his.Number
  7771. // flow.Status = 1
  7772. // flow.DCode = doctor_info.DoctorNumber
  7773. // flow.OriginalRxFile = rx_encoded
  7774. // flow.OriginalValue = encoded
  7775. // flow.SignCertDn = res2.Output.SignCertDn
  7776. // flow.SignCertSn = res2.Output.SignCertSn
  7777. // flow.Mtime = time.Now().Unix()
  7778. // service.Saveflow(flow)
  7779. // c.ServeSuccessJSON(map[string]interface{}{
  7780. // "msg": "预签名成功",
  7781. // })
  7782. // } else {
  7783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7784. // return
  7785. // }
  7786. //}
  7787. //func (c *HisApiController) GetCFYLJG003() {
  7788. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7789. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7790. // record_time := c.GetString("record_time")
  7791. // admin_user_id = 3626
  7792. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7793. // //id, _ := c.GetInt64("id")
  7794. // admin_user_id = 3626
  7795. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7796. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7797. //
  7798. // flow, _ := service.Getflowtwo(his.Number)
  7799. // //id = 3
  7800. // patient_id, _ := c.GetInt64("patient_id")
  7801. // //patient_id = 23834
  7802. // //record_time = "2023-09-18"
  7803. // timeLayout := "2006-01-02"
  7804. // loc, _ := time.LoadLocation("Local")
  7805. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7806. // if err != nil {
  7807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7808. // return
  7809. // }
  7810. // recordDateTime := theTime.Unix()
  7811. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7812. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7813. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7814. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7815. //
  7816. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7817. //
  7818. // var cFYLJG003 models.CFYLJG003
  7819. //
  7820. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7821. // cFYLJG003.HiRxno = flow.HiRxno
  7822. // cFYLJG003.MdtrtID = flow.MID
  7823. // cFYLJG003.PatnName = his.Name
  7824. // cFYLJG003.Certno = his.Certno
  7825. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7826. // cFYLJG003.FixmedinsCode = miConfig.Code
  7827. //
  7828. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7829. // cFYLJG003.PrscDrName = doctor_info.UserName
  7830. // cFYLJG003.PharDeptName = dept.Name
  7831. // cFYLJG003.PharDeptCode = dept.Number
  7832. // cFYLJG003.PharCode = "HY440309002107"
  7833. // cFYLJG003.PharCertType = "01"
  7834. // cFYLJG003.PharCertno = "430482199408260023"
  7835. // cFYLJG003.PharName = "彭斯遥"
  7836. // cFYLJG003.PsnCertType = "01"
  7837. // cFYLJG003.RxFile = flow.RxFile
  7838. // cFYLJG003.SignDigest = flow.SignDigest
  7839. // cFYLJG003.FixmedinsCode = miConfig.Code
  7840. // cFYLJG003.PsnCertType = "01"
  7841. // cFYLJG003.PharProfttlCodg = dept.Name
  7842. // //inputData["pharProfttlCodg"] =dept.Name
  7843. //
  7844. // tempTime2 := time.Unix(info.Ctime, 0)
  7845. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7846. // cFYLJG003.PharChkTime = timeFormatTwo
  7847. //
  7848. // if miConfig.MdtrtareaAdmvs == "340699" {
  7849. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7850. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7851. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7852. // } else {
  7853. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7854. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7855. //
  7856. // }
  7857. //
  7858. // var res ResultCFYLJG003
  7859. // var respJSON2 map[string]interface{}
  7860. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7861. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7863. // return
  7864. // }
  7865. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7866. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7867. // utils.ErrorLog("解析失败:%v", err)
  7868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7869. // return
  7870. // }
  7871. // if res.Infcode == -1 {
  7872. // c.ServeSuccessJSON(map[string]interface{}{
  7873. // "failed_code": -10,
  7874. // "msg": res.ErrMsg,
  7875. // })
  7876. // return
  7877. // } else {
  7878. // c.ServeSuccessJSON(map[string]interface{}{
  7879. // "info": res.Output,
  7880. // })
  7881. // }
  7882. //
  7883. //}
  7884. //func (c *HisApiController) GetCFYLJG004() {
  7885. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7886. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7887. // record_time := c.GetString("record_time")
  7888. // admin_user_id = 3626
  7889. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7890. // //id, _ := c.GetInt64("id")
  7891. // admin_user_id = 3626
  7892. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7893. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7894. //
  7895. // flow, _ := service.Getflowtwo(his.Number)
  7896. // //id = 3
  7897. // patient_id, _ := c.GetInt64("patient_id")
  7898. // //patient_id = 23834
  7899. // //record_time = "2023-09-18"
  7900. // timeLayout := "2006-01-02"
  7901. // loc, _ := time.LoadLocation("Local")
  7902. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7903. // if err != nil {
  7904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7905. // return
  7906. // }
  7907. // recordDateTime := theTime.Unix()
  7908. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7909. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7910. // var cFYLJG004 models.CFYLJG004
  7911. // cFYLJG004.HiRxno = flow.HiRxno
  7912. // cFYLJG004.FixmedinsCode = miConfig.Code
  7913. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7914. // cFYLJG004.UndoDrCertType = "01"
  7915. // cFYLJG004.UndoRea = "撤销处方"
  7916. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7917. // cFYLJG004.UndoDrName = doctor_info.UserName
  7918. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7919. //
  7920. // if miConfig.MdtrtareaAdmvs == "340699" {
  7921. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7922. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7923. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7924. //
  7925. // } else {
  7926. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7927. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7928. //
  7929. // }
  7930. //
  7931. // var res ResultCFYLJG004
  7932. // var respJSON2 map[string]interface{}
  7933. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. // return
  7937. // }
  7938. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7939. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7940. // utils.ErrorLog("解析失败:%v", err)
  7941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. // return
  7943. // }
  7944. // if res.Infcode == -1 {
  7945. // c.ServeSuccessJSON(map[string]interface{}{
  7946. // "failed_code": -10,
  7947. // "msg": res.ErrMsg,
  7948. // })
  7949. // return
  7950. // } else {
  7951. // flow.Status = 0
  7952. // service.Saveflow(flow)
  7953. // c.ServeSuccessJSON(map[string]interface{}{
  7954. // "msg": "撤销成功",
  7955. // })
  7956. // return
  7957. //
  7958. // }
  7959. //}
  7960. //func (c *HisApiController) GetCFYLJG005() {
  7961. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7962. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7963. // //record_time := c.GetString("record_time")
  7964. // admin_user_id = 3626
  7965. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7966. // //id, _ := c.GetInt64("id")
  7967. // admin_user_id = 3626
  7968. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7969. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7970. //
  7971. // flow, _ := service.Getflowtwo(his.Number)
  7972. // //id = 3
  7973. // var cFYLJG005 models.CFYLJG005
  7974. //
  7975. // //patient_id, _ := c.GetInt64("patient_id")
  7976. // cFYLJG005.HiRxno = flow.HiRxno
  7977. // cFYLJG005.MdtrtID = flow.MID
  7978. // cFYLJG005.EcToken = ""
  7979. // cFYLJG005.PsnName = his.Name
  7980. // cFYLJG005.PsnCertType = "01"
  7981. // cFYLJG005.Certno = his.IdCardNo
  7982. //
  7983. // if miConfig.MdtrtareaAdmvs == "340699" {
  7984. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7985. //
  7986. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7987. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7988. //
  7989. // } else {
  7990. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7991. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7992. //
  7993. // }
  7994. //
  7995. // var res ResultCFYLJG005
  7996. // var respJSON2 map[string]interface{}
  7997. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7998. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. // return
  8001. // }
  8002. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8003. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8004. // utils.ErrorLog("解析失败:%v", err)
  8005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. // return
  8007. // }
  8008. // if res.Infcode == -1 {
  8009. // c.ServeSuccessJSON(map[string]interface{}{
  8010. // "failed_code": -10,
  8011. // "msg": res.ErrMsg,
  8012. // })
  8013. // return
  8014. // } else {
  8015. // c.ServeSuccessJSON(map[string]interface{}{
  8016. // "info": res.Output,
  8017. // })
  8018. // return
  8019. // }
  8020. //}
  8021. //func (c *HisApiController) GetCFYLJG006() {
  8022. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8023. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8024. // admin_user_id = 3626
  8025. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8026. // //id, _ := c.GetInt64("id")
  8027. // admin_user_id = 3626
  8028. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8029. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8030. //
  8031. // flow, _ := service.Getflowtwo(his.Number)
  8032. // //id = 3
  8033. // patient_id, _ := c.GetInt64("patient_id")
  8034. // var cFYLJG006 models.CFYLJG006
  8035. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8036. // cFYLJG006.HiRxno = flow.HiRxno
  8037. // cFYLJG006.MdtrtID = flow.MID
  8038. // cFYLJG006.PsnName = patient.Name
  8039. // cFYLJG006.PsnCertType = "01"
  8040. // cFYLJG006.Certno = patient.IdCardNo
  8041. //
  8042. // if miConfig.MdtrtareaAdmvs == "340699" {
  8043. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8044. //
  8045. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8046. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8047. // } else {
  8048. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8049. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8050. // }
  8051. //
  8052. // var res ResultCFYLJG006
  8053. // var respJSON2 map[string]interface{}
  8054. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8055. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. // return
  8058. // }
  8059. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8060. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8061. // utils.ErrorLog("解析失败:%v", err)
  8062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8063. // return
  8064. // }
  8065. // if res.Infcode == -1 {
  8066. // c.ServeSuccessJSON(map[string]interface{}{
  8067. // "failed_code": -10,
  8068. // "msg": res.ErrMsg,
  8069. // })
  8070. // return
  8071. // } else {
  8072. // c.ServeSuccessJSON(map[string]interface{}{
  8073. // "info": res.Output,
  8074. // })
  8075. // return
  8076. // }
  8077. //}
  8078. //func (c *HisApiController) GetCFYLJG007() {
  8079. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8080. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8081. // admin_user_id = 3626
  8082. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8083. // //id, _ := c.GetInt64("id")
  8084. // admin_user_id = 3626
  8085. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8086. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8087. //
  8088. // flow, _ := service.Getflowtwo(his.Number)
  8089. // //id = 3
  8090. // patient_id, _ := c.GetInt64("patient_id")
  8091. // var cFYLJG007 models.CFYLJG007
  8092. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8093. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8094. //
  8095. // cFYLJG007.HiRxno = flow.HiRxno
  8096. // cFYLJG007.MdtrtID = flow.MID
  8097. // cFYLJG007.PsnNo = his.PsnNo
  8098. // cFYLJG007.PsnCertType = "01"
  8099. // cFYLJG007.Certno = patient.IdCardNo
  8100. // cFYLJG007.PsnName = patient.Name
  8101. //
  8102. // if miConfig.MdtrtareaAdmvs == "340699" {
  8103. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8104. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8105. // } else {
  8106. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8107. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8108. // }
  8109. //
  8110. // var res ResultCFYLJG007
  8111. // var respJSON2 map[string]interface{}
  8112. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8113. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8115. // return
  8116. // }
  8117. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8118. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8119. // utils.ErrorLog("解析失败:%v", err)
  8120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. // return
  8122. // }
  8123. // if res.Infcode == -1 {
  8124. // c.ServeSuccessJSON(map[string]interface{}{
  8125. // "failed_code": -10,
  8126. // "msg": res.ErrMsg,
  8127. // })
  8128. // return
  8129. // } else {
  8130. // c.ServeSuccessJSON(map[string]interface{}{
  8131. // "info": res,
  8132. // })
  8133. // return
  8134. // }
  8135. //}
  8136. //
  8137. //func (c *HisApiController) GetCFYLJG008() {
  8138. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8139. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8140. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8141. // var cFYLJG008 models.CFYLJG008
  8142. // //id, _ := c.GetInt64("id")
  8143. // patient_id, _ := c.GetInt64("patient_id")
  8144. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8145. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8146. // //id = 3
  8147. // //flow, _ := service.Getflow(id)
  8148. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8149. //
  8150. // //
  8151. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8152. // //patient_id, _ := c.GetInt64("patient_id")
  8153. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8154. // record_time := c.GetString("record_time")
  8155. //
  8156. // admin_user_id = 3626
  8157. // patient_id = 19424
  8158. // //his_patient_id = 263947
  8159. // record_time = "2023-08-29"
  8160. //
  8161. // timeLayout := "2006-01-02"
  8162. // loc, _ := time.LoadLocation("Local")
  8163. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8164. // if err != nil {
  8165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8166. // return
  8167. // }
  8168. // recordDateTime := theTime.Unix()
  8169. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8170. //
  8171. // cFYLJG008.FixmedinsName = ""
  8172. // cFYLJG008.Lat = ""
  8173. // cFYLJG008.Lng = ""
  8174. // cFYLJG008.OrderType = "1"
  8175. // cFYLJG008.PoolareaNo = ""
  8176. // cFYLJG008.Lng = ""
  8177. // cFYLJG008.PageNum = 1
  8178. // cFYLJG008.PageSize = 10
  8179. // var MPI models.MedinsProdInvChgDDTO
  8180. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8181. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8182. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8183. //
  8184. // if miConfig.MdtrtareaAdmvs == "340699" {
  8185. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8186. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8187. //
  8188. // } else {
  8189. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8190. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8191. //
  8192. // var res ResultCFYLJG008
  8193. // var respJSON2 map[string]interface{}
  8194. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8195. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. // return
  8198. // }
  8199. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8200. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8201. // utils.ErrorLog("解析失败:%v", err)
  8202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. // return
  8204. // }
  8205. // if res.Infcode == -1 {
  8206. // c.ServeSuccessJSON(map[string]interface{}{
  8207. // "failed_code": -10,
  8208. // "msg": res.ErrMsg,
  8209. // })
  8210. // return
  8211. // } else {
  8212. // c.ServeSuccessJSON(map[string]interface{}{
  8213. // "info": res.Output,
  8214. // })
  8215. // return
  8216. // }
  8217. // }
  8218. //
  8219. //}
  8220. func (c *HisApiController) GetBL4201A() {
  8221. order_id, _ := c.GetInt64("order_id")
  8222. admin_user_id, _ := c.GetInt64("admin_user_id")
  8223. order, _ := service.GetHisOrderByIDTwo(order_id)
  8224. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8225. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8226. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8227. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8228. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8229. department, _ := service.GetDepartMentDetail(his.Departments)
  8230. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8231. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8232. if order.ID == 0 {
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8234. return
  8235. }
  8236. var struct4201A models.Struct4201A
  8237. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8238. for _, items := range order_info {
  8239. memo := make(map[string]interface{})
  8240. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8241. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8242. fsiOPFLD.MedType = "14"
  8243. fsiOPFLD.BkkpSn = items.FeedetlSn
  8244. fsiOPFLD.FixmedinsCode = miConfig.Code
  8245. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8246. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8247. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8248. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8249. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8250. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8251. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8252. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8253. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8254. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8255. fsiOPFLD.BilgDeptName = department.Name
  8256. fsiOPFLD.BilgDeptCodg = department.Number
  8257. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8258. fsiOPFLD.BilgDrName = doctor.UserName
  8259. fsiOPFLD.MedChrgitmType = "09"
  8260. memo["hosp_appr_flag"] = "1"
  8261. memo["invoice_no"] = order.MdtrtId
  8262. memo["memo"] = "自费"
  8263. bytesData, _ := json.Marshal(memo)
  8264. fsiOPFLD.Memo = string(bytesData)
  8265. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8266. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8267. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8268. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8269. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8270. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8271. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8272. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8273. fsiOPFLD.BilgDeptName = department.Name
  8274. fsiOPFLD.BilgDeptCodg = department.Number
  8275. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8276. fsiOPFLD.BilgDrName = doctor.UserName
  8277. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8278. case 0:
  8279. break
  8280. case 1:
  8281. fsiOPFLD.MedChrgitmType = "14"
  8282. break
  8283. case 2:
  8284. fsiOPFLD.MedChrgitmType = "05"
  8285. break
  8286. case 3:
  8287. fsiOPFLD.MedChrgitmType = "03"
  8288. break
  8289. case 4:
  8290. fsiOPFLD.MedChrgitmType = "03"
  8291. break
  8292. case 5:
  8293. fsiOPFLD.MedChrgitmType = "08"
  8294. break
  8295. case 6:
  8296. fsiOPFLD.MedChrgitmType = "14"
  8297. break
  8298. case 7:
  8299. fsiOPFLD.MedChrgitmType = "14"
  8300. break
  8301. case 8:
  8302. fsiOPFLD.MedChrgitmType = "03"
  8303. break
  8304. case 9:
  8305. fsiOPFLD.MedChrgitmType = "14"
  8306. break
  8307. case 10:
  8308. fsiOPFLD.MedChrgitmType = "14"
  8309. break
  8310. case 11:
  8311. fsiOPFLD.MedChrgitmType = "06"
  8312. break
  8313. case 12:
  8314. fsiOPFLD.MedChrgitmType = "12"
  8315. break
  8316. case 13:
  8317. fsiOPFLD.MedChrgitmType = "01"
  8318. break
  8319. case 14:
  8320. fsiOPFLD.MedChrgitmType = "04"
  8321. break
  8322. case 15:
  8323. fsiOPFLD.MedChrgitmType = "14"
  8324. break
  8325. }
  8326. memo["hosp_appr_flag"] = "1"
  8327. memo["invoice_no"] = order.MdtrtId
  8328. memo["memo"] = "自费"
  8329. bytesData, _ := json.Marshal(memo)
  8330. fsiOPFLD.Memo = string(bytesData)
  8331. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8332. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8333. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8334. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8335. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8336. fsiOPFLD.BilgDeptName = department.Name
  8337. fsiOPFLD.BilgDeptCodg = department.Number
  8338. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8339. fsiOPFLD.BilgDrName = doctor.UserName
  8340. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8341. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8342. fsiOPFLD.MedChrgitmType = "08"
  8343. memo["hosp_appr_flag"] = "1"
  8344. memo["invoice_no"] = order.MdtrtId
  8345. memo["memo"] = "自费"
  8346. bytesData, _ := json.Marshal(memo)
  8347. fsiOPFLD.Memo = string(bytesData)
  8348. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8349. }
  8350. }
  8351. }
  8352. for _, items := range order_info_two {
  8353. memo := make(map[string]interface{})
  8354. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8355. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8356. fsiOPFLD.MedType = "14"
  8357. fsiOPFLD.BkkpSn = items.FeedetlSn
  8358. fsiOPFLD.FixmedinsCode = miConfig.Code
  8359. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8360. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8361. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8362. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8363. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8364. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8365. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8366. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8367. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8368. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8369. fsiOPFLD.BilgDeptName = department.Name
  8370. fsiOPFLD.BilgDeptCodg = department.Number
  8371. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8372. fsiOPFLD.BilgDrName = doctor.UserName
  8373. fsiOPFLD.MedChrgitmType = "09"
  8374. memo["hosp_appr_flag"] = "1"
  8375. memo["invoice_no"] = order.MdtrtId
  8376. memo["memo"] = "自费"
  8377. bytesData, _ := json.Marshal(memo)
  8378. fsiOPFLD.Memo = string(bytesData)
  8379. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8380. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8381. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8382. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8383. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8384. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8385. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8386. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8387. fsiOPFLD.BilgDeptName = department.Name
  8388. fsiOPFLD.BilgDeptCodg = department.Number
  8389. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8390. fsiOPFLD.BilgDrName = doctor.UserName
  8391. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8392. case 0:
  8393. break
  8394. case 1:
  8395. fsiOPFLD.MedChrgitmType = "14"
  8396. break
  8397. case 2:
  8398. fsiOPFLD.MedChrgitmType = "05"
  8399. break
  8400. case 3:
  8401. fsiOPFLD.MedChrgitmType = "03"
  8402. break
  8403. case 4:
  8404. fsiOPFLD.MedChrgitmType = "03"
  8405. break
  8406. case 5:
  8407. fsiOPFLD.MedChrgitmType = "08"
  8408. break
  8409. case 6:
  8410. fsiOPFLD.MedChrgitmType = "14"
  8411. break
  8412. case 7:
  8413. fsiOPFLD.MedChrgitmType = "14"
  8414. break
  8415. case 8:
  8416. fsiOPFLD.MedChrgitmType = "03"
  8417. break
  8418. case 9:
  8419. fsiOPFLD.MedChrgitmType = "14"
  8420. break
  8421. case 10:
  8422. fsiOPFLD.MedChrgitmType = "14"
  8423. break
  8424. case 11:
  8425. fsiOPFLD.MedChrgitmType = "06"
  8426. break
  8427. case 12:
  8428. fsiOPFLD.MedChrgitmType = "12"
  8429. break
  8430. case 13:
  8431. fsiOPFLD.MedChrgitmType = "01"
  8432. break
  8433. case 14:
  8434. fsiOPFLD.MedChrgitmType = "04"
  8435. break
  8436. case 15:
  8437. fsiOPFLD.MedChrgitmType = "14"
  8438. break
  8439. }
  8440. memo["hosp_appr_flag"] = "1"
  8441. memo["invoice_no"] = order.MdtrtId
  8442. memo["memo"] = "自费"
  8443. bytesData, _ := json.Marshal(memo)
  8444. fsiOPFLD.Memo = string(bytesData)
  8445. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8446. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8447. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8448. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8449. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8450. fsiOPFLD.BilgDeptName = department.Name
  8451. fsiOPFLD.BilgDeptCodg = department.Number
  8452. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8453. fsiOPFLD.BilgDrName = doctor.UserName
  8454. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8455. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8456. fsiOPFLD.MedChrgitmType = "08"
  8457. memo["hosp_appr_flag"] = "1"
  8458. memo["invoice_no"] = order.MdtrtId
  8459. memo["memo"] = "自费"
  8460. bytesData, _ := json.Marshal(memo)
  8461. fsiOPFLD.Memo = string(bytesData)
  8462. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8463. }
  8464. }
  8465. }
  8466. fmt.Println(fsiOPFLDs)
  8467. struct4201A.Fopfd = fsiOPFLDs
  8468. fmt.Println(struct4201A.Fopfd)
  8469. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8470. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8471. var res2 ResultSix
  8472. var respJSON2 map[string]interface{}
  8473. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. userJSONBytes2, _ := json.Marshal(respJSON2)
  8479. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8480. utils.ErrorLog("解析失败:%v", err)
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. if res2.Infcode != 0 {
  8485. c.ServeSuccessJSON(map[string]interface{}{
  8486. "failed_code": -10,
  8487. "msg": res2.ErrMsg,
  8488. })
  8489. return
  8490. } else {
  8491. order.IsUploadOrderInfo = 1
  8492. service.UpdateOrder(order)
  8493. c.ServeSuccessJSON(map[string]interface{}{
  8494. "msg": "上传成功",
  8495. })
  8496. }
  8497. }
  8498. func (c *HisApiController) Get2505() {
  8499. admin_user_id, _ := c.GetInt64("admin_user_id")
  8500. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8501. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8502. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  8503. }
  8504. func (c *HisApiController) Get4201A() {
  8505. order_id, _ := c.GetInt64("order_id")
  8506. admin_user_id, _ := c.GetInt64("admin_user_id")
  8507. order, _ := service.GetHisOrderByIDTwo(order_id)
  8508. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8509. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8510. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8511. //order_info = append(order_info, order_info_two...)
  8512. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8513. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8514. department, _ := service.GetDepartMentDetail(his.Departments)
  8515. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8516. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8517. if order.ID == 0 {
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8519. return
  8520. }
  8521. var struct4201A models.Struct4201A
  8522. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8523. for _, items := range order_info {
  8524. memo := make(map[string]interface{})
  8525. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8526. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8527. fsiOPFLD.MedType = "14"
  8528. fsiOPFLD.BkkpSn = items.FeedetlSn
  8529. fsiOPFLD.FixmedinsCode = miConfig.Code
  8530. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8531. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8532. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8533. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8534. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8535. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8536. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8537. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8538. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8539. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8540. fsiOPFLD.BilgDeptName = department.Name
  8541. fsiOPFLD.BilgDeptCodg = department.Number
  8542. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8543. fsiOPFLD.BilgDrName = doctor.UserName
  8544. fsiOPFLD.MedChrgitmType = "09"
  8545. memo["hosp_appr_flag"] = "1"
  8546. memo["invoice_no"] = order.MdtrtId
  8547. memo["memo"] = "自费"
  8548. bytesData, _ := json.Marshal(memo)
  8549. fsiOPFLD.Memo = string(bytesData)
  8550. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8551. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8552. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8553. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8554. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8555. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8556. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8557. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8558. fsiOPFLD.BilgDeptName = department.Name
  8559. fsiOPFLD.BilgDeptCodg = department.Number
  8560. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8561. fsiOPFLD.BilgDrName = doctor.UserName
  8562. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8563. case 0:
  8564. break
  8565. case 1:
  8566. fsiOPFLD.MedChrgitmType = "14"
  8567. break
  8568. case 2:
  8569. fsiOPFLD.MedChrgitmType = "05"
  8570. break
  8571. case 3:
  8572. fsiOPFLD.MedChrgitmType = "03"
  8573. break
  8574. case 4:
  8575. fsiOPFLD.MedChrgitmType = "03"
  8576. break
  8577. case 5:
  8578. fsiOPFLD.MedChrgitmType = "08"
  8579. break
  8580. case 6:
  8581. fsiOPFLD.MedChrgitmType = "14"
  8582. break
  8583. case 7:
  8584. fsiOPFLD.MedChrgitmType = "14"
  8585. break
  8586. case 8:
  8587. fsiOPFLD.MedChrgitmType = "03"
  8588. break
  8589. case 9:
  8590. fsiOPFLD.MedChrgitmType = "14"
  8591. break
  8592. case 10:
  8593. fsiOPFLD.MedChrgitmType = "14"
  8594. break
  8595. case 11:
  8596. fsiOPFLD.MedChrgitmType = "06"
  8597. break
  8598. case 12:
  8599. fsiOPFLD.MedChrgitmType = "12"
  8600. break
  8601. case 13:
  8602. fsiOPFLD.MedChrgitmType = "01"
  8603. break
  8604. case 14:
  8605. fsiOPFLD.MedChrgitmType = "04"
  8606. break
  8607. case 15:
  8608. fsiOPFLD.MedChrgitmType = "14"
  8609. break
  8610. }
  8611. memo["hosp_appr_flag"] = "1"
  8612. memo["invoice_no"] = order.MdtrtId
  8613. memo["memo"] = "自费"
  8614. bytesData, _ := json.Marshal(memo)
  8615. fsiOPFLD.Memo = string(bytesData)
  8616. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8617. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8618. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8619. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8620. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8621. fsiOPFLD.BilgDeptName = department.Name
  8622. fsiOPFLD.BilgDeptCodg = department.Number
  8623. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8624. fsiOPFLD.BilgDrName = doctor.UserName
  8625. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8626. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8627. fsiOPFLD.MedChrgitmType = "08"
  8628. memo["hosp_appr_flag"] = "1"
  8629. memo["invoice_no"] = order.MdtrtId
  8630. memo["memo"] = "自费"
  8631. bytesData, _ := json.Marshal(memo)
  8632. fsiOPFLD.Memo = string(bytesData)
  8633. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8634. }
  8635. }
  8636. }
  8637. for _, items := range order_info_two {
  8638. memo := make(map[string]interface{})
  8639. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8640. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8641. fsiOPFLD.MedType = "14"
  8642. fsiOPFLD.BkkpSn = items.FeedetlSn
  8643. fsiOPFLD.FixmedinsCode = miConfig.Code
  8644. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8645. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8646. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8647. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8648. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8649. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8650. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8651. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8652. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8653. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8654. fsiOPFLD.BilgDeptName = department.Name
  8655. fsiOPFLD.BilgDeptCodg = department.Number
  8656. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8657. fsiOPFLD.BilgDrName = doctor.UserName
  8658. fsiOPFLD.MedChrgitmType = "09"
  8659. memo["hosp_appr_flag"] = "1"
  8660. memo["invoice_no"] = order.MdtrtId
  8661. memo["memo"] = "自费"
  8662. bytesData, _ := json.Marshal(memo)
  8663. fsiOPFLD.Memo = string(bytesData)
  8664. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8665. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8666. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8667. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8668. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8669. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8670. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8671. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8672. fsiOPFLD.BilgDeptName = department.Name
  8673. fsiOPFLD.BilgDeptCodg = department.Number
  8674. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8675. fsiOPFLD.BilgDrName = doctor.UserName
  8676. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8677. case 0:
  8678. break
  8679. case 1:
  8680. fsiOPFLD.MedChrgitmType = "14"
  8681. break
  8682. case 2:
  8683. fsiOPFLD.MedChrgitmType = "05"
  8684. break
  8685. case 3:
  8686. fsiOPFLD.MedChrgitmType = "03"
  8687. break
  8688. case 4:
  8689. fsiOPFLD.MedChrgitmType = "03"
  8690. break
  8691. case 5:
  8692. fsiOPFLD.MedChrgitmType = "08"
  8693. break
  8694. case 6:
  8695. fsiOPFLD.MedChrgitmType = "14"
  8696. break
  8697. case 7:
  8698. fsiOPFLD.MedChrgitmType = "14"
  8699. break
  8700. case 8:
  8701. fsiOPFLD.MedChrgitmType = "03"
  8702. break
  8703. case 9:
  8704. fsiOPFLD.MedChrgitmType = "14"
  8705. break
  8706. case 10:
  8707. fsiOPFLD.MedChrgitmType = "14"
  8708. break
  8709. case 11:
  8710. fsiOPFLD.MedChrgitmType = "06"
  8711. break
  8712. case 12:
  8713. fsiOPFLD.MedChrgitmType = "12"
  8714. break
  8715. case 13:
  8716. fsiOPFLD.MedChrgitmType = "01"
  8717. break
  8718. case 14:
  8719. fsiOPFLD.MedChrgitmType = "04"
  8720. break
  8721. case 15:
  8722. fsiOPFLD.MedChrgitmType = "14"
  8723. break
  8724. }
  8725. memo["hosp_appr_flag"] = "1"
  8726. memo["invoice_no"] = order.MdtrtId
  8727. memo["memo"] = "自费"
  8728. bytesData, _ := json.Marshal(memo)
  8729. fsiOPFLD.Memo = string(bytesData)
  8730. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8731. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8732. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8733. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8734. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8735. fsiOPFLD.BilgDeptName = department.Name
  8736. fsiOPFLD.BilgDeptCodg = department.Number
  8737. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8738. fsiOPFLD.BilgDrName = doctor.UserName
  8739. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8740. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8741. fsiOPFLD.MedChrgitmType = "08"
  8742. memo["hosp_appr_flag"] = "1"
  8743. memo["invoice_no"] = order.MdtrtId
  8744. memo["memo"] = "自费"
  8745. bytesData, _ := json.Marshal(memo)
  8746. fsiOPFLD.Memo = string(bytesData)
  8747. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8748. }
  8749. }
  8750. }
  8751. fmt.Println(fsiOPFLDs)
  8752. struct4201A.Fopfd = fsiOPFLDs
  8753. fmt.Println(struct4201A.Fopfd)
  8754. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8755. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8756. var res2 ResultSix
  8757. var respJSON2 map[string]interface{}
  8758. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8761. return
  8762. }
  8763. userJSONBytes2, _ := json.Marshal(respJSON2)
  8764. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8765. utils.ErrorLog("解析失败:%v", err)
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. if res2.Infcode != 0 {
  8770. c.ServeSuccessJSON(map[string]interface{}{
  8771. "failed_code": -10,
  8772. "msg": res2.ErrMsg,
  8773. })
  8774. return
  8775. } else {
  8776. order.IsUploadOrderInfo = 1
  8777. service.UpdateOrder(order)
  8778. c.ServeSuccessJSON(map[string]interface{}{
  8779. "msg": "上传成功",
  8780. })
  8781. }
  8782. }
  8783. func (c *HisApiController) Get4202() {
  8784. order_id, _ := c.GetInt64("order_id")
  8785. admin_user_id, _ := c.GetInt64("admin_user_id")
  8786. order, _ := service.GetHisOrderByIDTwo(order_id)
  8787. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8788. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8789. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8790. if order.ID == 0 {
  8791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8792. return
  8793. }
  8794. var struct4202 models.Struct4202
  8795. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8796. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8797. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8798. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8799. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8800. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8801. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8802. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8803. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8804. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8805. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8806. var config []*models.HisXtDiagnoseConfig
  8807. for _, item := range diagnosis_ids {
  8808. id, _ := strconv.ParseInt(item, 10, 64)
  8809. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8810. config = append(config, &diagnosisConfig)
  8811. }
  8812. var tempDiaginfos []models.OwnPayPatnDiagListD
  8813. for index, item := range config {
  8814. if index == 0 {
  8815. var tempDiaginfo models.OwnPayPatnDiagListD
  8816. tempDiaginfo.InoutDiagType = "1"
  8817. tempDiaginfo.DiagCode = item.CountryCode
  8818. tempDiaginfo.DiagName = item.CountryContentName
  8819. tempDiaginfo.DiagType = "1"
  8820. tempDiaginfo.DiagSrtNo = "1"
  8821. tempDiaginfo.MaindiagFlag = "1"
  8822. tempDiaginfo.ValiFlag = "1"
  8823. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8824. } else {
  8825. var tempDiaginfo models.OwnPayPatnDiagListD
  8826. tempDiaginfo.DiagCode = item.CountryCode
  8827. tempDiaginfo.DiagName = item.CountryContentName
  8828. tempDiaginfo.DiagType = "2"
  8829. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8830. tempDiaginfo.MaindiagFlag = "0"
  8831. tempDiaginfo.ValiFlag = "1"
  8832. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8833. }
  8834. }
  8835. struct4202.ODiagListD = tempDiaginfos
  8836. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8837. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8838. var res2 ResultSix
  8839. var respJSON2 map[string]interface{}
  8840. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. userJSONBytes2, _ := json.Marshal(respJSON2)
  8846. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8847. utils.ErrorLog("解析失败:%v", err)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. if res2.Infcode != 0 {
  8852. c.ServeSuccessJSON(map[string]interface{}{
  8853. "failed_code": -10,
  8854. "msg": res2.ErrMsg,
  8855. })
  8856. return
  8857. } else {
  8858. order.IsUploadDiagnose = 1
  8859. service.UpdateOrder(order)
  8860. c.ServeSuccessJSON(map[string]interface{}{
  8861. "msg": "上传成功",
  8862. })
  8863. }
  8864. }
  8865. func (c *HisApiController) Get4203() {
  8866. admin_user_id, _ := c.GetInt64("admin_user_id")
  8867. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8869. order_id, _ := c.GetInt64("order_id")
  8870. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8871. number := ""
  8872. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8873. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8874. if his.ID == 0 {
  8875. number = hospital.Number
  8876. } else {
  8877. number = his.Number
  8878. }
  8879. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8880. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8881. var res2 ResultSix
  8882. var respJSON2 map[string]interface{}
  8883. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. userJSONBytes2, _ := json.Marshal(respJSON2)
  8889. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8890. utils.ErrorLog("解析失败:%v", err)
  8891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8892. return
  8893. }
  8894. if res2.Infcode != 0 {
  8895. c.ServeSuccessJSON(map[string]interface{}{
  8896. "failed_code": -10,
  8897. "msg": res2.ErrMsg,
  8898. })
  8899. return
  8900. } else {
  8901. order.IsUploadSuccess = 1
  8902. service.UpdateOrderTwo(order)
  8903. c.ServeSuccessJSON(map[string]interface{}{
  8904. "msg": "上传成功",
  8905. })
  8906. }
  8907. }
  8908. func (c *HisApiController) Get4205() {
  8909. order_id, _ := c.GetInt64("order_id")
  8910. admin_user_id, _ := c.GetInt64("admin_user_id")
  8911. fapiao_code := c.GetString("fapiao_code")
  8912. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8913. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8914. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8915. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8916. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8917. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8918. //order_info = append(order_info, order_info_two...)
  8919. department, _ := service.GetDepartMentDetail(his.Departments)
  8920. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8921. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8922. if order.ID == 0 {
  8923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8924. return
  8925. }
  8926. var struct4201A models.Struct4201A
  8927. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8928. for _, items := range order_info {
  8929. memo := make(map[string]interface{})
  8930. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8931. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8932. fsiOPFLD.MedType = pre.MedType
  8933. fsiOPFLD.FixmedinsCode = miConfig.Code
  8934. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8935. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8936. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8937. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8938. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8939. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8940. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8941. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8942. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8943. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8944. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8945. fsiOPFLD.BilgDeptName = department.Name
  8946. fsiOPFLD.BilgDeptCodg = department.Number
  8947. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8948. fsiOPFLD.BilgDrName = doctor.UserName
  8949. fsiOPFLD.MedChrgitmType = "09"
  8950. memo["hosp_appr_flag"] = "1"
  8951. memo["invoice_no"] = fapiao_code
  8952. memo["memo"] = "自费"
  8953. bytesData, _ := json.Marshal(memo)
  8954. fsiOPFLD.Memo = string(bytesData)
  8955. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8956. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8957. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8958. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8959. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8960. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8961. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8962. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8963. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8964. fsiOPFLD.BilgDeptName = department.Name
  8965. fsiOPFLD.BilgDeptCodg = department.Number
  8966. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8967. fsiOPFLD.BilgDrName = doctor.UserName
  8968. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8969. case 0:
  8970. break
  8971. case 1:
  8972. fsiOPFLD.MedChrgitmType = "14"
  8973. break
  8974. case 2:
  8975. fsiOPFLD.MedChrgitmType = "05"
  8976. break
  8977. case 3:
  8978. fsiOPFLD.MedChrgitmType = "03"
  8979. break
  8980. case 4:
  8981. fsiOPFLD.MedChrgitmType = "03"
  8982. break
  8983. case 5:
  8984. fsiOPFLD.MedChrgitmType = "08"
  8985. break
  8986. case 6:
  8987. fsiOPFLD.MedChrgitmType = "14"
  8988. break
  8989. case 7:
  8990. fsiOPFLD.MedChrgitmType = "14"
  8991. break
  8992. case 8:
  8993. fsiOPFLD.MedChrgitmType = "03"
  8994. break
  8995. case 9:
  8996. fsiOPFLD.MedChrgitmType = "14"
  8997. break
  8998. case 10:
  8999. fsiOPFLD.MedChrgitmType = "14"
  9000. break
  9001. case 11:
  9002. fsiOPFLD.MedChrgitmType = "06"
  9003. break
  9004. case 12:
  9005. fsiOPFLD.MedChrgitmType = "12"
  9006. break
  9007. case 13:
  9008. fsiOPFLD.MedChrgitmType = "01"
  9009. break
  9010. case 14:
  9011. fsiOPFLD.MedChrgitmType = "04"
  9012. break
  9013. case 15:
  9014. fsiOPFLD.MedChrgitmType = "14"
  9015. break
  9016. }
  9017. memo["hosp_appr_flag"] = "1"
  9018. memo["invoice_no"] = fapiao_code
  9019. memo["memo"] = "自费"
  9020. bytesData, _ := json.Marshal(memo)
  9021. fsiOPFLD.Memo = string(bytesData)
  9022. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9023. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9024. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9025. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9026. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9027. fsiOPFLD.BilgDeptName = department.Name
  9028. fsiOPFLD.BilgDeptCodg = department.Number
  9029. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9030. fsiOPFLD.BilgDrName = doctor.UserName
  9031. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9032. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9033. fsiOPFLD.MedChrgitmType = "08"
  9034. memo["hosp_appr_flag"] = "1"
  9035. memo["invoice_no"] = fapiao_code
  9036. memo["memo"] = "自费"
  9037. bytesData, _ := json.Marshal(memo)
  9038. fsiOPFLD.Memo = string(bytesData)
  9039. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9040. }
  9041. }
  9042. }
  9043. for _, items := range order_info_two {
  9044. memo := make(map[string]interface{})
  9045. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9046. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9047. fsiOPFLD.MedType = pre.MedType
  9048. fsiOPFLD.BkkpSn = items.FeedetlSn
  9049. fsiOPFLD.FixmedinsCode = miConfig.Code
  9050. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9051. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9052. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9053. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9054. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9055. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9056. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9057. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9058. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9059. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9060. fsiOPFLD.BilgDeptName = department.Name
  9061. fsiOPFLD.BilgDeptCodg = department.Number
  9062. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9063. fsiOPFLD.BilgDrName = doctor.UserName
  9064. fsiOPFLD.MedChrgitmType = "09"
  9065. memo["hosp_appr_flag"] = "1"
  9066. memo["invoice_no"] = fapiao_code
  9067. memo["memo"] = "自费"
  9068. bytesData, _ := json.Marshal(memo)
  9069. fsiOPFLD.Memo = string(bytesData)
  9070. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9071. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9072. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9073. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9074. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9075. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9076. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9077. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9078. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9079. fsiOPFLD.BilgDeptName = department.Name
  9080. fsiOPFLD.BilgDeptCodg = department.Number
  9081. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9082. fsiOPFLD.BilgDrName = doctor.UserName
  9083. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9084. case 0:
  9085. break
  9086. case 1:
  9087. fsiOPFLD.MedChrgitmType = "14"
  9088. break
  9089. case 2:
  9090. fsiOPFLD.MedChrgitmType = "05"
  9091. break
  9092. case 3:
  9093. fsiOPFLD.MedChrgitmType = "03"
  9094. break
  9095. case 4:
  9096. fsiOPFLD.MedChrgitmType = "03"
  9097. break
  9098. case 5:
  9099. fsiOPFLD.MedChrgitmType = "08"
  9100. break
  9101. case 6:
  9102. fsiOPFLD.MedChrgitmType = "14"
  9103. break
  9104. case 7:
  9105. fsiOPFLD.MedChrgitmType = "14"
  9106. break
  9107. case 8:
  9108. fsiOPFLD.MedChrgitmType = "03"
  9109. break
  9110. case 9:
  9111. fsiOPFLD.MedChrgitmType = "14"
  9112. break
  9113. case 10:
  9114. fsiOPFLD.MedChrgitmType = "14"
  9115. break
  9116. case 11:
  9117. fsiOPFLD.MedChrgitmType = "06"
  9118. break
  9119. case 12:
  9120. fsiOPFLD.MedChrgitmType = "12"
  9121. break
  9122. case 13:
  9123. fsiOPFLD.MedChrgitmType = "01"
  9124. break
  9125. case 14:
  9126. fsiOPFLD.MedChrgitmType = "04"
  9127. break
  9128. case 15:
  9129. fsiOPFLD.MedChrgitmType = "14"
  9130. break
  9131. }
  9132. memo["hosp_appr_flag"] = "1"
  9133. memo["invoice_no"] = fapiao_code
  9134. memo["memo"] = "自费"
  9135. bytesData, _ := json.Marshal(memo)
  9136. fsiOPFLD.Memo = string(bytesData)
  9137. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9138. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9139. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9140. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9141. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9142. fsiOPFLD.BilgDeptName = department.Name
  9143. fsiOPFLD.BilgDeptCodg = department.Number
  9144. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9145. fsiOPFLD.BilgDrName = doctor.UserName
  9146. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9147. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9148. fsiOPFLD.MedChrgitmType = "08"
  9149. memo["hosp_appr_flag"] = "1"
  9150. memo["invoice_no"] = fapiao_code
  9151. memo["memo"] = "自费"
  9152. bytesData, _ := json.Marshal(memo)
  9153. fsiOPFLD.Memo = string(bytesData)
  9154. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9155. }
  9156. }
  9157. }
  9158. fmt.Println(fsiOPFLDs)
  9159. struct4201A.Fopfd = fsiOPFLDs
  9160. fmt.Println(struct4201A.Fopfd)
  9161. var struct4202 models.Struct4202
  9162. timeLayout := "2006-01-02 15:04:05"
  9163. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9164. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9165. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9166. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9167. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9168. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9169. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9170. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9171. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9172. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9173. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9174. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9175. var config []*models.HisXtDiagnoseConfig
  9176. for _, item := range diagnosis_ids {
  9177. id, _ := strconv.ParseInt(item, 10, 64)
  9178. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9179. config = append(config, &diagnosisConfig)
  9180. }
  9181. var tempDiaginfos []models.OwnPayPatnDiagListD
  9182. for index, item := range config {
  9183. if index == 0 {
  9184. var tempDiaginfo models.OwnPayPatnDiagListD
  9185. tempDiaginfo.InoutDiagType = "1"
  9186. tempDiaginfo.DiagCode = item.CountryCode
  9187. tempDiaginfo.DiagName = item.CountryContentName
  9188. tempDiaginfo.DiagType = "1"
  9189. tempDiaginfo.DiagSrtNo = "1"
  9190. tempDiaginfo.MaindiagFlag = "1"
  9191. tempDiaginfo.ValiFlag = "1"
  9192. tempDiaginfo.DiagDrName = doctor.UserName
  9193. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9194. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9195. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9196. } else {
  9197. var tempDiaginfo models.OwnPayPatnDiagListD
  9198. tempDiaginfo.DiagCode = item.CountryCode
  9199. tempDiaginfo.DiagName = item.CountryContentName
  9200. tempDiaginfo.DiagType = "2"
  9201. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9202. tempDiaginfo.MaindiagFlag = "0"
  9203. tempDiaginfo.ValiFlag = "1"
  9204. tempDiaginfo.DiagDrName = doctor.UserName
  9205. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9206. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9207. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9208. }
  9209. }
  9210. struct4202.ODiagListD = tempDiaginfos
  9211. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9212. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9213. var res2 ResultSix
  9214. var respJSON2 map[string]interface{}
  9215. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9218. return
  9219. }
  9220. userJSONBytes2, _ := json.Marshal(respJSON2)
  9221. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9222. utils.ErrorLog("解析失败:%v", err)
  9223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9224. return
  9225. }
  9226. if res2.Infcode != 0 {
  9227. c.ServeSuccessJSON(map[string]interface{}{
  9228. "failed_code": -10,
  9229. "msg": res2.ErrMsg,
  9230. })
  9231. return
  9232. } else {
  9233. order.IsUploadDiagnose = 1
  9234. order.IsUploadOrderInfo = 1
  9235. service.UpdateOrderTwo(order)
  9236. c.ServeSuccessJSON(map[string]interface{}{
  9237. "msg": "上传成功",
  9238. })
  9239. }
  9240. }
  9241. func (c *HisApiController) Get4207() {
  9242. admin_user_id, _ := c.GetInt64("admin_user_id")
  9243. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9245. order_id, _ := c.GetInt64("order_id")
  9246. order, _ := service.GetHisOrderByIDTwo(order_id)
  9247. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9248. var struct4207 models.Struct4207
  9249. struct4207.PageNum = "1"
  9250. struct4207.PageSize = "1000"
  9251. struct4207.FixmedinsCode = miConfig.Code
  9252. struct4207.FixmedinsMdtrtID = order.Number
  9253. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9254. saveLog(result, requestLog, "4207", "查询")
  9255. var res2 ResultSix
  9256. var respJSON2 map[string]interface{}
  9257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9260. return
  9261. }
  9262. userJSONBytes2, _ := json.Marshal(respJSON2)
  9263. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9264. utils.ErrorLog("解析失败:%v", err)
  9265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9266. return
  9267. }
  9268. if res2.Infcode != 0 {
  9269. c.ServeSuccessJSON(map[string]interface{}{
  9270. "failed_code": -10,
  9271. "msg": res2.ErrMsg,
  9272. })
  9273. return
  9274. } else {
  9275. c.ServeSuccessJSON(map[string]interface{}{
  9276. "msg": "查询成功",
  9277. })
  9278. }
  9279. }
  9280. func (c *HisApiController) Get4208() {
  9281. admin_user_id, _ := c.GetInt64("admin_user_id")
  9282. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9284. order_id, _ := c.GetInt64("order_id")
  9285. order, _ := service.GetHisOrderByIDTwo(order_id)
  9286. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9287. var struct4208 models.Struct4208
  9288. struct4208.PageNum = "1"
  9289. struct4208.PageSize = "1000"
  9290. struct4208.PsnCertType = "01"
  9291. struct4208.Certno = his.Certno
  9292. struct4208.MedType = order.MedType
  9293. struct4208.PsnName = his.Name
  9294. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9295. saveLog(result, requestLog, "4208", "查询")
  9296. var res2 ResultSix
  9297. var respJSON2 map[string]interface{}
  9298. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9301. return
  9302. }
  9303. userJSONBytes2, _ := json.Marshal(respJSON2)
  9304. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9305. utils.ErrorLog("解析失败:%v", err)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. if res2.Infcode != 0 {
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "failed_code": -10,
  9312. "msg": res2.ErrMsg,
  9313. })
  9314. return
  9315. } else {
  9316. c.ServeSuccessJSON(map[string]interface{}{
  9317. "msg": "查询成功",
  9318. })
  9319. }
  9320. }
  9321. func (c *HisApiController) Get4209() {
  9322. admin_user_id, _ := c.GetInt64("admin_user_id")
  9323. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9324. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9325. order_id, _ := c.GetInt64("order_id")
  9326. order, _ := service.GetHisOrderByIDTwo(order_id)
  9327. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9328. var struct4209 models.Struct4209
  9329. struct4209.FixmedinsMdtrtID = order.Number
  9330. struct4209.FixmedinsCode = miConfig.Code
  9331. struct4209.PageSize = "1000"
  9332. struct4209.PageNum = "1"
  9333. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9334. saveLog(result, requestLog, "4209", "查询")
  9335. var res2 ResultSix
  9336. var respJSON2 map[string]interface{}
  9337. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. userJSONBytes2, _ := json.Marshal(respJSON2)
  9343. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. if res2.Infcode != 0 {
  9349. c.ServeSuccessJSON(map[string]interface{}{
  9350. "failed_code": -10,
  9351. "msg": res2.ErrMsg,
  9352. })
  9353. return
  9354. } else {
  9355. c.ServeSuccessJSON(map[string]interface{}{
  9356. "msg": "查询成功",
  9357. })
  9358. }
  9359. }
  9360. type Result3101 struct {
  9361. Infcode string `json:"infcode"`
  9362. InfRefmsgid string `json:"inf_refmsgid"`
  9363. RefmsgTime string `json:"refmsg_time"`
  9364. RespondTime string `json:"respond_time"`
  9365. Enctype string `json:"enctype"`
  9366. Signtype string `json:"signtype"`
  9367. ErrMsg string `json:"err_msg"`
  9368. Output struct {
  9369. Result []struct {
  9370. JudgeResultDetailDtos []struct {
  9371. VolaItemType string `json:"vola_item_type"`
  9372. MdtrtID string `json:"mdtrt_id"`
  9373. JrdID string `json:"jrd_id"`
  9374. PatnID string `json:"patn_id"`
  9375. RxID string `json:"rx_id"`
  9376. VolaAmt interface{} `json:"vola_amt"`
  9377. } `json:"judge_result_detail_dtos"`
  9378. RuleID string `json:"rule_id"`
  9379. VolaEvid string `json:"vola_evid"`
  9380. MdtrtID string `json:"mdtrt_id"`
  9381. RuleName string `json:"rule_name"`
  9382. VolaAmtStas string `json:"vola_amt_stas"`
  9383. JrID string `json:"jr_id"`
  9384. PatnID string `json:"patn_id"`
  9385. SevDeg string `json:"sev_deg"`
  9386. VolaAmt float64 `json:"vola_amt"`
  9387. VolaBhvrType string `json:"vola_bhvr_type"`
  9388. VolaCont string `json:"vola_cont"`
  9389. } `json:"result"`
  9390. } `json:"output"`
  9391. }
  9392. type Resultgd3101 struct {
  9393. Infcode int64 `json:"infcode"`
  9394. InfRefmsgid string `json:"inf_refmsgid"`
  9395. RefmsgTime string `json:"refmsg_time"`
  9396. RespondTime string `json:"respond_time"`
  9397. Enctype string `json:"enctype"`
  9398. Signtype string `json:"signtype"`
  9399. ErrMsg string `json:"err_msg"`
  9400. Output struct {
  9401. Result []struct {
  9402. JudgeResultDetailDtos []struct {
  9403. VolaItemType string `json:"vola_item_type"`
  9404. MdtrtID string `json:"mdtrt_id"`
  9405. JrdID string `json:"jrd_id"`
  9406. PatnID string `json:"patn_id"`
  9407. RxID string `json:"rx_id"`
  9408. VolaAmt interface{} `json:"vola_amt"`
  9409. } `json:"judge_result_detail_dtos"`
  9410. RuleID string `json:"rule_id"`
  9411. VolaEvid string `json:"vola_evid"`
  9412. MdtrtID string `json:"mdtrt_id"`
  9413. RuleName string `json:"rule_name"`
  9414. VolaAmtStas string `json:"vola_amt_stas"`
  9415. JrID string `json:"jr_id"`
  9416. PatnID string `json:"patn_id"`
  9417. SevDeg string `json:"sev_deg"`
  9418. VolaAmt float64 `json:"vola_amt"`
  9419. VolaBhvrType string `json:"vola_bhvr_type"`
  9420. VolaCont string `json:"vola_cont"`
  9421. } `json:"result"`
  9422. } `json:"output"`
  9423. }
  9424. func (c *HisApiController) ReadEleToken() {
  9425. admin_user_id, _ := c.GetInt64("admin_user_id")
  9426. his_patient_id, _ := c.GetInt64("his_patient_id")
  9427. adminUser := c.GetAdminUserInfo()
  9428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9429. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9430. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9431. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9432. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9433. if len(tokens) > 0 {
  9434. c.ServeSuccessJSON(map[string]interface{}{
  9435. "msg": "读取成功",
  9436. })
  9437. } else {
  9438. c.ServeSuccessJSON(map[string]interface{}{
  9439. "failed_code": -10,
  9440. "msg": "读取失败",
  9441. })
  9442. }
  9443. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9444. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9445. if len(tokens) > 0 {
  9446. c.ServeSuccessJSON(map[string]interface{}{
  9447. "msg": "读取成功",
  9448. })
  9449. } else {
  9450. c.ServeSuccessJSON(map[string]interface{}{
  9451. "failed_code": -10,
  9452. "msg": "读取失败",
  9453. })
  9454. }
  9455. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9456. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9457. if len(tokens) > 0 {
  9458. c.ServeSuccessJSON(map[string]interface{}{
  9459. "msg": "读取成功",
  9460. })
  9461. } else {
  9462. c.ServeSuccessJSON(map[string]interface{}{
  9463. "failed_code": -10,
  9464. "msg": "读取失败",
  9465. })
  9466. }
  9467. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9468. var api string
  9469. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9470. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName + "&is_settle=1"
  9471. resp, requestErr := http.Get(api)
  9472. if requestErr != nil {
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. }
  9475. body, ioErr := ioutil.ReadAll(resp.Body)
  9476. if ioErr != nil {
  9477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. }
  9480. var respJSON map[string]interface{}
  9481. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. var status string
  9487. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9488. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9489. var token string
  9490. var res ResultTwo //1101结果
  9491. var res10265 ResultTwo10265 //1101结果
  9492. if status == "0" { //读卡成功
  9493. var card_info string //卡信息
  9494. var busi_card_info string
  9495. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9496. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9497. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9498. fmt.Println(card_info)
  9499. fmt.Println(busi_card_info)
  9500. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9501. result, _ := json.Marshal(respJSON)
  9502. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9503. utils.ErrorLog("解析失败:%v", err)
  9504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9505. return
  9506. }
  9507. res.ErrMsg = res10265.ErrMsg
  9508. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9509. res.Infcode = infocode
  9510. res.Output = res10265.Output
  9511. res.InfRefmsgid = res10265.InfRefmsgid
  9512. if res.Infcode == 0 {
  9513. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9514. if err == gorm.ErrRecordNotFound {
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9516. return
  9517. } else if err != nil {
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9519. return
  9520. } else {
  9521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9523. infoStr := string(Iinfos)
  9524. idetinfoStr := string(Idetinfos)
  9525. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9526. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9527. psn := &models.HisPsn{
  9528. PsnNo: res.Output.Baseinfo.PsnNo,
  9529. PatientId: patient.ID,
  9530. Certno: res.Output.Baseinfo.Certno,
  9531. Gend: res.Output.Baseinfo.Gend,
  9532. Naty: res.Output.Baseinfo.Naty,
  9533. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9534. PsnName: res.Output.Baseinfo.PsnName,
  9535. Age: float64(age),
  9536. Brdy: b,
  9537. Idetinfo: idetinfoStr,
  9538. Insuinfo: infoStr,
  9539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9540. CardInfo: card_info,
  9541. VerifyNumber: token,
  9542. IdCardType: 4,
  9543. }
  9544. var rf []*ResultFive
  9545. json.Unmarshal([]byte(infoStr), &rf)
  9546. var insutypes []*ResultFive
  9547. var insutype string
  9548. var is390 int = 0
  9549. var is310 int = 0
  9550. for _, item := range rf {
  9551. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9552. insutypes = append(insutypes, item)
  9553. }
  9554. }
  9555. if len(insutypes) == 1 {
  9556. insutype = insutypes[0].Insutype
  9557. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9558. } else {
  9559. for _, i := range insutypes {
  9560. if i.Insutype == "390" {
  9561. is390 = 1
  9562. }
  9563. if i.Insutype == "310" {
  9564. is310 = 1
  9565. }
  9566. }
  9567. }
  9568. if is390 == 1 {
  9569. insutype = "390"
  9570. }
  9571. if is310 == 1 {
  9572. insutype = "310"
  9573. }
  9574. if len(insutypes) == 0 {
  9575. insutype = "310"
  9576. }
  9577. service.CreateHisPsn(psn)
  9578. c.ServeSuccessJSON(map[string]interface{}{
  9579. "patient": patient,
  9580. "number": token,
  9581. "insutype": insutype,
  9582. })
  9583. }
  9584. } else {
  9585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9586. return
  9587. }
  9588. } else { //读卡失败
  9589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9590. return
  9591. }
  9592. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9593. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9594. if len(errMsg) == 0 {
  9595. type ELeData struct {
  9596. Data struct {
  9597. IdNo string `json:"idNo"`
  9598. IdType string `json:"idType"`
  9599. UserName string `json:"userName"`
  9600. EcToken string `json:"ecToken"`
  9601. InsuOrg string `json:"insuOrg"`
  9602. Gender string `json:"gender"`
  9603. Birthday string `json:"birthday"`
  9604. Nationality string `json:"nationality"`
  9605. Email string `json:"email"`
  9606. Extra string `json:"extra"`
  9607. } `json:"data"`
  9608. Code int `json:"code"`
  9609. Message string `json:"message"`
  9610. }
  9611. var ele ELeData
  9612. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9613. if err != nil {
  9614. utils.ErrorLog("解析失败:%v", err)
  9615. }
  9616. token := ele.Data.EcToken
  9617. if len(token) > 0 {
  9618. psn := &models.HisPsn{
  9619. PsnNo: his.PsnNo,
  9620. Age: 0,
  9621. PatientId: his.PatientId,
  9622. Certno: his.Certno,
  9623. Brdy: his.Brdy,
  9624. Gend: his.Gend,
  9625. Naty: his.Naty,
  9626. PsnCertType: his.PsnCertType,
  9627. PsnName: his.PsnName,
  9628. Idetinfo: his.Idetinfo,
  9629. Insuinfo: his.Iinfo,
  9630. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9631. CardInfo: outPutInfo,
  9632. VerifyNumber: token,
  9633. }
  9634. service.CreateHisPsn(psn)
  9635. }
  9636. if len(token) > 0 {
  9637. c.ServeSuccessJSON(map[string]interface{}{
  9638. "msg": "读取成功",
  9639. })
  9640. } else {
  9641. c.ServeSuccessJSON(map[string]interface{}{
  9642. "failed_code": -10,
  9643. "msg": "读取失败",
  9644. })
  9645. }
  9646. }
  9647. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9648. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9649. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9650. type ELeData struct {
  9651. Data struct {
  9652. IdNo string `json:"idNo"`
  9653. IdType string `json:"idType"`
  9654. UserName string `json:"userName"`
  9655. EcToken string `json:"ecToken"`
  9656. InsuOrg string `json:"insuOrg"`
  9657. Gender string `json:"gender"`
  9658. Birthday string `json:"birthday"`
  9659. Nationality string `json:"nationality"`
  9660. Email string `json:"email"`
  9661. Extra string `json:"extra"`
  9662. } `json:"data"`
  9663. Code int `json:"code"`
  9664. Message string `json:"message"`
  9665. }
  9666. var ele ELeData
  9667. err := json.Unmarshal([]byte(result), &ele)
  9668. if err != nil {
  9669. utils.ErrorLog("解析失败:%v", err)
  9670. }
  9671. token := ele.Data.EcToken
  9672. token = Remove0000(token)
  9673. fmt.Println(ele.Data.UserName)
  9674. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9675. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9676. var res ResultTwo
  9677. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9678. utils.ErrorLog("解析失败:%v", err)
  9679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9680. return
  9681. }
  9682. if res.Infcode == 0 {
  9683. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9684. if err == gorm.ErrRecordNotFound {
  9685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9686. return
  9687. } else if err != nil {
  9688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9689. return
  9690. } else {
  9691. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9692. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9693. infoStr := string(Iinfos)
  9694. idetinfoStr := string(Idetinfos)
  9695. psn := &models.HisPsn{
  9696. PsnNo: res.Output.Baseinfo.PsnNo,
  9697. PatientId: patient.ID,
  9698. Certno: res.Output.Baseinfo.Certno,
  9699. Gend: res.Output.Baseinfo.Gend,
  9700. Naty: res.Output.Baseinfo.Naty,
  9701. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9702. PsnName: res.Output.Baseinfo.PsnName,
  9703. Idetinfo: idetinfoStr,
  9704. Insuinfo: infoStr,
  9705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9706. CardInfo: "",
  9707. VerifyNumber: token,
  9708. }
  9709. service.CreateHisPsn(psn)
  9710. c.ServeSuccessJSON(map[string]interface{}{
  9711. "patient": patient,
  9712. "number": token,
  9713. })
  9714. }
  9715. } else {
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9717. return
  9718. }
  9719. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9720. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9721. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9722. type ELeData struct {
  9723. Data struct {
  9724. IdNo string `json:"idNo"`
  9725. IdType string `json:"idType"`
  9726. UserName string `json:"userName"`
  9727. EcToken string `json:"ecToken"`
  9728. InsuOrg string `json:"insuOrg"`
  9729. Gender string `json:"gender"`
  9730. Birthday string `json:"birthday"`
  9731. Nationality string `json:"nationality"`
  9732. Email string `json:"email"`
  9733. Extra string `json:"extra"`
  9734. } `json:"data"`
  9735. Code int `json:"code"`
  9736. Message string `json:"message"`
  9737. }
  9738. var ele ELeData
  9739. err := json.Unmarshal([]byte(result), &ele)
  9740. if err != nil {
  9741. utils.ErrorLog("解析失败:%v", err)
  9742. }
  9743. token := ele.Data.EcToken
  9744. token = Remove0000(token)
  9745. fmt.Println(ele.Data.UserName)
  9746. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9747. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9748. var res ResultTwo
  9749. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9750. utils.ErrorLog("解析失败:%v", err)
  9751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9752. return
  9753. }
  9754. if res.Infcode == 0 {
  9755. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9756. if err == gorm.ErrRecordNotFound {
  9757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9758. return
  9759. } else if err != nil {
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9761. return
  9762. } else {
  9763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9765. infoStr := string(Iinfos)
  9766. idetinfoStr := string(Idetinfos)
  9767. psn := &models.HisPsn{
  9768. PsnNo: res.Output.Baseinfo.PsnNo,
  9769. PatientId: patient.ID,
  9770. Certno: res.Output.Baseinfo.Certno,
  9771. Gend: res.Output.Baseinfo.Gend,
  9772. Naty: res.Output.Baseinfo.Naty,
  9773. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9774. PsnName: res.Output.Baseinfo.PsnName,
  9775. Idetinfo: idetinfoStr,
  9776. Insuinfo: infoStr,
  9777. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9778. CardInfo: "",
  9779. VerifyNumber: token,
  9780. }
  9781. service.CreateHisPsn(psn)
  9782. c.ServeSuccessJSON(map[string]interface{}{
  9783. "patient": patient,
  9784. "number": token,
  9785. })
  9786. }
  9787. } else {
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9789. return
  9790. }
  9791. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9792. //if initFlag == 0 {
  9793. //c.TestGetJiangXiBasBaseInit()
  9794. //}
  9795. //if initEleFlag == 0 {
  9796. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9797. //}
  9798. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9799. utils.ErrorLog("解析失败:%v", json_result)
  9800. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9801. type ELeData struct {
  9802. Data struct {
  9803. IdNo string `json:"idNo"`
  9804. IdType string `json:"idType"`
  9805. UserName string `json:"userName"`
  9806. EcToken string `json:"ecToken"`
  9807. InsuOrg string `json:"insuOrg"`
  9808. Gender string `json:"gender"`
  9809. Birthday string `json:"birthday"`
  9810. Nationality string `json:"nationality"`
  9811. Email string `json:"email"`
  9812. Extra string `json:"extra"`
  9813. } `json:"data"`
  9814. Code int `json:"code"`
  9815. Message string `json:"message"`
  9816. }
  9817. var ele ELeData
  9818. err := json.Unmarshal([]byte(json_result), &ele)
  9819. if err != nil {
  9820. utils.ErrorLog("解析失败:%v", err)
  9821. }
  9822. token := ele.Data.EcToken
  9823. token = Remove0000(token)
  9824. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9825. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9826. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9827. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9828. var res ResultTwo
  9829. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9830. utils.ErrorLog("解析失败:%v", err)
  9831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9832. return
  9833. }
  9834. if res.Infcode == 0 {
  9835. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9836. if err == gorm.ErrRecordNotFound {
  9837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9838. return
  9839. } else if err != nil {
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9841. return
  9842. } else {
  9843. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9844. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9845. infoStr := string(Iinfos)
  9846. idetinfoStr := string(Idetinfos)
  9847. psn := &models.HisPsn{
  9848. PsnNo: res.Output.Baseinfo.PsnNo,
  9849. PatientId: patient.ID,
  9850. Certno: res.Output.Baseinfo.Certno,
  9851. Gend: res.Output.Baseinfo.Gend,
  9852. Naty: res.Output.Baseinfo.Naty,
  9853. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9854. PsnName: res.Output.Baseinfo.PsnName,
  9855. Idetinfo: idetinfoStr,
  9856. Insuinfo: infoStr,
  9857. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9858. CardInfo: "",
  9859. VerifyNumber: token,
  9860. InsuplcAdmdvs: ele.Data.InsuOrg,
  9861. }
  9862. service.CreateHisPsn(psn)
  9863. c.ServeSuccessJSON(map[string]interface{}{
  9864. "patient": patient,
  9865. "number": token,
  9866. })
  9867. }
  9868. } else {
  9869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9870. return
  9871. }
  9872. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9873. res := c.GetoleInfo()
  9874. if res.Infcode == 0 {
  9875. var result string
  9876. if res.Output.MdtrtCertType == "01" {
  9877. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  9878. } else if res.Output.MdtrtCertType == "02" {
  9879. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  9880. } else if res.Output.MdtrtCertType == "03" {
  9881. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  9882. }
  9883. var dat map[string]interface{}
  9884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9885. fmt.Println(dat)
  9886. } else {
  9887. fmt.Println(err)
  9888. }
  9889. userJSONBytes, _ := json.Marshal(dat)
  9890. var res2 ResultTwo
  9891. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9892. utils.ErrorLog("解析失败:%v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. if res2.Infcode == 0 {
  9897. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9898. if err == gorm.ErrRecordNotFound {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9900. return
  9901. } else if err != nil {
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9903. return
  9904. } else {
  9905. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9906. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9907. infoStr := string(Iinfos)
  9908. idetinfoStr := string(Idetinfos)
  9909. var rf []*ResultFive
  9910. json.Unmarshal([]byte(infoStr), &rf)
  9911. var insutypes []*ResultFive
  9912. var insutype string
  9913. var is390 int = 0
  9914. var is310 int = 0
  9915. //var insuplc_admdvs string
  9916. for _, item := range rf {
  9917. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9918. insutypes = append(insutypes, item)
  9919. }
  9920. }
  9921. if len(insutypes) == 1 {
  9922. insutype = insutypes[0].Insutype
  9923. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9924. } else {
  9925. for _, i := range insutypes {
  9926. if i.Insutype == "390" {
  9927. is390 = 1
  9928. }
  9929. if i.Insutype == "310" {
  9930. is310 = 1
  9931. }
  9932. }
  9933. }
  9934. if is390 == 1 {
  9935. insutype = "390"
  9936. }
  9937. if is310 == 1 {
  9938. insutype = "310"
  9939. }
  9940. if len(insutypes) == 0 {
  9941. insutype = "310"
  9942. }
  9943. psn := &models.HisPsn{
  9944. PsnNo: res2.Output.Baseinfo.PsnNo,
  9945. PatientId: patient.ID,
  9946. Certno: res2.Output.Baseinfo.Certno,
  9947. Gend: res2.Output.Baseinfo.Gend,
  9948. Naty: res2.Output.Baseinfo.Naty,
  9949. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9950. PsnName: res2.Output.Baseinfo.PsnName,
  9951. Idetinfo: idetinfoStr,
  9952. Insuinfo: infoStr,
  9953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9954. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9955. VerifyNumber: res.Output.EcToken,
  9956. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9957. }
  9958. service.CreateHisPsn(psn)
  9959. c.ServeSuccessJSON(map[string]interface{}{
  9960. "patient": patient,
  9961. "number": res.Output.CardNo,
  9962. "insutype": insutype,
  9963. })
  9964. }
  9965. } else {
  9966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9967. return
  9968. }
  9969. } else {
  9970. c.ServeSuccessJSON(map[string]interface{}{
  9971. "failed_code": -10,
  9972. "msg": res.ErrMsg,
  9973. })
  9974. }
  9975. } else {
  9976. //if initFlag == 0 {
  9977. // c.TestGetBasBaseInit()
  9978. //}
  9979. //token := c.GetEleBaseInfo()
  9980. //token = Remove0000(token)
  9981. type ELeData struct {
  9982. Code string `json:"code"`
  9983. Data struct {
  9984. Aac002 string `json:"aac002"`
  9985. Aaz500 string `json:"aaz500"`
  9986. ActCardNo string `json:"actCardNo"`
  9987. Bab520 string `json:"bab520"`
  9988. Bkz543 string `json:"bkz543"`
  9989. BusinessType string `json:"businessType"`
  9990. CertfCodg string `json:"certfCodg"`
  9991. EcIndexNo string `json:"ecIndexNo"`
  9992. EcToken string `json:"ecToken"`
  9993. ID0000 string `json:"id0000"`
  9994. IDNo string `json:"idNo"`
  9995. IDType string `json:"idType"`
  9996. Idcode string `json:"idcode"`
  9997. IdentityToken string `json:"identity_token"`
  9998. InsuOrg string `json:"insuOrg"`
  9999. OfficeID string `json:"officeId"`
  10000. OfficeName string `json:"officeName"`
  10001. OperatorID string `json:"operatorId"`
  10002. OperatorName string `json:"operatorName"`
  10003. OrgID string `json:"orgId"`
  10004. UserName string `json:"userName"`
  10005. } `json:"data"`
  10006. Infno interface{} `json:"infno"`
  10007. Message string `json:"message"`
  10008. OrgID string `json:"orgId"`
  10009. TransType string `json:"transType"`
  10010. }
  10011. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10012. fmt.Println(result)
  10013. outPutInfo := Remove0000(result)
  10014. fmt.Println(outPutInfo)
  10015. var ele ELeData
  10016. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10017. if err != nil {
  10018. utils.ErrorLog("解析失败:%v", err)
  10019. }
  10020. token := ele.Data.EcToken
  10021. var result2 string
  10022. var requestLog2 string
  10023. if len(token) > 0 {
  10024. if strings.Contains(ele.Data.IDNo, "HKG") {
  10025. result2, requestLog2 = service.Gdyb1101ForEleCert1111(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo, 6)
  10026. } else {
  10027. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10028. }
  10029. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10030. var res ResultTwo
  10031. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10032. utils.ErrorLog("解析失败:%v", err)
  10033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10034. return
  10035. }
  10036. if res.Infcode == 0 {
  10037. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10038. if err == gorm.ErrRecordNotFound {
  10039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10040. return
  10041. } else if err != nil {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10043. return
  10044. } else {
  10045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10047. infoStr := string(Iinfos)
  10048. idetinfoStr := string(Idetinfos)
  10049. psn := &models.HisPsn{
  10050. PsnNo: res.Output.Baseinfo.PsnNo,
  10051. PatientId: patient.ID,
  10052. Certno: res.Output.Baseinfo.Certno,
  10053. Gend: res.Output.Baseinfo.Gend,
  10054. Naty: res.Output.Baseinfo.Naty,
  10055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10056. PsnName: res.Output.Baseinfo.PsnName,
  10057. Idetinfo: idetinfoStr,
  10058. Insuinfo: infoStr,
  10059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10060. CardInfo: "",
  10061. VerifyNumber: token,
  10062. }
  10063. service.CreateHisPsn(psn)
  10064. c.ServeSuccessJSON(map[string]interface{}{
  10065. "msg": "读取成功",
  10066. })
  10067. }
  10068. } else {
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10070. return
  10071. }
  10072. } else {
  10073. c.ServeSuccessJSON(map[string]interface{}{
  10074. "failed_code": -10,
  10075. "msg": "读取失败",
  10076. })
  10077. }
  10078. }
  10079. }
  10080. func (c *HisApiController) ReadEleFace() {
  10081. admin_user_id, _ := c.GetInt64("admin_user_id")
  10082. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10083. adminUser := c.GetAdminUserInfo()
  10084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10085. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10086. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10087. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10088. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10089. if len(tokens) > 0 {
  10090. c.ServeSuccessJSON(map[string]interface{}{
  10091. "msg": "读取成功",
  10092. })
  10093. } else {
  10094. c.ServeSuccessJSON(map[string]interface{}{
  10095. "failed_code": -10,
  10096. "msg": "读取失败",
  10097. })
  10098. }
  10099. }
  10100. }
  10101. func (c *HisApiController) Get9001() {
  10102. adminUser := c.GetAdminUserInfo()
  10103. admin_user_id, _ := c.GetInt64("admin_user_id")
  10104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10106. if miConfig.MdtrtareaAdmvs == "350500" {
  10107. service.GetFjAuthorizationInfo(miConfig.Code)
  10108. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10109. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10110. var dat map[string]interface{}
  10111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10112. fmt.Println(dat)
  10113. } else {
  10114. fmt.Println(err)
  10115. }
  10116. userJSONBytes, _ := json.Marshal(dat)
  10117. var res models.Result9001
  10118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10119. utils.ErrorLog("解析失败:%v", err)
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10121. return
  10122. }
  10123. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10124. fmt.Println(miConfig.SecretKey)
  10125. var res models.Result9001Two
  10126. api := miConfig.SecretKey + "ahyb/9001?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  10127. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10128. resp, requestErr := http.Get(api)
  10129. if requestErr != nil {
  10130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10131. return
  10132. }
  10133. body, ioErr := ioutil.ReadAll(resp.Body)
  10134. if ioErr != nil {
  10135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10137. return
  10138. }
  10139. var respJSON map[string]interface{}
  10140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10146. if status == "0" {
  10147. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10148. c.ServeSuccessJSON(map[string]interface{}{
  10149. "failed_code": -10,
  10150. "msg": err_msg,
  10151. })
  10152. return
  10153. }
  10154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10155. result, _ := json.Marshal(respJSON)
  10156. fmt.Println("log")
  10157. fmt.Println(string(result))
  10158. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10159. utils.ErrorLog("解析失败:%v", err)
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. return
  10162. }
  10163. if res.Infcode == 0 {
  10164. sign := models.HisSignIn{
  10165. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10166. SignNo: res.Output.Signinoutb.SignNo,
  10167. SignTime: "",
  10168. Ctime: time.Now().Unix(),
  10169. Mtime: time.Now().Unix(),
  10170. Status: 1,
  10171. InputLog: "",
  10172. OutputLog: "",
  10173. FixmedinsCode: miConfig.Code,
  10174. }
  10175. err := service.CreateSignIn(&sign)
  10176. if err == nil {
  10177. c.ServeSuccessJSON(map[string]interface{}{
  10178. "msg": "签到成功",
  10179. })
  10180. }
  10181. } else {
  10182. c.ServeSuccessJSON(map[string]interface{}{
  10183. "failed_code": -10,
  10184. "msg": res.ErrMsg,
  10185. })
  10186. return
  10187. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10188. //return
  10189. }
  10190. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10191. fmt.Println(miConfig.SecretKey)
  10192. var res models.Result9001Two
  10193. api := miConfig.SecretKey + "ahyb/9001?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  10194. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10195. resp, requestErr := http.Get(api)
  10196. if requestErr != nil {
  10197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10198. return
  10199. }
  10200. body, ioErr := ioutil.ReadAll(resp.Body)
  10201. if ioErr != nil {
  10202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10204. return
  10205. }
  10206. var respJSON map[string]interface{}
  10207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10210. return
  10211. }
  10212. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10213. if status == "0" {
  10214. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10215. c.ServeSuccessJSON(map[string]interface{}{
  10216. "failed_code": -10,
  10217. "msg": err_msg,
  10218. })
  10219. return
  10220. }
  10221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10222. result, _ := json.Marshal(respJSON)
  10223. fmt.Println("log")
  10224. fmt.Println(string(result))
  10225. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10226. utils.ErrorLog("解析失败:%v", err)
  10227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10228. return
  10229. }
  10230. if res.Infcode == 0 {
  10231. sign := models.HisSignIn{
  10232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10233. SignNo: res.Output.Signinoutb.SignNo,
  10234. SignTime: "",
  10235. Ctime: time.Now().Unix(),
  10236. Mtime: time.Now().Unix(),
  10237. Status: 1,
  10238. InputLog: "",
  10239. OutputLog: "",
  10240. FixmedinsCode: miConfig.Code,
  10241. }
  10242. err := service.CreateSignIn(&sign)
  10243. if err == nil {
  10244. c.ServeSuccessJSON(map[string]interface{}{
  10245. "msg": "签到成功",
  10246. })
  10247. }
  10248. } else {
  10249. c.ServeSuccessJSON(map[string]interface{}{
  10250. "failed_code": -10,
  10251. "msg": res.ErrMsg,
  10252. })
  10253. return
  10254. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10255. //return
  10256. }
  10257. } else {
  10258. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10259. var dat map[string]interface{}
  10260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10261. fmt.Println(dat)
  10262. } else {
  10263. fmt.Println(err)
  10264. }
  10265. userJSONBytes, _ := json.Marshal(dat)
  10266. var res models.Result9001
  10267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10268. utils.ErrorLog("解析失败:%v", err)
  10269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10270. return
  10271. }
  10272. if res.Infcode == 0 {
  10273. sign := models.HisSignIn{
  10274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10275. SignNo: res.Output.Signinoutb.SignNo,
  10276. SignTime: res.Output.Signinoutb.SignTime,
  10277. Ctime: time.Now().Unix(),
  10278. Mtime: time.Now().Unix(),
  10279. Status: 1,
  10280. InputLog: "",
  10281. OutputLog: "",
  10282. FixmedinsCode: miConfig.Code,
  10283. }
  10284. err := service.CreateSignIn(&sign)
  10285. if err == nil {
  10286. c.ServeSuccessJSON(map[string]interface{}{
  10287. "msg": "签到成功",
  10288. })
  10289. }
  10290. }
  10291. }
  10292. }
  10293. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, de models.XtHisDepartment) (res2 Result3101) {
  10294. var res Result3101
  10295. adminUser := c.GetAdminUserInfo()
  10296. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10297. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10299. //record_time := c.GetString("record_time")
  10300. //trig_scen := c.GetString("trig_scen")
  10301. timeLayout := "2006-01-02"
  10302. loc, _ := time.LoadLocation("Local")
  10303. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10304. if err != nil {
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10306. return res
  10307. }
  10308. recordDateTime := theTime.Unix()
  10309. var patientPrescription models.HisPrescriptionInfo
  10310. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10311. //if patientPrescription.ID == 0 {
  10312. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10313. //}
  10314. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10315. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10316. //
  10317. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10318. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10319. var pp models.PublicParams
  10320. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10321. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10322. pp.FixmedinsName = miConfig.OrgName
  10323. pp.FixmedinsCode = miConfig.Code
  10324. pp.RequestUrl = miConfig.Url
  10325. pp.Cainfo = miConfig.Cainfo
  10326. pp.SecretKey = miConfig.SecretKey
  10327. pp.AccessKey = miConfig.AccessKey
  10328. pp.OpterName = roles.UserName
  10329. var config []*models.HisXtDiagnoseConfig
  10330. for _, item := range diagnosis_ids {
  10331. id, _ := strconv.ParseInt(item, 10, 64)
  10332. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10333. config = append(config, &diagnosisConfig)
  10334. }
  10335. var pd models.PatientDtos
  10336. pd.PatnID = his.PsnNo
  10337. pd.PatnName = his.Name
  10338. pd.Gend = his.Gend
  10339. pd.Brdy = his.Brdy
  10340. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10341. pd.CurrMdtrtID = his.Number
  10342. var fed models.FsiEncounterDtos
  10343. fed.MdtrtID = his.Number
  10344. fed.MedinsID = miConfig.Code
  10345. fed.MedinsName = miConfig.OrgName
  10346. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10347. fed.MedMdtrtType = "1"
  10348. fed.MedinsType = "1"
  10349. fed.MedinsLv = "11"
  10350. tm := time.Unix(his.RecordDate, 0)
  10351. s_tm := tm.Format("2006-01-02 15:04:05")
  10352. fed.AdmDate = s_tm
  10353. fed.DscgDate = s_tm
  10354. fed.DscgMainDiseCodg = config[0].CountryCode
  10355. fed.DscgMainDiseName = config[0].CountryContentName
  10356. //诊断信息
  10357. var fdds []*models.FsiDiagnoseDtos
  10358. for index, item := range config {
  10359. if index == 0 {
  10360. var fdd models.FsiDiagnoseDtos
  10361. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10362. fdd.InoutDiseType = "1"
  10363. fdd.MaindiseFlag = "1"
  10364. fdd.DiseDate = s_tm
  10365. fdd.DiasSrtNo = "1"
  10366. fdd.DiseName = item.CountryContentName
  10367. fdd.DiseCodg = item.CountryCode
  10368. fdds = append(fdds, &fdd)
  10369. } else {
  10370. var fdd models.FsiDiagnoseDtos
  10371. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10372. fdd.InoutDiseType = "1"
  10373. fdd.MaindiseFlag = "1"
  10374. fdd.DiseDate = s_tm
  10375. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10376. fdd.DiseName = item.CountryContentName
  10377. fdd.DiseCodg = item.CountryCode
  10378. fdds = append(fdds, &fdd)
  10379. }
  10380. }
  10381. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10382. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10383. fed.AdmDeptName = de.Name
  10384. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10385. fed.DscgDeptName = de.Name
  10386. fed.MedMdtrtType = "1"
  10387. fed.MedType = "11"
  10388. //if his.Insutype == "390" {
  10389. // fed.MedType = "1402"
  10390. //} else {
  10391. // fed.MedType = "9933"
  10392. //}
  10393. var orders []*models.FsiOrderDtos
  10394. if trig_scen == "2" {
  10395. //处方医嘱信息
  10396. for _, item := range prescriptions {
  10397. for _, subItem := range item.HisDoctorAdviceInfo {
  10398. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10399. var order models.FsiOrderDtos
  10400. order.RxID = strconv.FormatInt(item.ID, 10)
  10401. order.Rxno = strconv.FormatInt(item.ID, 10)
  10402. order.LongDrordFlag = "0"
  10403. order.HilistType = "1"
  10404. order.ChrgType = "1"
  10405. order.DrordBhvr = "-"
  10406. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10407. order.HosplistName = subItem.BaseDrugLib.DrugName
  10408. order.HilistLv = "1"
  10409. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10410. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10411. order.HosplistName = subItem.BaseDrugLib.DrugName
  10412. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10413. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10414. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10415. order.OwnpayAmt = ""
  10416. order.SelfpayAmt = ""
  10417. order.Spec = ""
  10418. order.SpecUnt = ""
  10419. order.DrordBegnDate = s_tm
  10420. order.DrordStopDate = ""
  10421. order.DrordDrCodg = doctor_info.DoctorNumber
  10422. order.DrordDeptName = department.Name
  10423. order.DrordDeptCodg = department.Number
  10424. order.DrordDrName = doctor_info.UserName
  10425. order.DrordDrProfttl = "234"
  10426. order.CurrDrordFlag = "1"
  10427. orders = append(orders, &order)
  10428. }
  10429. }
  10430. for _, subItem := range item.HisPrescriptionProject {
  10431. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10432. var order models.FsiOrderDtos
  10433. order.RxID = strconv.FormatInt(item.ID, 10)
  10434. order.Rxno = strconv.FormatInt(item.ID, 10)
  10435. order.LongDrordFlag = "0"
  10436. order.HilistType = "1"
  10437. order.ChrgType = "1"
  10438. order.DrordBhvr = "-"
  10439. order.HilistCode = subItem.HisProject.MedicalCode
  10440. order.HosplistName = subItem.HisProject.ProjectName
  10441. order.HilistLv = "1"
  10442. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10443. order.HosplistCode = subItem.HisProject.MedicalCode
  10444. order.HosplistName = subItem.HisProject.ProjectName
  10445. order.Cnt = subItem.Count
  10446. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10447. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10448. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10449. order.OwnpayAmt = ""
  10450. order.SelfpayAmt = ""
  10451. order.Spec = ""
  10452. order.SpecUnt = ""
  10453. order.DrordBegnDate = s_tm
  10454. order.DrordStopDate = ""
  10455. order.DrordDrCodg = doctor_info.DoctorNumber
  10456. order.DrordDeptName = department.Name
  10457. order.DrordDeptCodg = department.Number
  10458. order.DrordDrName = doctor_info.UserName
  10459. order.DrordDrProfttl = "234"
  10460. order.CurrDrordFlag = "1"
  10461. orders = append(orders, &order)
  10462. }
  10463. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10464. var order models.FsiOrderDtos
  10465. order.RxID = strconv.FormatInt(item.ID, 10)
  10466. order.Rxno = strconv.FormatInt(item.ID, 10)
  10467. order.LongDrordFlag = "0"
  10468. order.HilistType = "1"
  10469. order.ChrgType = "1"
  10470. order.DrordBhvr = "-"
  10471. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10472. order.HosplistName = subItem.GoodInfo.GoodName
  10473. order.HilistLv = "1"
  10474. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10475. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10476. order.HosplistName = subItem.GoodInfo.GoodName
  10477. order.Cnt = subItem.Count
  10478. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10479. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10480. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10481. order.OwnpayAmt = ""
  10482. order.SelfpayAmt = ""
  10483. order.Spec = ""
  10484. order.SpecUnt = ""
  10485. order.DrordBegnDate = s_tm
  10486. order.DrordStopDate = ""
  10487. order.DrordDrCodg = doctor_info.DoctorNumber
  10488. order.DrordDeptName = department.Name
  10489. order.DrordDeptCodg = department.Number
  10490. order.DrordDrName = doctor_info.UserName
  10491. order.DrordDrProfttl = "234"
  10492. order.CurrDrordFlag = "1"
  10493. orders = append(orders, &order)
  10494. }
  10495. }
  10496. }
  10497. //处方医嘱信息
  10498. }
  10499. fed.MatnStas = "0"
  10500. fed.MedfeeSumamt = "0"
  10501. fed.OwnpayAmt = "0"
  10502. fed.SelfpayAmt = "0"
  10503. fed.AcctPayamt = "0"
  10504. fed.MaAmt = "0"
  10505. fed.HifpPayamt = "0"
  10506. fed.SetlTotlnum = "1"
  10507. fed.Insutype = his.Insutype
  10508. fed.ReimFlag = "0"
  10509. fed.OutSetlFlag = "0"
  10510. var fopd []*models.FsiOperationDtosData
  10511. data := make(map[string]interface{})
  10512. data["fed"] = fed
  10513. data["fdd"] = fdds
  10514. data["fod"] = orders
  10515. data["pd"] = pd
  10516. data["pp"] = pp
  10517. data["fopd"] = fopd
  10518. data["trig_scen"] = trig_scen
  10519. fmt.Println(data)
  10520. fmt.Println(fed)
  10521. fmt.Println(fdds)
  10522. fmt.Println(orders)
  10523. fmt.Println(pd)
  10524. fmt.Println(pp)
  10525. fmt.Println(fopd)
  10526. client := &http.Client{}
  10527. bytesData, _ := json.Marshal(data)
  10528. var req *http.Request
  10529. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10530. if miConfig.MdtrtareaAdmvs == "320921" {
  10531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10532. } else {
  10533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10534. }
  10535. resp, _ := client.Do(req)
  10536. defer resp.Body.Close()
  10537. body, ioErr := ioutil.ReadAll(resp.Body)
  10538. if ioErr != nil {
  10539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10541. return res
  10542. }
  10543. var respJSON map[string]interface{}
  10544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10547. return res
  10548. }
  10549. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10550. fmt.Println(respJSON)
  10551. result, _ := json.Marshal(respJSON)
  10552. fmt.Println(result)
  10553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10554. utils.ErrorLog("解析失败:%v", err)
  10555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. return res
  10557. }
  10558. return res
  10559. } else {
  10560. //if miConfig.MdtrtareaAdmvs == "441202" {
  10561. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10562. saveLog(output, input, "3101", "事前")
  10563. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10564. utils.ErrorLog("解析失败:%v", err)
  10565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10566. return
  10567. }
  10568. return res
  10569. //}
  10570. }
  10571. }
  10572. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  10573. adminUser := c.GetAdminUserInfo()
  10574. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10575. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10577. //record_time := c.GetString("record_time")
  10578. //trig_scen := c.GetString("trig_scen")
  10579. timeLayout := "2006-01-02"
  10580. loc, _ := time.LoadLocation("Local")
  10581. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10582. if err != nil {
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10584. return res
  10585. }
  10586. recordDateTime := theTime.Unix()
  10587. var patientPrescription models.HisPrescriptionInfo
  10588. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10589. if patientPrescription.ID == 0 {
  10590. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10591. }
  10592. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10593. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10594. //
  10595. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10596. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10597. var pp models.PublicParams
  10598. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10599. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10600. pp.FixmedinsName = miConfig.OrgName
  10601. pp.FixmedinsCode = miConfig.Code
  10602. pp.RequestUrl = miConfig.Url
  10603. pp.Cainfo = miConfig.Cainfo
  10604. pp.SecretKey = miConfig.SecretKey
  10605. pp.AccessKey = miConfig.AccessKey
  10606. pp.OpterName = roles.UserName
  10607. var config []*models.HisXtDiagnoseConfig
  10608. for _, item := range diagnosis_ids {
  10609. id, _ := strconv.ParseInt(item, 10, 64)
  10610. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10611. config = append(config, &diagnosisConfig)
  10612. }
  10613. var pd models.PatientDtos
  10614. pd.PatnID = his.PsnNo
  10615. pd.PatnName = his.Name
  10616. pd.Gend = his.Gend
  10617. pd.Brdy = his.Brdy
  10618. pd.Poolarea = his.InsuplcAdmdvs
  10619. pd.CurrMdtrtID = his.Number
  10620. var fed models.FsiEncounterDtos
  10621. fed.MdtrtID = his.Number
  10622. fed.MedinsID = miConfig.Code
  10623. fed.MedinsName = miConfig.OrgName
  10624. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10625. fed.MedMdtrtType = "1"
  10626. fed.MedinsType = "1"
  10627. fed.MedinsLv = "11"
  10628. tm := time.Unix(his.RecordDate, 0)
  10629. s_tm := tm.Format("2006-01-02 15:04:05")
  10630. fed.AdmDate = s_tm
  10631. fed.DscgDate = s_tm
  10632. fed.DscgMainDiseCodg = config[0].CountryCode
  10633. fed.DscgMainDiseName = config[0].CountryContentName
  10634. //诊断信息
  10635. var fdds []*models.FsiDiagnoseDtos
  10636. for index, item := range config {
  10637. if index == 0 {
  10638. var fdd models.FsiDiagnoseDtos
  10639. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10640. fdd.InoutDiseType = "1"
  10641. fdd.MaindiseFlag = "1"
  10642. fdd.DiseDate = s_tm
  10643. fdd.DiasSrtNo = "1"
  10644. fdd.DiseName = item.CountryContentName
  10645. fdd.DiseCodg = item.CountryCode
  10646. fdds = append(fdds, &fdd)
  10647. } else {
  10648. var fdd models.FsiDiagnoseDtos
  10649. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10650. fdd.InoutDiseType = "1"
  10651. fdd.MaindiseFlag = "1"
  10652. fdd.DiseDate = s_tm
  10653. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10654. fdd.DiseName = item.CountryContentName
  10655. fdd.DiseCodg = item.CountryCode
  10656. fdds = append(fdds, &fdd)
  10657. }
  10658. }
  10659. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10660. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10661. fed.AdmDeptName = department.Name
  10662. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10663. fed.DscgDeptName = department.Name
  10664. fed.MedMdtrtType = "1"
  10665. fed.MedType = "11"
  10666. //if his.Insutype == "390" {
  10667. // fed.MedType = "1402"
  10668. //} else {
  10669. // fed.MedType = "9933"
  10670. //}
  10671. var orders []*models.FsiOrderDtos
  10672. if trig_scen == "2" {
  10673. //处方医嘱信息
  10674. for _, item := range prescriptions {
  10675. for _, subItem := range item.HisDoctorAdviceInfo {
  10676. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10677. var order models.FsiOrderDtos
  10678. order.RxID = strconv.FormatInt(item.ID, 10)
  10679. order.Rxno = strconv.FormatInt(item.ID, 10)
  10680. order.LongDrordFlag = "0"
  10681. order.HilistType = "1"
  10682. order.ChrgType = "1"
  10683. order.DrordBhvr = "-"
  10684. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10685. order.HosplistName = subItem.BaseDrugLib.DrugName
  10686. order.HilistLv = "1"
  10687. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10688. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10689. order.HosplistName = subItem.BaseDrugLib.DrugName
  10690. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10692. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10693. order.OwnpayAmt = ""
  10694. order.SelfpayAmt = ""
  10695. order.Spec = ""
  10696. order.SpecUnt = ""
  10697. order.DrordBegnDate = s_tm
  10698. order.DrordStopDate = ""
  10699. order.DrordDrCodg = doctor_info.DoctorNumber
  10700. order.DrordDeptName = department.Name
  10701. order.DrordDeptCodg = department.Number
  10702. order.DrordDrName = doctor_info.UserName
  10703. order.DrordDrProfttl = "234"
  10704. order.CurrDrordFlag = "1"
  10705. orders = append(orders, &order)
  10706. }
  10707. }
  10708. for _, subItem := range item.HisPrescriptionProject {
  10709. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10710. var order models.FsiOrderDtos
  10711. order.RxID = strconv.FormatInt(item.ID, 10)
  10712. order.Rxno = strconv.FormatInt(item.ID, 10)
  10713. order.LongDrordFlag = "0"
  10714. order.HilistType = "1"
  10715. order.ChrgType = "1"
  10716. order.DrordBhvr = "-"
  10717. order.HilistCode = subItem.HisProject.MedicalCode
  10718. order.HosplistName = subItem.HisProject.ProjectName
  10719. order.HilistLv = "1"
  10720. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10721. order.HosplistCode = subItem.HisProject.MedicalCode
  10722. order.HosplistName = subItem.HisProject.ProjectName
  10723. order.Cnt = subItem.Count
  10724. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10725. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10726. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10727. order.OwnpayAmt = ""
  10728. order.SelfpayAmt = ""
  10729. order.Spec = ""
  10730. order.SpecUnt = ""
  10731. order.DrordBegnDate = s_tm
  10732. order.DrordStopDate = ""
  10733. order.DrordDrCodg = doctor_info.DoctorNumber
  10734. order.DrordDeptName = department.Name
  10735. order.DrordDeptCodg = department.Number
  10736. order.DrordDrName = doctor_info.UserName
  10737. order.DrordDrProfttl = "234"
  10738. order.CurrDrordFlag = "1"
  10739. orders = append(orders, &order)
  10740. }
  10741. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10742. var order models.FsiOrderDtos
  10743. order.RxID = strconv.FormatInt(item.ID, 10)
  10744. order.Rxno = strconv.FormatInt(item.ID, 10)
  10745. order.LongDrordFlag = "0"
  10746. order.HilistType = "1"
  10747. order.ChrgType = "1"
  10748. order.DrordBhvr = "-"
  10749. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10750. order.HosplistName = subItem.GoodInfo.GoodName
  10751. order.HilistLv = "1"
  10752. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10753. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10754. order.HosplistName = subItem.GoodInfo.GoodName
  10755. order.Cnt = subItem.Count
  10756. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10757. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10758. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10759. order.OwnpayAmt = ""
  10760. order.SelfpayAmt = ""
  10761. order.Spec = ""
  10762. order.SpecUnt = ""
  10763. order.DrordBegnDate = s_tm
  10764. order.DrordStopDate = ""
  10765. order.DrordDrCodg = doctor_info.DoctorNumber
  10766. order.DrordDeptName = department.Name
  10767. order.DrordDeptCodg = department.Number
  10768. order.DrordDrName = doctor_info.UserName
  10769. order.DrordDrProfttl = "234"
  10770. order.CurrDrordFlag = "1"
  10771. orders = append(orders, &order)
  10772. }
  10773. }
  10774. }
  10775. //处方医嘱信息
  10776. }
  10777. fed.MatnStas = "0"
  10778. fed.MedfeeSumamt = "0"
  10779. fed.OwnpayAmt = "0"
  10780. fed.SelfpayAmt = "0"
  10781. fed.AcctPayamt = "0"
  10782. fed.MaAmt = "0"
  10783. fed.HifpPayamt = "0"
  10784. fed.SetlTotlnum = "1"
  10785. fed.Insutype = his.Insutype
  10786. fed.ReimFlag = "0"
  10787. fed.OutSetlFlag = "0"
  10788. var fopd []*models.FsiOperationDtosData
  10789. data := make(map[string]interface{})
  10790. data["fed"] = fed
  10791. data["fdd"] = fdds
  10792. data["fod"] = orders
  10793. data["pd"] = pd
  10794. data["pp"] = pp
  10795. data["fopd"] = fopd
  10796. data["trig_scen"] = trig_scen
  10797. fmt.Println(data)
  10798. fmt.Println(fed)
  10799. fmt.Println(fdds)
  10800. fmt.Println(orders)
  10801. fmt.Println(pd)
  10802. fmt.Println(pp)
  10803. fmt.Println(fopd)
  10804. client := &http.Client{}
  10805. bytesData, _ := json.Marshal(data)
  10806. var req *http.Request
  10807. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10808. if miConfig.MdtrtareaAdmvs == "320921" {
  10809. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10810. } else {
  10811. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10812. }
  10813. resp, _ := client.Do(req)
  10814. defer resp.Body.Close()
  10815. body, ioErr := ioutil.ReadAll(resp.Body)
  10816. if ioErr != nil {
  10817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10819. return res
  10820. }
  10821. var respJSON map[string]interface{}
  10822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10825. return res
  10826. }
  10827. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10828. fmt.Println(respJSON)
  10829. result, _ := json.Marshal(respJSON)
  10830. fmt.Println(result)
  10831. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10832. utils.ErrorLog("解析失败:%v", err)
  10833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10834. return res
  10835. }
  10836. return res
  10837. } else {
  10838. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10839. saveLog(output, input, "3101", "事前")
  10840. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10841. utils.ErrorLog("解析失败:%v", err)
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. return res
  10846. }
  10847. return res
  10848. }
  10849. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10850. ////patient_id, _ := c.GetInt64("patient_id")
  10851. //order_id, _ := c.GetInt64("order_id")
  10852. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10853. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10854. //trig_scen := c.GetString("trig_scen")
  10855. adminUser := c.GetAdminUserInfo()
  10856. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10857. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10858. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10859. record_time := c.GetString("record_time")
  10860. order, _ := service.GetHisOrderByID(order_id)
  10861. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10862. timeLayout := "2006-01-02"
  10863. loc, _ := time.LoadLocation("Local")
  10864. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10865. if err != nil {
  10866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10867. return
  10868. }
  10869. recordDateTime := theTime.Unix()
  10870. var patientPrescription models.HisPrescriptionInfo
  10871. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10872. if patientPrescription.ID == 0 {
  10873. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10874. }
  10875. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10876. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10877. //
  10878. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10879. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10880. var pp models.PublicParams
  10881. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10882. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10883. pp.FixmedinsName = miConfig.OrgName
  10884. pp.FixmedinsCode = miConfig.Code
  10885. pp.RequestUrl = miConfig.Url
  10886. pp.Cainfo = miConfig.Cainfo
  10887. pp.SecretKey = miConfig.SecretKey
  10888. pp.AccessKey = miConfig.AccessKey
  10889. pp.OpterName = roles.UserName
  10890. var config []*models.HisXtDiagnoseConfig
  10891. for _, item := range diagnosis_ids {
  10892. id, _ := strconv.ParseInt(item, 10, 64)
  10893. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10894. config = append(config, &diagnosisConfig)
  10895. }
  10896. var pd models.PatientDtos
  10897. pd.PatnID = his.PsnNo
  10898. pd.PatnName = his.Name
  10899. pd.Gend = his.Gend
  10900. pd.Brdy = psn_info.Brdy
  10901. pd.Poolarea = his.InsuplcAdmdvs
  10902. pd.CurrMdtrtID = his.Number
  10903. var fed models.FsiEncounterDtos
  10904. fed.MdtrtID = his.Number
  10905. fed.MedinsID = miConfig.Code
  10906. fed.MedinsName = miConfig.OrgName
  10907. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10908. fed.MedMdtrtType = "1"
  10909. fed.MedinsType = "1"
  10910. fed.MedinsLv = "11"
  10911. tm := time.Unix(his.RecordDate, 0)
  10912. s_tm := tm.Format("2006-01-02 15:04:05")
  10913. fed.AdmDate = s_tm
  10914. fed.DscgDate = s_tm
  10915. fed.DscgMainDiseCodg = config[0].CountryCode
  10916. fed.DscgMainDiseName = config[0].CountryContentName
  10917. //诊断信息
  10918. var fdds []*models.FsiDiagnoseDtos
  10919. for index, item := range config {
  10920. if index == 0 {
  10921. var fdd models.FsiDiagnoseDtos
  10922. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10923. fdd.InoutDiseType = "1"
  10924. fdd.MaindiseFlag = "1"
  10925. fdd.DiseDate = s_tm
  10926. fdd.DiasSrtNo = "1"
  10927. fdd.DiseName = item.CountryContentName
  10928. fdd.DiseCodg = item.CountryCode
  10929. fdds = append(fdds, &fdd)
  10930. } else {
  10931. var fdd models.FsiDiagnoseDtos
  10932. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10933. fdd.InoutDiseType = "1"
  10934. fdd.MaindiseFlag = "1"
  10935. fdd.DiseDate = s_tm
  10936. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10937. fdd.DiseName = item.CountryContentName
  10938. fdd.DiseCodg = item.CountryCode
  10939. fdds = append(fdds, &fdd)
  10940. }
  10941. }
  10942. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10943. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10944. fed.AdmDeptName = department.Name
  10945. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10946. fed.DscgDeptName = department.Name
  10947. fed.MedType = order.MedType
  10948. //处方医嘱信息
  10949. var orders []*models.FsiOrderDtos
  10950. //for _, item := range prescriptions {
  10951. // for _, subItem := range item.HisDoctorAdviceInfo {
  10952. // var order models.FsiOrderDtos
  10953. // order.RxID = strconv.FormatInt(item.ID, 10)
  10954. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10955. // order.LongDrordFlag = "0"
  10956. // order.HilistType = "1"
  10957. // order.ChrgType = "1"
  10958. // order.DrordBhvr = "-"
  10959. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10960. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10961. // order.HilistLv = "1"
  10962. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10963. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10964. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10965. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10966. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10967. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10968. // order.OwnpayAmt = ""
  10969. // order.SelfpayAmt = ""
  10970. // order.Spec = ""
  10971. // order.SpecUnt = ""
  10972. // order.DrordBegnDate = s_tm
  10973. // order.DrordStopDate = ""
  10974. // order.DrordDrCodg = "1"
  10975. // order.DrordDeptName = department.Name
  10976. // order.DrordDrCodg = "1"
  10977. // order.DrordDrName = doctor_info.UserName
  10978. // order.DrordDrProfttl = ""
  10979. // order.CurrDrordFlag = "1"
  10980. // orders = append(orders, &order)
  10981. // }
  10982. // for _, subItem := range item.HisPrescriptionProject {
  10983. // if subItem.Type == 2 {
  10984. // var order models.FsiOrderDtos
  10985. // order.RxID = strconv.FormatInt(item.ID, 10)
  10986. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10987. // order.LongDrordFlag = "0"
  10988. // order.HilistType = "1"
  10989. // order.ChrgType = "1"
  10990. // order.DrordBhvr = "-"
  10991. // order.HilistCode = subItem.HisProject.MedicalCode
  10992. // order.HosplistName = subItem.HisProject.ProjectName
  10993. // order.HilistLv = "1"
  10994. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10995. // order.HosplistCode = subItem.HisProject.MedicalCode
  10996. // order.HosplistName = subItem.HisProject.ProjectName
  10997. // order.Cnt = subItem.Count
  10998. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10999. //
  11000. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11001. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11002. // order.OwnpayAmt = ""
  11003. // order.SelfpayAmt = ""
  11004. // order.Spec = ""
  11005. // order.SpecUnt = ""
  11006. // order.DrordBegnDate = s_tm
  11007. // order.DrordStopDate = ""
  11008. // order.DrordDrCodg = "1"
  11009. // order.DrordDeptName = department.Name
  11010. // order.DrordDrCodg = "1"
  11011. // order.DrordDrName = doctor_info.UserName
  11012. // order.DrordDrProfttl = ""
  11013. // order.CurrDrordFlag = "1"
  11014. // orders = append(orders, &order)
  11015. //
  11016. // }
  11017. // if subItem.Type == 3 {
  11018. //
  11019. // var order models.FsiOrderDtos
  11020. // order.RxID = strconv.FormatInt(item.ID, 10)
  11021. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11022. // order.LongDrordFlag = "0"
  11023. // order.HilistType = "1"
  11024. // order.ChrgType = "1"
  11025. // order.DrordBhvr = "-"
  11026. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11027. // order.HosplistName = subItem.GoodInfo.GoodName
  11028. // order.HilistLv = "1"
  11029. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11030. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11031. // order.HosplistName = subItem.GoodInfo.GoodName
  11032. // order.Cnt = subItem.Count
  11033. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11034. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11035. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11036. // order.OwnpayAmt = ""
  11037. // order.SelfpayAmt = ""
  11038. // order.Spec = ""
  11039. // order.SpecUnt = ""
  11040. // order.DrordBegnDate = s_tm
  11041. // order.DrordStopDate = ""
  11042. // order.DrordDrCodg = "1"
  11043. // order.DrordDeptName = department.Name
  11044. // order.DrordDrCodg = "1"
  11045. // order.DrordDrName = doctor_info.UserName
  11046. // order.DrordDrProfttl = ""
  11047. // order.CurrDrordFlag = "1"
  11048. // orders = append(orders, &order)
  11049. //
  11050. // }
  11051. // }
  11052. //}
  11053. for _, item := range prescriptions {
  11054. for _, subItem := range item.HisDoctorAdviceInfo {
  11055. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11056. var order models.FsiOrderDtos
  11057. order.RxID = strconv.FormatInt(item.ID, 10)
  11058. order.Rxno = strconv.FormatInt(item.ID, 10)
  11059. order.LongDrordFlag = "0"
  11060. order.HilistType = "1"
  11061. order.ChrgType = "1"
  11062. order.DrordBhvr = "-"
  11063. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11064. order.HosplistName = subItem.BaseDrugLib.DrugName
  11065. order.HilistLv = "1"
  11066. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11067. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11068. order.HosplistName = subItem.BaseDrugLib.DrugName
  11069. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11070. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11071. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11072. order.OwnpayAmt = ""
  11073. order.SelfpayAmt = ""
  11074. order.Spec = ""
  11075. order.SpecUnt = ""
  11076. order.DrordBegnDate = s_tm
  11077. order.DrordStopDate = ""
  11078. order.DrordDrCodg = doctor_info.DoctorNumber
  11079. order.DrordDeptName = department.Name
  11080. order.DrordDeptCodg = department.Number
  11081. order.DrordDrName = doctor_info.UserName
  11082. order.DrordDrProfttl = "234"
  11083. order.CurrDrordFlag = "1"
  11084. orders = append(orders, &order)
  11085. }
  11086. }
  11087. for _, subItem := range item.HisPrescriptionProject {
  11088. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11089. var order models.FsiOrderDtos
  11090. order.RxID = strconv.FormatInt(item.ID, 10)
  11091. order.Rxno = strconv.FormatInt(item.ID, 10)
  11092. order.LongDrordFlag = "0"
  11093. order.HilistType = "1"
  11094. order.ChrgType = "1"
  11095. order.DrordBhvr = "-"
  11096. order.HilistCode = subItem.HisProject.MedicalCode
  11097. order.HosplistName = subItem.HisProject.ProjectName
  11098. order.HilistLv = "1"
  11099. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11100. order.HosplistCode = subItem.HisProject.MedicalCode
  11101. order.HosplistName = subItem.HisProject.ProjectName
  11102. order.Cnt = subItem.Count
  11103. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11104. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11105. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11106. order.OwnpayAmt = ""
  11107. order.SelfpayAmt = ""
  11108. order.Spec = ""
  11109. order.SpecUnt = ""
  11110. order.DrordBegnDate = s_tm
  11111. order.DrordStopDate = ""
  11112. order.DrordDrCodg = doctor_info.DoctorNumber
  11113. order.DrordDeptName = department.Name
  11114. order.DrordDeptCodg = department.Number
  11115. order.DrordDrName = doctor_info.UserName
  11116. order.DrordDrProfttl = "234"
  11117. order.CurrDrordFlag = "1"
  11118. orders = append(orders, &order)
  11119. }
  11120. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11121. var order models.FsiOrderDtos
  11122. order.RxID = strconv.FormatInt(item.ID, 10)
  11123. order.Rxno = strconv.FormatInt(item.ID, 10)
  11124. order.LongDrordFlag = "0"
  11125. order.HilistType = "1"
  11126. order.ChrgType = "1"
  11127. order.DrordBhvr = "0"
  11128. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11129. order.HosplistName = subItem.GoodInfo.GoodName
  11130. order.HilistLv = "1"
  11131. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11132. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11133. order.HosplistName = subItem.GoodInfo.GoodName
  11134. order.Cnt = subItem.Count
  11135. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11136. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11137. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11138. order.OwnpayAmt = ""
  11139. order.SelfpayAmt = ""
  11140. order.Spec = ""
  11141. order.SpecUnt = ""
  11142. order.DrordBegnDate = s_tm
  11143. order.DrordStopDate = ""
  11144. order.DrordDrCodg = doctor_info.DoctorNumber
  11145. order.DrordDeptName = department.Name
  11146. order.DrordDeptCodg = department.Number
  11147. order.DrordDrName = doctor_info.UserName
  11148. order.DrordDrProfttl = "234"
  11149. order.CurrDrordFlag = "1"
  11150. orders = append(orders, &order)
  11151. }
  11152. }
  11153. }
  11154. //处方医嘱信息
  11155. fed.MatnStas = "0"
  11156. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11157. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11158. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11159. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11160. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11161. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11162. fed.SetlTotlnum = "1"
  11163. fed.Insutype = his.Insutype
  11164. fed.ReimFlag = "0"
  11165. fed.OutSetlFlag = "0"
  11166. var fopd []*models.FsiOperationDtosData
  11167. data := make(map[string]interface{})
  11168. data["fed"] = fed
  11169. data["fdd"] = fdds
  11170. data["fod"] = orders
  11171. data["pd"] = pd
  11172. data["pp"] = pp
  11173. data["fopd"] = fopd
  11174. data["trig_scen"] = trig_scen
  11175. client := &http.Client{}
  11176. bytesData, _ := json.Marshal(data)
  11177. var req *http.Request
  11178. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11179. if miConfig.MdtrtareaAdmvs == "320921" {
  11180. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11181. } else {
  11182. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11183. }
  11184. resp, _ := client.Do(req)
  11185. defer resp.Body.Close()
  11186. body, ioErr := ioutil.ReadAll(resp.Body)
  11187. if ioErr != nil {
  11188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11190. return res
  11191. }
  11192. var respJSON map[string]interface{}
  11193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11196. return res
  11197. }
  11198. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11199. result, _ := json.Marshal(respJSON)
  11200. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11201. utils.ErrorLog("解析失败:%v", err)
  11202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11203. return res
  11204. }
  11205. return res
  11206. } else {
  11207. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11208. saveLog(output, input, "3102", "事中")
  11209. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11210. utils.ErrorLog("解析失败:%v", err)
  11211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11212. return
  11213. }
  11214. return res
  11215. }
  11216. return res
  11217. }
  11218. func Checkgd3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, de models.XtHisDepartment) (res2 Resultgd3101) {
  11219. var res Resultgd3101
  11220. adminUser := c.GetAdminUserInfo()
  11221. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11222. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11224. //record_time := c.GetString("record_time")
  11225. //trig_scen := c.GetString("trig_scen")
  11226. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11227. //psn_info, _ := service.GetPatientId(patient_id)
  11228. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11229. timeLayout := "2006-01-02"
  11230. loc, _ := time.LoadLocation("Local")
  11231. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11232. if err != nil {
  11233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11234. return res
  11235. }
  11236. recordDateTime := theTime.Unix()
  11237. var patientPrescription models.HisPrescriptionInfo
  11238. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11239. //if patientPrescription.ID == 0 {
  11240. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11241. //}
  11242. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11243. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11244. //
  11245. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11246. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11247. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11248. var pp models.PublicParams
  11249. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11250. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11251. pp.FixmedinsName = miConfig.OrgName
  11252. pp.FixmedinsCode = miConfig.Code
  11253. pp.RequestUrl = miConfig.Url
  11254. pp.Cainfo = miConfig.Cainfo
  11255. pp.SecretKey = miConfig.SecretKey
  11256. pp.AccessKey = miConfig.AccessKey
  11257. pp.OpterName = roles.UserName
  11258. var config []*models.HisXtDiagnoseConfig
  11259. for _, item := range diagnosis_ids {
  11260. id, _ := strconv.ParseInt(item, 10, 64)
  11261. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11262. config = append(config, &diagnosisConfig)
  11263. }
  11264. var pd models.PatientDtos
  11265. pd.PatnID = his.PsnNo
  11266. pd.PatnName = his.Name
  11267. pd.Gend = his.Gend
  11268. pd.Brdy = str
  11269. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11270. pd.CurrMdtrtID = his.Number
  11271. var fed models.FsiEncounterDtos
  11272. fed.MdtrtID = his.Number
  11273. fed.MedinsID = miConfig.Code
  11274. fed.MedinsName = miConfig.OrgName
  11275. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11276. fed.MedMdtrtType = "1"
  11277. fed.MedinsType = "1"
  11278. fed.MedinsLv = "11"
  11279. tm := time.Unix(his.RecordDate, 0)
  11280. s_tm := tm.Format("2006-01-02 15:04:05")
  11281. fed.AdmDate = s_tm
  11282. fed.DscgDate = s_tm
  11283. fed.DscgMainDiseCodg = config[0].CountryCode
  11284. fed.DscgMainDiseName = config[0].CountryContentName
  11285. //诊断信息
  11286. var fdds []*models.FsiDiagnoseDtos
  11287. for index, item := range config {
  11288. if index == 0 {
  11289. var fdd models.FsiDiagnoseDtos
  11290. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11291. fdd.InoutDiseType = "1"
  11292. fdd.MaindiseFlag = "1"
  11293. fdd.DiseDate = s_tm
  11294. fdd.DiasSrtNo = "1"
  11295. fdd.DiseName = item.CountryContentName
  11296. fdd.DiseCodg = item.CountryCode
  11297. fdds = append(fdds, &fdd)
  11298. } else {
  11299. var fdd models.FsiDiagnoseDtos
  11300. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11301. fdd.InoutDiseType = "1"
  11302. fdd.MaindiseFlag = "1"
  11303. fdd.DiseDate = s_tm
  11304. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11305. fdd.DiseName = item.CountryContentName
  11306. fdd.DiseCodg = item.CountryCode
  11307. fdds = append(fdds, &fdd)
  11308. }
  11309. }
  11310. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11311. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11312. fed.AdmDeptName = de.Name
  11313. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11314. fed.DscgDeptName = de.Name
  11315. fed.MedMdtrtType = "1"
  11316. fed.MedType = "11"
  11317. //if his.Insutype == "390" {
  11318. // fed.MedType = "1402"
  11319. //} else {
  11320. // fed.MedType = "9933"
  11321. //}
  11322. var orders []*models.FsiOrderDtos
  11323. if trig_scen == "2" {
  11324. //处方医嘱信息
  11325. for _, item := range prescriptions {
  11326. for _, subItem := range item.HisDoctorAdviceInfo {
  11327. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11328. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11329. var order models.FsiOrderDtos
  11330. order.RxID = strconv.FormatInt(item.ID, 10)
  11331. order.Rxno = strconv.FormatInt(item.ID, 10)
  11332. order.LongDrordFlag = "0"
  11333. order.HilistType = "1"
  11334. order.ChrgType = "1"
  11335. order.DrordBhvr = "0"
  11336. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11337. order.HosplistName = subItem.BaseDrugLib.DrugName
  11338. order.HilistLv = "1"
  11339. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11340. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11341. order.HosplistName = subItem.BaseDrugLib.DrugName
  11342. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11343. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11344. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11345. order.OwnpayAmt = ""
  11346. order.SelfpayAmt = ""
  11347. order.Spec = spec
  11348. order.SpecUnt = subItem.PrescribingNumberUnit
  11349. order.DrordBegnDate = s_tm
  11350. order.DrordStopDate = ""
  11351. order.DrordDrCodg = doctor_info.DoctorNumber
  11352. order.DrordDeptName = department.Name
  11353. order.DrordDeptCodg = department.Number
  11354. order.DrordDrName = doctor_info.UserName
  11355. order.DrordDrProfttl = "234"
  11356. order.CurrDrordFlag = "1"
  11357. orders = append(orders, &order)
  11358. }
  11359. }
  11360. for _, subItem := range item.HisPrescriptionProject {
  11361. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11362. var order models.FsiOrderDtos
  11363. order.RxID = strconv.FormatInt(item.ID, 10)
  11364. order.Rxno = strconv.FormatInt(item.ID, 10)
  11365. order.LongDrordFlag = "0"
  11366. order.HilistType = "1"
  11367. order.ChrgType = "1"
  11368. order.DrordBhvr = "0"
  11369. order.HilistCode = subItem.HisProject.MedicalCode
  11370. order.HosplistName = subItem.HisProject.ProjectName
  11371. order.HilistLv = "1"
  11372. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11373. order.HosplistCode = subItem.HisProject.MedicalCode
  11374. order.HosplistName = subItem.HisProject.ProjectName
  11375. order.Cnt = subItem.Count
  11376. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11377. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11378. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11379. order.OwnpayAmt = ""
  11380. order.SelfpayAmt = ""
  11381. order.Spec = subItem.Unit
  11382. order.SpecUnt = subItem.Unit
  11383. order.DrordBegnDate = s_tm
  11384. order.DrordStopDate = ""
  11385. order.DrordDrCodg = doctor_info.DoctorNumber
  11386. order.DrordDeptName = department.Name
  11387. order.DrordDeptCodg = department.Number
  11388. order.DrordDrName = doctor_info.UserName
  11389. order.DrordDrProfttl = "234"
  11390. order.CurrDrordFlag = "1"
  11391. orders = append(orders, &order)
  11392. }
  11393. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11394. var order models.FsiOrderDtos
  11395. order.RxID = strconv.FormatInt(item.ID, 10)
  11396. order.Rxno = strconv.FormatInt(item.ID, 10)
  11397. order.LongDrordFlag = "0"
  11398. order.HilistType = "1"
  11399. order.ChrgType = "1"
  11400. order.DrordBhvr = "0"
  11401. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11402. order.HosplistName = subItem.GoodInfo.GoodName
  11403. order.HilistLv = "1"
  11404. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11405. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11406. order.HosplistName = subItem.GoodInfo.GoodName
  11407. order.Cnt = subItem.Count
  11408. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11409. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11410. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11411. order.OwnpayAmt = ""
  11412. order.SelfpayAmt = ""
  11413. order.Spec = subItem.GoodInfo.SpecificationName
  11414. order.SpecUnt = subItem.Unit
  11415. order.DrordBegnDate = s_tm
  11416. order.DrordStopDate = ""
  11417. order.DrordDrCodg = doctor_info.DoctorNumber
  11418. order.DrordDeptName = department.Name
  11419. order.DrordDeptCodg = department.Number
  11420. order.DrordDrName = doctor_info.UserName
  11421. order.DrordDrProfttl = "234"
  11422. order.CurrDrordFlag = "1"
  11423. orders = append(orders, &order)
  11424. }
  11425. }
  11426. }
  11427. //处方医嘱信息
  11428. }
  11429. fed.MatnStas = "0"
  11430. fed.MedfeeSumamt = "0"
  11431. fed.OwnpayAmt = "0"
  11432. fed.SelfpayAmt = "0"
  11433. fed.AcctPayamt = "0"
  11434. fed.MaAmt = "0"
  11435. fed.HifpPayamt = "0"
  11436. fed.SetlTotlnum = "1"
  11437. fed.Insutype = his.Insutype
  11438. fed.ReimFlag = "0"
  11439. fed.OutSetlFlag = "0"
  11440. var fopd []*models.FsiOperationDtosData
  11441. data := make(map[string]interface{})
  11442. data["fed"] = fed
  11443. data["fdd"] = fdds
  11444. data["fod"] = orders
  11445. data["pd"] = pd
  11446. data["pp"] = pp
  11447. data["fopd"] = fopd
  11448. data["trig_scen"] = trig_scen
  11449. fmt.Println(data)
  11450. fmt.Println(fed)
  11451. fmt.Println(fdds)
  11452. fmt.Println(orders)
  11453. fmt.Println(pd)
  11454. fmt.Println(pp)
  11455. fmt.Println(fopd)
  11456. client := &http.Client{}
  11457. bytesData, _ := json.Marshal(data)
  11458. var req *http.Request
  11459. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11460. if miConfig.MdtrtareaAdmvs == "320921" {
  11461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11462. } else {
  11463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11464. }
  11465. resp, _ := client.Do(req)
  11466. defer resp.Body.Close()
  11467. body, ioErr := ioutil.ReadAll(resp.Body)
  11468. if ioErr != nil {
  11469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11471. return res
  11472. }
  11473. var respJSON map[string]interface{}
  11474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11477. return res
  11478. }
  11479. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11480. fmt.Println(respJSON)
  11481. result, _ := json.Marshal(respJSON)
  11482. fmt.Println(result)
  11483. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11484. utils.ErrorLog("解析失败:%v", err)
  11485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11486. return res
  11487. }
  11488. return res
  11489. } else {
  11490. //if miConfig.MdtrtareaAdmvs == "441202" {
  11491. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11492. saveLog(output, input, "3101", "事前")
  11493. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11494. utils.ErrorLog("解析失败:%v", err)
  11495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11496. return
  11497. }
  11498. return res
  11499. //}
  11500. }
  11501. }
  11502. func Checkgd3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Resultgd3101) {
  11503. adminUser := c.GetAdminUserInfo()
  11504. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11505. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11506. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11507. //record_time := c.GetString("record_time")
  11508. //trig_scen := c.GetString("trig_scen")
  11509. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11510. timeLayout := "2006-01-02"
  11511. loc, _ := time.LoadLocation("Local")
  11512. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11513. if err != nil {
  11514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11515. return res
  11516. }
  11517. recordDateTime := theTime.Unix()
  11518. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11519. var patientPrescription models.HisPrescriptionInfo
  11520. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11521. if patientPrescription.ID == 0 {
  11522. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11523. }
  11524. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11525. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11526. //
  11527. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11528. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11529. var pp models.PublicParams
  11530. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11531. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11532. pp.FixmedinsName = miConfig.OrgName
  11533. pp.FixmedinsCode = miConfig.Code
  11534. pp.RequestUrl = miConfig.Url
  11535. pp.Cainfo = miConfig.Cainfo
  11536. pp.SecretKey = miConfig.SecretKey
  11537. pp.AccessKey = miConfig.AccessKey
  11538. pp.OpterName = roles.UserName
  11539. var config []*models.HisXtDiagnoseConfig
  11540. for _, item := range diagnosis_ids {
  11541. id, _ := strconv.ParseInt(item, 10, 64)
  11542. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11543. config = append(config, &diagnosisConfig)
  11544. }
  11545. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11546. var pd models.PatientDtos
  11547. pd.PatnID = his.PsnNo
  11548. pd.PatnName = his.Name
  11549. pd.Gend = his.Gend
  11550. pd.Brdy = str
  11551. pd.Poolarea = his.InsuplcAdmdvs
  11552. pd.CurrMdtrtID = his.Number
  11553. var fed models.FsiEncounterDtos
  11554. fed.MdtrtID = his.Number
  11555. fed.MedinsID = miConfig.Code
  11556. fed.MedinsName = miConfig.OrgName
  11557. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11558. fed.MedMdtrtType = "1"
  11559. fed.MedinsType = "1"
  11560. fed.MedinsLv = "11"
  11561. tm := time.Unix(his.RecordDate, 0)
  11562. s_tm := tm.Format("2006-01-02 15:04:05")
  11563. fed.AdmDate = s_tm
  11564. fed.DscgDate = s_tm
  11565. fed.DscgMainDiseCodg = config[0].CountryCode
  11566. fed.DscgMainDiseName = config[0].CountryContentName
  11567. //诊断信息
  11568. var fdds []*models.FsiDiagnoseDtos
  11569. for index, item := range config {
  11570. if index == 0 {
  11571. var fdd models.FsiDiagnoseDtos
  11572. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11573. fdd.InoutDiseType = "1"
  11574. fdd.MaindiseFlag = "1"
  11575. fdd.DiseDate = s_tm
  11576. fdd.DiasSrtNo = "1"
  11577. fdd.DiseName = item.CountryContentName
  11578. fdd.DiseCodg = item.CountryCode
  11579. fdds = append(fdds, &fdd)
  11580. } else {
  11581. var fdd models.FsiDiagnoseDtos
  11582. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11583. fdd.InoutDiseType = "1"
  11584. fdd.MaindiseFlag = "1"
  11585. fdd.DiseDate = s_tm
  11586. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11587. fdd.DiseName = item.CountryContentName
  11588. fdd.DiseCodg = item.CountryCode
  11589. fdds = append(fdds, &fdd)
  11590. }
  11591. }
  11592. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11593. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11594. fed.AdmDeptName = department.Name
  11595. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11596. fed.DscgDeptName = department.Name
  11597. fed.MedMdtrtType = "1"
  11598. fed.MedType = "11"
  11599. //if his.Insutype == "390" {
  11600. // fed.MedType = "1402"
  11601. //} else {
  11602. // fed.MedType = "9933"
  11603. //}
  11604. var orders []*models.FsiOrderDtos
  11605. if trig_scen == "2" {
  11606. //处方医嘱信息
  11607. for _, item := range prescriptions {
  11608. for _, subItem := range item.HisDoctorAdviceInfo {
  11609. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11610. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11611. var order models.FsiOrderDtos
  11612. order.RxID = strconv.FormatInt(item.ID, 10)
  11613. order.Rxno = strconv.FormatInt(item.ID, 10)
  11614. order.LongDrordFlag = "0"
  11615. order.HilistType = "1"
  11616. order.ChrgType = "1"
  11617. order.DrordBhvr = "0"
  11618. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11619. order.HosplistName = subItem.BaseDrugLib.DrugName
  11620. order.HilistLv = "1"
  11621. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11622. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11623. order.HosplistName = subItem.BaseDrugLib.DrugName
  11624. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11626. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11627. order.OwnpayAmt = ""
  11628. order.SelfpayAmt = ""
  11629. order.Spec = spec
  11630. order.SpecUnt = subItem.PrescribingNumberUnit
  11631. order.DrordBegnDate = s_tm
  11632. order.DrordStopDate = ""
  11633. order.DrordDrCodg = doctor_info.DoctorNumber
  11634. order.DrordDeptName = department.Name
  11635. order.DrordDeptCodg = department.Number
  11636. order.DrordDrName = doctor_info.UserName
  11637. order.DrordDrProfttl = "234"
  11638. order.CurrDrordFlag = "1"
  11639. orders = append(orders, &order)
  11640. }
  11641. }
  11642. for _, subItem := range item.HisPrescriptionProject {
  11643. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11644. var order models.FsiOrderDtos
  11645. order.RxID = strconv.FormatInt(item.ID, 10)
  11646. order.Rxno = strconv.FormatInt(item.ID, 10)
  11647. order.LongDrordFlag = "0"
  11648. order.HilistType = "1"
  11649. order.ChrgType = "1"
  11650. order.DrordBhvr = "0"
  11651. order.HilistCode = subItem.HisProject.MedicalCode
  11652. order.HosplistName = subItem.HisProject.ProjectName
  11653. order.HilistLv = "1"
  11654. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11655. order.HosplistCode = subItem.HisProject.MedicalCode
  11656. order.HosplistName = subItem.HisProject.ProjectName
  11657. order.Cnt = subItem.Count
  11658. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11659. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11660. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11661. order.OwnpayAmt = ""
  11662. order.SelfpayAmt = ""
  11663. order.Spec = subItem.Unit
  11664. order.SpecUnt = subItem.Unit
  11665. order.DrordBegnDate = s_tm
  11666. order.DrordStopDate = ""
  11667. order.DrordDrCodg = doctor_info.DoctorNumber
  11668. order.DrordDeptName = department.Name
  11669. order.DrordDeptCodg = department.Number
  11670. order.DrordDrName = doctor_info.UserName
  11671. order.DrordDrProfttl = "234"
  11672. order.CurrDrordFlag = "1"
  11673. orders = append(orders, &order)
  11674. }
  11675. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11676. var order models.FsiOrderDtos
  11677. order.RxID = strconv.FormatInt(item.ID, 10)
  11678. order.Rxno = strconv.FormatInt(item.ID, 10)
  11679. order.LongDrordFlag = "0"
  11680. order.HilistType = "1"
  11681. order.ChrgType = "1"
  11682. order.DrordBhvr = "0"
  11683. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11684. order.HosplistName = subItem.GoodInfo.GoodName
  11685. order.HilistLv = "1"
  11686. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11687. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11688. order.HosplistName = subItem.GoodInfo.GoodName
  11689. order.Cnt = subItem.Count
  11690. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11692. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11693. order.OwnpayAmt = ""
  11694. order.SelfpayAmt = ""
  11695. order.Spec = subItem.GoodInfo.SpecificationName
  11696. order.SpecUnt = subItem.Unit
  11697. order.DrordBegnDate = s_tm
  11698. order.DrordStopDate = ""
  11699. order.DrordDrCodg = doctor_info.DoctorNumber
  11700. order.DrordDeptName = department.Name
  11701. order.DrordDeptCodg = department.Number
  11702. order.DrordDrName = doctor_info.UserName
  11703. order.DrordDrProfttl = "234"
  11704. order.CurrDrordFlag = "1"
  11705. orders = append(orders, &order)
  11706. }
  11707. }
  11708. }
  11709. //处方医嘱信息
  11710. }
  11711. fed.MatnStas = "0"
  11712. fed.MedfeeSumamt = "0"
  11713. fed.OwnpayAmt = "0"
  11714. fed.SelfpayAmt = "0"
  11715. fed.AcctPayamt = "0"
  11716. fed.MaAmt = "0"
  11717. fed.HifpPayamt = "0"
  11718. fed.SetlTotlnum = "1"
  11719. fed.Insutype = his.Insutype
  11720. fed.ReimFlag = "0"
  11721. fed.OutSetlFlag = "0"
  11722. var fopd []*models.FsiOperationDtosData
  11723. data := make(map[string]interface{})
  11724. data["fed"] = fed
  11725. data["fdd"] = fdds
  11726. data["fod"] = orders
  11727. data["pd"] = pd
  11728. data["pp"] = pp
  11729. data["fopd"] = fopd
  11730. data["trig_scen"] = trig_scen
  11731. fmt.Println(data)
  11732. fmt.Println(fed)
  11733. fmt.Println(fdds)
  11734. fmt.Println(orders)
  11735. fmt.Println(pd)
  11736. fmt.Println(pp)
  11737. fmt.Println(fopd)
  11738. client := &http.Client{}
  11739. bytesData, _ := json.Marshal(data)
  11740. var req *http.Request
  11741. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11742. if miConfig.MdtrtareaAdmvs == "320921" {
  11743. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11744. } else {
  11745. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11746. }
  11747. resp, _ := client.Do(req)
  11748. defer resp.Body.Close()
  11749. body, ioErr := ioutil.ReadAll(resp.Body)
  11750. if ioErr != nil {
  11751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11753. return res
  11754. }
  11755. var respJSON map[string]interface{}
  11756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11759. return res
  11760. }
  11761. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11762. fmt.Println(respJSON)
  11763. result, _ := json.Marshal(respJSON)
  11764. fmt.Println(result)
  11765. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11766. utils.ErrorLog("解析失败:%v", err)
  11767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11768. return res
  11769. }
  11770. return res
  11771. } else {
  11772. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11773. saveLog(output, input, "3101", "事前")
  11774. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11775. utils.ErrorLog("解析失败:%v", err)
  11776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11777. return
  11778. }
  11779. return res
  11780. }
  11781. return res
  11782. }
  11783. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11784. adminUser := c.GetAdminUserInfo()
  11785. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11786. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11787. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11788. record_time := c.GetString("record_time")
  11789. order, _ := service.GetHisOrderByID(order_id)
  11790. timeLayout := "2006-01-02"
  11791. loc, _ := time.LoadLocation("Local")
  11792. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11793. if err != nil {
  11794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11795. return
  11796. }
  11797. recordDateTime := theTime.Unix()
  11798. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11799. var patientPrescription models.HisPrescriptionInfo
  11800. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11801. if patientPrescription.ID == 0 {
  11802. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11803. }
  11804. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11805. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11806. //
  11807. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11808. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11809. var pp models.PublicParams
  11810. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11811. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11812. pp.FixmedinsName = miConfig.OrgName
  11813. pp.FixmedinsCode = miConfig.Code
  11814. pp.RequestUrl = miConfig.Url
  11815. pp.Cainfo = miConfig.Cainfo
  11816. pp.SecretKey = miConfig.SecretKey
  11817. pp.AccessKey = miConfig.AccessKey
  11818. pp.OpterName = roles.UserName
  11819. var config []*models.HisXtDiagnoseConfig
  11820. for _, item := range diagnosis_ids {
  11821. id, _ := strconv.ParseInt(item, 10, 64)
  11822. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11823. config = append(config, &diagnosisConfig)
  11824. }
  11825. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11826. var pd models.PatientDtos
  11827. pd.PatnID = his.PsnNo
  11828. pd.PatnName = his.Name
  11829. pd.Gend = his.Gend
  11830. pd.Brdy = str
  11831. pd.Poolarea = his.InsuplcAdmdvs
  11832. pd.CurrMdtrtID = his.Number
  11833. var fed models.FsiEncounterDtos
  11834. fed.MdtrtID = his.Number
  11835. fed.MedinsID = miConfig.Code
  11836. fed.MedinsName = miConfig.OrgName
  11837. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11838. fed.MedMdtrtType = "1"
  11839. fed.MedinsType = "1"
  11840. fed.MedinsLv = "11"
  11841. tm := time.Unix(his.RecordDate, 0)
  11842. s_tm := tm.Format("2006-01-02 15:04:05")
  11843. fed.AdmDate = s_tm
  11844. fed.DscgDate = s_tm
  11845. fed.DscgMainDiseCodg = config[0].CountryCode
  11846. fed.DscgMainDiseName = config[0].CountryContentName
  11847. //诊断信息
  11848. var fdds []*models.FsiDiagnoseDtos
  11849. for index, item := range config {
  11850. if index == 0 {
  11851. var fdd models.FsiDiagnoseDtos
  11852. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11853. fdd.InoutDiseType = "1"
  11854. fdd.MaindiseFlag = "1"
  11855. fdd.DiseDate = s_tm
  11856. fdd.DiasSrtNo = "1"
  11857. fdd.DiseName = item.CountryContentName
  11858. fdd.DiseCodg = item.CountryCode
  11859. fdds = append(fdds, &fdd)
  11860. } else {
  11861. var fdd models.FsiDiagnoseDtos
  11862. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11863. fdd.InoutDiseType = "1"
  11864. fdd.MaindiseFlag = "1"
  11865. fdd.DiseDate = s_tm
  11866. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11867. fdd.DiseName = item.CountryContentName
  11868. fdd.DiseCodg = item.CountryCode
  11869. fdds = append(fdds, &fdd)
  11870. }
  11871. }
  11872. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11873. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11874. fed.AdmDeptName = department.Name
  11875. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11876. fed.DscgDeptName = department.Name
  11877. fed.MedType = order.MedType
  11878. //处方医嘱信息
  11879. var orders []*models.FsiOrderDtos
  11880. //for _, item := range prescriptions {
  11881. // for _, subItem := range item.HisDoctorAdviceInfo {
  11882. // var order models.FsiOrderDtos
  11883. // order.RxID = strconv.FormatInt(item.ID, 10)
  11884. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11885. // order.LongDrordFlag = "0"
  11886. // order.HilistType = "1"
  11887. // order.ChrgType = "1"
  11888. // order.DrordBhvr = "-"
  11889. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11890. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11891. // order.HilistLv = "1"
  11892. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11893. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11894. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11895. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11896. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11897. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11898. // order.OwnpayAmt = ""
  11899. // order.SelfpayAmt = ""
  11900. // order.Spec = ""
  11901. // order.SpecUnt = ""
  11902. // order.DrordBegnDate = s_tm
  11903. // order.DrordStopDate = ""
  11904. // order.DrordDrCodg = "1"
  11905. // order.DrordDeptName = department.Name
  11906. // order.DrordDrCodg = "1"
  11907. // order.DrordDrName = doctor_info.UserName
  11908. // order.DrordDrProfttl = ""
  11909. // order.CurrDrordFlag = "1"
  11910. // orders = append(orders, &order)
  11911. // }
  11912. // for _, subItem := range item.HisPrescriptionProject {
  11913. // if subItem.Type == 2 {
  11914. // var order models.FsiOrderDtos
  11915. // order.RxID = strconv.FormatInt(item.ID, 10)
  11916. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11917. // order.LongDrordFlag = "0"
  11918. // order.HilistType = "1"
  11919. // order.ChrgType = "1"
  11920. // order.DrordBhvr = "-"
  11921. // order.HilistCode = subItem.HisProject.MedicalCode
  11922. // order.HosplistName = subItem.HisProject.ProjectName
  11923. // order.HilistLv = "1"
  11924. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11925. // order.HosplistCode = subItem.HisProject.MedicalCode
  11926. // order.HosplistName = subItem.HisProject.ProjectName
  11927. // order.Cnt = subItem.Count
  11928. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11929. //
  11930. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11931. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11932. // order.OwnpayAmt = ""
  11933. // order.SelfpayAmt = ""
  11934. // order.Spec = ""
  11935. // order.SpecUnt = ""
  11936. // order.DrordBegnDate = s_tm
  11937. // order.DrordStopDate = ""
  11938. // order.DrordDrCodg = "1"
  11939. // order.DrordDeptName = department.Name
  11940. // order.DrordDrCodg = "1"
  11941. // order.DrordDrName = doctor_info.UserName
  11942. // order.DrordDrProfttl = ""
  11943. // order.CurrDrordFlag = "1"
  11944. // orders = append(orders, &order)
  11945. //
  11946. // }
  11947. // if subItem.Type == 3 {
  11948. //
  11949. // var order models.FsiOrderDtos
  11950. // order.RxID = strconv.FormatInt(item.ID, 10)
  11951. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11952. // order.LongDrordFlag = "0"
  11953. // order.HilistType = "1"
  11954. // order.ChrgType = "1"
  11955. // order.DrordBhvr = "-"
  11956. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11957. // order.HosplistName = subItem.GoodInfo.GoodName
  11958. // order.HilistLv = "1"
  11959. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11960. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11961. // order.HosplistName = subItem.GoodInfo.GoodName
  11962. // order.Cnt = subItem.Count
  11963. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11964. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11965. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11966. // order.OwnpayAmt = ""
  11967. // order.SelfpayAmt = ""
  11968. // order.Spec = ""
  11969. // order.SpecUnt = ""
  11970. // order.DrordBegnDate = s_tm
  11971. // order.DrordStopDate = ""
  11972. // order.DrordDrCodg = "1"
  11973. // order.DrordDeptName = department.Name
  11974. // order.DrordDrCodg = "1"
  11975. // order.DrordDrName = doctor_info.UserName
  11976. // order.DrordDrProfttl = ""
  11977. // order.CurrDrordFlag = "1"
  11978. // orders = append(orders, &order)
  11979. //
  11980. // }
  11981. // }
  11982. //}
  11983. for _, item := range prescriptions {
  11984. for _, subItem := range item.HisDoctorAdviceInfo {
  11985. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11986. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11987. var order models.FsiOrderDtos
  11988. order.RxID = strconv.FormatInt(item.ID, 10)
  11989. order.Rxno = strconv.FormatInt(item.ID, 10)
  11990. order.LongDrordFlag = "0"
  11991. order.HilistType = "1"
  11992. order.ChrgType = "1"
  11993. order.DrordBhvr = "0"
  11994. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11995. order.HosplistName = subItem.BaseDrugLib.DrugName
  11996. order.HilistLv = "1"
  11997. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11998. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11999. order.HosplistName = subItem.BaseDrugLib.DrugName
  12000. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12001. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12002. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12003. order.OwnpayAmt = ""
  12004. order.SelfpayAmt = ""
  12005. order.Spec = spec
  12006. order.SpecUnt = subItem.PrescribingNumberUnit
  12007. order.DrordBegnDate = s_tm
  12008. order.DrordStopDate = ""
  12009. order.DrordDrCodg = doctor_info.DoctorNumber
  12010. order.DrordDeptName = department.Name
  12011. order.DrordDeptCodg = department.Number
  12012. order.DrordDrName = doctor_info.UserName
  12013. order.DrordDrProfttl = "234"
  12014. order.CurrDrordFlag = "1"
  12015. orders = append(orders, &order)
  12016. }
  12017. }
  12018. for _, subItem := range item.HisPrescriptionProject {
  12019. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12020. var order models.FsiOrderDtos
  12021. order.RxID = strconv.FormatInt(item.ID, 10)
  12022. order.Rxno = strconv.FormatInt(item.ID, 10)
  12023. order.LongDrordFlag = "0"
  12024. order.HilistType = "1"
  12025. order.ChrgType = "1"
  12026. order.DrordBhvr = "0"
  12027. order.HilistCode = subItem.HisProject.MedicalCode
  12028. order.HosplistName = subItem.HisProject.ProjectName
  12029. order.HilistLv = "1"
  12030. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12031. order.HosplistCode = subItem.HisProject.MedicalCode
  12032. order.HosplistName = subItem.HisProject.ProjectName
  12033. order.Cnt = subItem.Count
  12034. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12035. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12036. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12037. order.OwnpayAmt = ""
  12038. order.SelfpayAmt = ""
  12039. order.Spec = subItem.Unit
  12040. order.SpecUnt = subItem.Unit
  12041. order.DrordBegnDate = s_tm
  12042. order.DrordStopDate = ""
  12043. order.DrordDrCodg = doctor_info.DoctorNumber
  12044. order.DrordDeptName = department.Name
  12045. order.DrordDeptCodg = department.Number
  12046. order.DrordDrName = doctor_info.UserName
  12047. order.DrordDrProfttl = "234"
  12048. order.CurrDrordFlag = "1"
  12049. orders = append(orders, &order)
  12050. }
  12051. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12052. var order models.FsiOrderDtos
  12053. order.RxID = strconv.FormatInt(item.ID, 10)
  12054. order.Rxno = strconv.FormatInt(item.ID, 10)
  12055. order.LongDrordFlag = "0"
  12056. order.HilistType = "1"
  12057. order.ChrgType = "1"
  12058. order.DrordBhvr = "0"
  12059. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12060. order.HosplistName = subItem.GoodInfo.GoodName
  12061. order.HilistLv = "1"
  12062. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12063. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12064. order.HosplistName = subItem.GoodInfo.GoodName
  12065. order.Cnt = subItem.Count
  12066. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12067. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12068. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12069. order.OwnpayAmt = ""
  12070. order.SelfpayAmt = ""
  12071. order.Spec = subItem.GoodInfo.SpecificationName
  12072. order.SpecUnt = subItem.Unit
  12073. order.DrordBegnDate = s_tm
  12074. order.DrordStopDate = ""
  12075. order.DrordDrCodg = doctor_info.DoctorNumber
  12076. order.DrordDeptName = department.Name
  12077. order.DrordDeptCodg = department.Number
  12078. order.DrordDrName = doctor_info.UserName
  12079. order.DrordDrProfttl = "234"
  12080. order.CurrDrordFlag = "1"
  12081. orders = append(orders, &order)
  12082. }
  12083. }
  12084. }
  12085. //处方医嘱信息
  12086. fed.MatnStas = "0"
  12087. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12088. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12089. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12090. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12091. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12092. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12093. fed.SetlTotlnum = "1"
  12094. fed.Insutype = his.Insutype
  12095. fed.ReimFlag = "0"
  12096. fed.OutSetlFlag = "0"
  12097. var fopd []*models.FsiOperationDtosData
  12098. data := make(map[string]interface{})
  12099. data["fed"] = fed
  12100. data["fdd"] = fdds
  12101. data["fod"] = orders
  12102. data["pd"] = pd
  12103. data["pp"] = pp
  12104. data["fopd"] = fopd
  12105. data["trig_scen"] = trig_scen
  12106. client := &http.Client{}
  12107. bytesData, _ := json.Marshal(data)
  12108. var req *http.Request
  12109. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12110. if miConfig.MdtrtareaAdmvs == "320921" {
  12111. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12112. } else {
  12113. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12114. }
  12115. resp, _ := client.Do(req)
  12116. defer resp.Body.Close()
  12117. body, ioErr := ioutil.ReadAll(resp.Body)
  12118. if ioErr != nil {
  12119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12121. return res
  12122. }
  12123. var respJSON map[string]interface{}
  12124. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12127. return res
  12128. }
  12129. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12130. result, _ := json.Marshal(respJSON)
  12131. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12132. utils.ErrorLog("解析失败:%v", err)
  12133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12134. return res
  12135. }
  12136. return res
  12137. } else {
  12138. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12139. saveLog(output, input, "3102", "事中")
  12140. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12141. utils.ErrorLog("解析失败:%v", err)
  12142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12143. return
  12144. }
  12145. return res
  12146. }
  12147. return res
  12148. }
  12149. func (c *HisApiController) Check() {
  12150. psn_no := c.GetString("psn_no")
  12151. in := c.GetString("in")
  12152. mt := c.GetString("mt")
  12153. baseParams := models.BaseParams{
  12154. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12155. FixmedinsCode: "H15049901371",
  12156. InsuplcAdmdvs: "150499",
  12157. MdtrtareaAdmvs: "150499",
  12158. OrgName: "赤峰费森血液透析中心",
  12159. Doctor: "1111",
  12160. }
  12161. service.Gdyb2001(baseParams, psn_no, in, mt)
  12162. }
  12163. func (c *HisApiController) GetPsnNcdsInfo() {
  12164. admin_user_id, _ := c.GetInt64("admin_user_id")
  12165. patient_id, _ := c.GetInt64("patient_id")
  12166. //id, _ := c.GetInt64("id")
  12167. adminUser := c.GetAdminUserInfo()
  12168. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12169. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12170. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12171. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12172. //psn_record, _ := service.GetP(id)
  12173. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12174. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12175. //
  12176. //if psn_record.ID == 0 {
  12177. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12178. // return
  12179. //}
  12180. var res Result5301
  12181. var res10265 Result5301For10265
  12182. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12183. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12184. var api string
  12185. if miConfig.MdtrtareaAdmvs == "320921" {
  12186. 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 +
  12187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12188. } else {
  12189. 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 +
  12190. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12191. }
  12192. resp, requestErr := http.Get(api)
  12193. if requestErr != nil {
  12194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12195. return
  12196. }
  12197. body, ioErr := ioutil.ReadAll(resp.Body)
  12198. if ioErr != nil {
  12199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12201. return
  12202. }
  12203. var respJSON map[string]interface{}
  12204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12207. return
  12208. }
  12209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12210. result, _ := json.Marshal(respJSON)
  12211. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12212. utils.ErrorLog("解析失败:%v", err)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return
  12215. }
  12216. res.ErrMsg = res10265.ErrMsg
  12217. res.Output = res10265.Output
  12218. res.InfRefmsgid = res10265.InfRefmsgid
  12219. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12220. res.Infcode = infocode
  12221. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12222. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12223. var api string
  12224. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12225. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12226. resp, requestErr := http.Get(api)
  12227. if requestErr != nil {
  12228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12229. return
  12230. }
  12231. body, ioErr := ioutil.ReadAll(resp.Body)
  12232. if ioErr != nil {
  12233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12235. return
  12236. }
  12237. var respJSON map[string]interface{}
  12238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. return
  12242. }
  12243. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12244. if status == "0" {
  12245. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12246. c.ServeSuccessJSON(map[string]interface{}{
  12247. "failed_code": -10,
  12248. "msg": err_msg,
  12249. })
  12250. return
  12251. }
  12252. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12253. result, _ := json.Marshal(respJSON)
  12254. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12255. utils.ErrorLog("解析失败:%v", err)
  12256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12257. return
  12258. }
  12259. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12260. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12261. var api string
  12262. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12263. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12264. resp, requestErr := http.Get(api)
  12265. if requestErr != nil {
  12266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12267. return
  12268. }
  12269. body, ioErr := ioutil.ReadAll(resp.Body)
  12270. if ioErr != nil {
  12271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12273. return
  12274. }
  12275. var respJSON map[string]interface{}
  12276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12279. return
  12280. }
  12281. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12282. if status == "0" {
  12283. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12284. c.ServeSuccessJSON(map[string]interface{}{
  12285. "failed_code": -10,
  12286. "msg": err_msg,
  12287. })
  12288. return
  12289. }
  12290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12291. result, _ := json.Marshal(respJSON)
  12292. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12293. utils.ErrorLog("解析失败:%v", err)
  12294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12295. return
  12296. }
  12297. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12298. p, _ := service.GetHisPatientById(patient_id)
  12299. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12300. var dat map[string]interface{}
  12301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12302. fmt.Println(dat)
  12303. } else {
  12304. fmt.Println(err)
  12305. }
  12306. userJSONBytes, _ := json.Marshal(dat)
  12307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12308. utils.ErrorLog("解析失败:%v", err)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12313. p, _ := service.GetHisPatientById(patient_id)
  12314. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12315. var dat map[string]interface{}
  12316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12317. fmt.Println(dat)
  12318. } else {
  12319. fmt.Println(err)
  12320. }
  12321. userJSONBytes, _ := json.Marshal(dat)
  12322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12323. utils.ErrorLog("解析失败:%v", err)
  12324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12325. return
  12326. }
  12327. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12328. p, _ := service.GetHisPatientById(patient_id)
  12329. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12330. var dat map[string]interface{}
  12331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12332. fmt.Println(dat)
  12333. } else {
  12334. fmt.Println(err)
  12335. }
  12336. userJSONBytes, _ := json.Marshal(dat)
  12337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12338. utils.ErrorLog("解析失败:%v", err)
  12339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12340. return
  12341. }
  12342. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12343. p, _ := service.GetHisPatientById(patient_id)
  12344. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12345. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12347. resp, requestErr := http.Get(api)
  12348. if requestErr != nil {
  12349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12350. return
  12351. }
  12352. body, ioErr := ioutil.ReadAll(resp.Body)
  12353. if ioErr != nil {
  12354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12356. return
  12357. }
  12358. var respJSON map[string]interface{}
  12359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12362. return
  12363. }
  12364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12365. result, _ := json.Marshal(respJSON)
  12366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12367. utils.ErrorLog("解析失败:%v", err)
  12368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12369. return
  12370. }
  12371. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12372. p, _ := service.GetHisPatientById(patient_id)
  12373. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12374. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12375. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12376. resp, requestErr := http.Get(api)
  12377. if requestErr != nil {
  12378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12379. return
  12380. }
  12381. body, ioErr := ioutil.ReadAll(resp.Body)
  12382. if ioErr != nil {
  12383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12385. return
  12386. }
  12387. var respJSON map[string]interface{}
  12388. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12391. return
  12392. }
  12393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12394. result, _ := json.Marshal(respJSON)
  12395. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12396. utils.ErrorLog("解析失败:%v", err)
  12397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12398. return
  12399. }
  12400. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12401. p, _ := service.GetHisPatientById(patient_id)
  12402. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12403. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12404. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12405. resp, requestErr := http.Get(api)
  12406. if requestErr != nil {
  12407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12408. return
  12409. }
  12410. body, ioErr := ioutil.ReadAll(resp.Body)
  12411. if ioErr != nil {
  12412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12414. return
  12415. }
  12416. var respJSON map[string]interface{}
  12417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12420. return
  12421. }
  12422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12423. result, _ := json.Marshal(respJSON)
  12424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12425. utils.ErrorLog("解析失败:%v", err)
  12426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12427. return
  12428. }
  12429. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12430. p, _ := service.GetHisPatientById(patient_id)
  12431. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12432. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12433. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12434. resp, requestErr := http.Get(api)
  12435. if requestErr != nil {
  12436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12437. return
  12438. }
  12439. body, ioErr := ioutil.ReadAll(resp.Body)
  12440. if ioErr != nil {
  12441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12443. return
  12444. }
  12445. var respJSON map[string]interface{}
  12446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12449. return
  12450. }
  12451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12452. result, _ := json.Marshal(respJSON)
  12453. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12454. utils.ErrorLog("解析失败:%v", err)
  12455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12456. return
  12457. }
  12458. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12459. p, _ := service.GetHisPatientById(patient_id)
  12460. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12461. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12462. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12463. resp, requestErr := http.Get(api)
  12464. if requestErr != nil {
  12465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12466. return
  12467. }
  12468. body, ioErr := ioutil.ReadAll(resp.Body)
  12469. if ioErr != nil {
  12470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12472. return
  12473. }
  12474. var respJSON map[string]interface{}
  12475. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12478. return
  12479. }
  12480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12481. result, _ := json.Marshal(respJSON)
  12482. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12483. utils.ErrorLog("解析失败:%v", err)
  12484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12485. return
  12486. }
  12487. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12488. p, _ := service.GetHisPatientById(patient_id)
  12489. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12490. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12491. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12492. resp, requestErr := http.Get(api)
  12493. if requestErr != nil {
  12494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12495. return
  12496. }
  12497. body, ioErr := ioutil.ReadAll(resp.Body)
  12498. if ioErr != nil {
  12499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12501. return
  12502. }
  12503. var respJSON map[string]interface{}
  12504. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12507. return
  12508. }
  12509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12510. result, _ := json.Marshal(respJSON)
  12511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12512. utils.ErrorLog("解析失败:%v", err)
  12513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12514. return
  12515. }
  12516. } else {
  12517. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12518. var dat map[string]interface{}
  12519. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12520. fmt.Println(dat)
  12521. } else {
  12522. fmt.Println(err)
  12523. }
  12524. userJSONBytes, _ := json.Marshal(dat)
  12525. if miConfig.Code == "H15049901371" {
  12526. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12527. utils.ErrorLog("解析失败:%v", err)
  12528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12529. return
  12530. }
  12531. res.InfRefmsgid = res10265.InfRefmsgid
  12532. res.Output = res10265.Output
  12533. res.ErrMsg = res10265.ErrMsg
  12534. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12535. res.Infcode = infocode
  12536. } else {
  12537. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12538. utils.ErrorLog("解析失败:%v", err)
  12539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12540. return
  12541. }
  12542. }
  12543. }
  12544. if res.Infcode == 0 {
  12545. c.ServeSuccessJSON(map[string]interface{}{
  12546. "result": res.Output.Result,
  12547. })
  12548. }
  12549. }
  12550. func (c *HisApiController) CheckInsutype() {
  12551. his_patient_id, _ := c.GetInt64("his_patient_id")
  12552. admin_user_id, _ := c.GetInt64("admin_user_id")
  12553. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12554. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12556. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12557. var dat map[string]interface{}
  12558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12559. fmt.Println(dat)
  12560. } else {
  12561. fmt.Println(err)
  12562. }
  12563. userJSONBytes, _ := json.Marshal(dat)
  12564. var res Result90100
  12565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12566. utils.ErrorLog("解析失败:%v", err)
  12567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12568. return
  12569. }
  12570. if res.Infcode != 0 {
  12571. c.ServeSuccessJSON(map[string]interface{}{
  12572. "failed_code": -10,
  12573. "msg": res.ErrMsg,
  12574. })
  12575. return
  12576. } else {
  12577. fmt.Println(res)
  12578. }
  12579. }
  12580. func (c *HisApiController) CheckCardPWD() {
  12581. card_pwd := c.GetString("card_pwd")
  12582. his_patient_id, _ := c.GetInt64("his_patient_id")
  12583. admin_user_id, _ := c.GetInt64("admin_user_id")
  12584. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12586. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12587. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12588. bas := strings.Split(psn.CardInfo, "|")
  12589. basNumber := bas[2]
  12590. if psn.InsuplcAdmdvs[:4] == "4403" {
  12591. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12592. var dat map[string]interface{}
  12593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12594. fmt.Println(dat)
  12595. } else {
  12596. fmt.Println(err)
  12597. }
  12598. userJSONBytes, _ := json.Marshal(dat)
  12599. var res Result90991
  12600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12601. utils.ErrorLog("解析失败:%v", err)
  12602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12603. return
  12604. }
  12605. if res.Infcode != 0 {
  12606. c.ServeSuccessJSON(map[string]interface{}{
  12607. "failed_code": -10,
  12608. "msg": res.ErrMsg,
  12609. })
  12610. return
  12611. } else {
  12612. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12613. var msg string
  12614. switch res.Output.Result.CardStat {
  12615. case "00":
  12616. msg = "未激活"
  12617. break
  12618. case "10":
  12619. msg = "激活"
  12620. break
  12621. case "20":
  12622. msg = "窗口挂失"
  12623. break
  12624. case "21":
  12625. msg = "电话挂失"
  12626. break
  12627. case "22":
  12628. msg = "单位网上申报挂失"
  12629. break
  12630. case "23":
  12631. msg = "保健办挂失"
  12632. break
  12633. case "24":
  12634. msg = "个人网上挂失"
  12635. break
  12636. case "25":
  12637. msg = "网上服务大厅挂失"
  12638. break
  12639. case "30":
  12640. msg = "注销"
  12641. break
  12642. case "40":
  12643. msg = "回收"
  12644. break
  12645. case "99":
  12646. msg = "制卡中(无效卡)"
  12647. break
  12648. }
  12649. c.ServeSuccessJSON(map[string]interface{}{
  12650. "failed_code": -10,
  12651. "msg": msg,
  12652. })
  12653. return
  12654. } else {
  12655. c.ServeSuccessJSON(map[string]interface{}{
  12656. "msg": "校验成功",
  12657. })
  12658. return
  12659. }
  12660. }
  12661. } else {
  12662. c.ServeSuccessJSON(map[string]interface{}{
  12663. "msg": "校验成功",
  12664. })
  12665. return
  12666. }
  12667. }
  12668. func (c *HisApiController) CheckCardPWDTwo() {
  12669. //card_pwd := c.GetString("card_pwd")
  12670. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12671. admin_user_id, _ := c.GetInt64("admin_user_id")
  12672. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12673. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12674. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12675. var dat map[string]interface{}
  12676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12677. fmt.Println(dat)
  12678. } else {
  12679. fmt.Println(err)
  12680. }
  12681. userJSONBytes, _ := json.Marshal(dat)
  12682. var res Result90991
  12683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12684. utils.ErrorLog("解析失败:%v", err)
  12685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12686. return
  12687. }
  12688. if res.Infcode != 0 {
  12689. c.ServeSuccessJSON(map[string]interface{}{
  12690. "failed_code": -10,
  12691. "msg": res.ErrMsg,
  12692. })
  12693. return
  12694. } else {
  12695. if res.Output.Result.SscnoCheckStat == "0" {
  12696. var msg string
  12697. switch res.Output.Result.CardStat {
  12698. case "00":
  12699. msg = "未激活"
  12700. break
  12701. case "10":
  12702. msg = "激活"
  12703. break
  12704. case "20":
  12705. msg = "窗口挂失"
  12706. break
  12707. case "21":
  12708. msg = "电话挂失"
  12709. break
  12710. case "22":
  12711. msg = "单位网上申报挂失"
  12712. break
  12713. case "23":
  12714. msg = "保健办挂失"
  12715. break
  12716. case "24":
  12717. msg = "个人网上挂失"
  12718. break
  12719. case "25":
  12720. msg = "网上服务大厅挂失"
  12721. break
  12722. case "30":
  12723. msg = "注销"
  12724. break
  12725. case "40":
  12726. msg = "回收"
  12727. break
  12728. case "99":
  12729. msg = "制卡中(无效卡)"
  12730. break
  12731. }
  12732. c.ServeSuccessJSON(map[string]interface{}{
  12733. "failed_code": -10,
  12734. "msg": msg,
  12735. })
  12736. return
  12737. } else {
  12738. c.ServeSuccessJSON(map[string]interface{}{
  12739. "msg": "校验成功",
  12740. })
  12741. return
  12742. }
  12743. }
  12744. }
  12745. type ELeCertData struct {
  12746. Data struct {
  12747. Extra string `json:"extra"`
  12748. IDNo string `json:"idNo"`
  12749. IDType string `json:"idType"`
  12750. EcToken string `json:"ecToken"`
  12751. InsuOrg string `json:"insuOrg"`
  12752. UserName string `json:"userName"`
  12753. EcIndexNo string `json:"ecIndexNo"`
  12754. Gender string `json:"gender"`
  12755. Birthday string `json:"birthday"`
  12756. Nationality string `json:"nationality"`
  12757. Email string `json:"email"`
  12758. } `json:"OutData"`
  12759. }
  12760. func (c *HisApiController) ReadCard() {
  12761. id_card_type, _ := c.GetInt64("id_card_type")
  12762. admin_user_id, _ := c.GetInt64("admin_user_id")
  12763. certificates, _ := c.GetInt64("certificates")
  12764. //
  12765. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12766. id_card_no := c.GetString("id_card_no")
  12767. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12768. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12769. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12770. switch id_card_type {
  12771. case 1:
  12772. if miConfig.MdtrtareaAdmvs == "421300" {
  12773. var res ResultTwo
  12774. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12775. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12776. "&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)
  12777. resp, requestErr := http.Get(api)
  12778. if requestErr != nil {
  12779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12780. return
  12781. }
  12782. body, ioErr := ioutil.ReadAll(resp.Body)
  12783. if ioErr != nil {
  12784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12786. return
  12787. }
  12788. var respJSON map[string]interface{}
  12789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12792. return
  12793. }
  12794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12795. result, _ := json.Marshal(respJSON)
  12796. fmt.Println("log")
  12797. fmt.Println(string(result))
  12798. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12799. utils.ErrorLog("解析失败:%v", err)
  12800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12801. return
  12802. }
  12803. if res.Infcode == 0 {
  12804. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12805. if err == gorm.ErrRecordNotFound {
  12806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12807. return
  12808. } else if err != nil {
  12809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12810. return
  12811. } else {
  12812. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12813. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12814. infoStr := string(Iinfos)
  12815. idetinfoStr := string(Idetinfos)
  12816. var rf []*ResultFive
  12817. json.Unmarshal([]byte(infoStr), &rf)
  12818. var insutypes []*ResultFive
  12819. var insutype string
  12820. var is390 int = 0
  12821. var is310 int = 0
  12822. for _, item := range rf {
  12823. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12824. insutypes = append(insutypes, item)
  12825. }
  12826. }
  12827. if len(insutypes) == 1 {
  12828. insutype = insutypes[0].Insutype
  12829. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12830. } else {
  12831. for _, i := range insutypes {
  12832. if i.Insutype == "390" {
  12833. is390 = 1
  12834. }
  12835. if i.Insutype == "310" {
  12836. is310 = 1
  12837. }
  12838. }
  12839. }
  12840. if is390 == 1 {
  12841. insutype = "390"
  12842. }
  12843. if is310 == 1 {
  12844. insutype = "310"
  12845. }
  12846. if len(insutypes) == 0 {
  12847. insutype = "390"
  12848. }
  12849. var insuplc_admdvs string
  12850. for _, item := range rf {
  12851. if item.Insutype == insutype {
  12852. insuplc_admdvs = item.InsuplcAdmdvs
  12853. }
  12854. }
  12855. if strings.Contains(insuplc_admdvs, "4213") {
  12856. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12857. }
  12858. psn := &models.HisPsn{
  12859. PsnNo: res.Output.Baseinfo.PsnNo,
  12860. PatientId: patient.ID,
  12861. Certno: res.Output.Baseinfo.Certno,
  12862. Gend: res.Output.Baseinfo.Gend,
  12863. Naty: res.Output.Baseinfo.Naty,
  12864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12865. PsnName: res.Output.Baseinfo.PsnName,
  12866. Idetinfo: idetinfoStr,
  12867. Insuinfo: infoStr,
  12868. InsuplcAdmdvs: insuplc_admdvs,
  12869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12870. }
  12871. service.CreateHisPsn(psn)
  12872. c.ServeSuccessJSON(map[string]interface{}{
  12873. "patient": patient,
  12874. "number": res.Output.Baseinfo.Certno,
  12875. })
  12876. }
  12877. } else {
  12878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12879. return
  12880. }
  12881. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12882. var res ResultTwo
  12883. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12884. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12885. "&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)
  12886. resp, requestErr := http.Get(api)
  12887. if requestErr != nil {
  12888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12889. return
  12890. }
  12891. body, ioErr := ioutil.ReadAll(resp.Body)
  12892. if ioErr != nil {
  12893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12895. return
  12896. }
  12897. var respJSON map[string]interface{}
  12898. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12901. return
  12902. }
  12903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12904. result, _ := json.Marshal(respJSON)
  12905. fmt.Println("log")
  12906. fmt.Println(string(result))
  12907. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12908. utils.ErrorLog("解析失败:%v", err)
  12909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12910. return
  12911. }
  12912. if res.Infcode == 0 {
  12913. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12914. if err == gorm.ErrRecordNotFound {
  12915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12916. return
  12917. } else if err != nil {
  12918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12919. return
  12920. } else {
  12921. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12922. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12923. infoStr := string(Iinfos)
  12924. idetinfoStr := string(Idetinfos)
  12925. psn := &models.HisPsn{
  12926. PsnNo: res.Output.Baseinfo.PsnNo,
  12927. PatientId: patient.ID,
  12928. Certno: res.Output.Baseinfo.Certno,
  12929. Gend: res.Output.Baseinfo.Gend,
  12930. Naty: res.Output.Baseinfo.Naty,
  12931. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12932. PsnName: res.Output.Baseinfo.PsnName,
  12933. Idetinfo: idetinfoStr,
  12934. Insuinfo: infoStr,
  12935. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12936. }
  12937. service.CreateHisPsn(psn)
  12938. var rf []*ResultFive
  12939. json.Unmarshal([]byte(infoStr), &rf)
  12940. var insutypes []*ResultFive
  12941. var insutype string
  12942. var is390 int = 0
  12943. var is310 int = 0
  12944. for _, item := range rf {
  12945. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12946. insutypes = append(insutypes, item)
  12947. }
  12948. }
  12949. if len(insutypes) == 1 {
  12950. insutype = insutypes[0].Insutype
  12951. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12952. } else {
  12953. for _, i := range insutypes {
  12954. if i.Insutype == "390" {
  12955. is390 = 1
  12956. }
  12957. if i.Insutype == "310" {
  12958. is310 = 1
  12959. }
  12960. }
  12961. }
  12962. if is390 == 1 {
  12963. insutype = "390"
  12964. }
  12965. if is310 == 1 {
  12966. insutype = "310"
  12967. }
  12968. if len(insutypes) == 0 {
  12969. insutype = "310"
  12970. }
  12971. c.ServeSuccessJSON(map[string]interface{}{
  12972. "patient": patient,
  12973. "number": res.Output.Baseinfo.Certno,
  12974. "insutype": insutype,
  12975. })
  12976. }
  12977. } else {
  12978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12979. return
  12980. }
  12981. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12982. var res ResultTwo
  12983. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12984. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12985. "&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)
  12986. resp, requestErr := http.Get(api)
  12987. if requestErr != nil {
  12988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12989. return
  12990. }
  12991. body, ioErr := ioutil.ReadAll(resp.Body)
  12992. if ioErr != nil {
  12993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12995. return
  12996. }
  12997. var respJSON map[string]interface{}
  12998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13001. return
  13002. }
  13003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13004. result, _ := json.Marshal(respJSON)
  13005. fmt.Println("log")
  13006. fmt.Println(string(result))
  13007. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13008. utils.ErrorLog("解析失败:%v", err)
  13009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13010. return
  13011. }
  13012. if res.Infcode == 0 {
  13013. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13014. if err == gorm.ErrRecordNotFound {
  13015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13016. return
  13017. } else if err != nil {
  13018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13019. return
  13020. } else {
  13021. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13022. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13023. infoStr := string(Iinfos)
  13024. idetinfoStr := string(Idetinfos)
  13025. var rf []*ResultFive
  13026. json.Unmarshal([]byte(infoStr), &rf)
  13027. var insutypes []*ResultFive
  13028. var insutype string
  13029. var is390 int = 0
  13030. var is310 int = 0
  13031. for _, item := range rf {
  13032. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13033. insutypes = append(insutypes, item)
  13034. }
  13035. }
  13036. if len(insutypes) == 1 {
  13037. insutype = insutypes[0].Insutype
  13038. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13039. } else {
  13040. for _, i := range insutypes {
  13041. if i.Insutype == "390" {
  13042. is390 = 1
  13043. }
  13044. if i.Insutype == "310" {
  13045. is310 = 1
  13046. }
  13047. }
  13048. }
  13049. if is390 == 1 {
  13050. insutype = "390"
  13051. }
  13052. if is310 == 1 {
  13053. insutype = "310"
  13054. }
  13055. if len(insutypes) == 0 {
  13056. insutype = "390"
  13057. }
  13058. var insuplc_admdvs string
  13059. for _, item := range rf {
  13060. if item.Insutype == insutype {
  13061. insuplc_admdvs = item.InsuplcAdmdvs
  13062. }
  13063. }
  13064. psn := &models.HisPsn{
  13065. PsnNo: res.Output.Baseinfo.PsnNo,
  13066. PatientId: patient.ID,
  13067. Certno: res.Output.Baseinfo.Certno,
  13068. Gend: res.Output.Baseinfo.Gend,
  13069. Naty: res.Output.Baseinfo.Naty,
  13070. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13071. PsnName: res.Output.Baseinfo.PsnName,
  13072. Idetinfo: idetinfoStr,
  13073. Insuinfo: infoStr,
  13074. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13075. InsuplcAdmdvs: insuplc_admdvs,
  13076. }
  13077. service.CreateHisPsn(psn)
  13078. for _, item := range rf {
  13079. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13080. insutypes = append(insutypes, item)
  13081. }
  13082. }
  13083. if len(insutypes) == 1 {
  13084. insutype = insutypes[0].Insutype
  13085. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13086. } else {
  13087. for _, i := range insutypes {
  13088. if i.Insutype == "390" {
  13089. is390 = 1
  13090. }
  13091. if i.Insutype == "310" {
  13092. is310 = 1
  13093. }
  13094. }
  13095. }
  13096. if is390 == 1 {
  13097. insutype = "390"
  13098. }
  13099. if is310 == 1 {
  13100. insutype = "310"
  13101. }
  13102. if len(insutypes) == 0 {
  13103. insutype = "310"
  13104. }
  13105. c.ServeSuccessJSON(map[string]interface{}{
  13106. "patient": patient,
  13107. "number": res.Output.Baseinfo.Certno,
  13108. "insutype": insutype,
  13109. })
  13110. }
  13111. } else {
  13112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13113. return
  13114. }
  13115. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13116. var res ResultTwo
  13117. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13118. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13119. "&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)
  13120. resp, requestErr := http.Get(api)
  13121. if requestErr != nil {
  13122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13123. return
  13124. }
  13125. body, ioErr := ioutil.ReadAll(resp.Body)
  13126. if ioErr != nil {
  13127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13129. return
  13130. }
  13131. var respJSON map[string]interface{}
  13132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13135. return
  13136. }
  13137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13138. result, _ := json.Marshal(respJSON)
  13139. fmt.Println("log")
  13140. fmt.Println(string(result))
  13141. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13142. utils.ErrorLog("解析失败:%v", err)
  13143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13144. return
  13145. }
  13146. if res.Infcode == 0 {
  13147. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13148. if err == gorm.ErrRecordNotFound {
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13150. return
  13151. } else if err != nil {
  13152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13153. return
  13154. } else {
  13155. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13156. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13157. infoStr := string(Iinfos)
  13158. idetinfoStr := string(Idetinfos)
  13159. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13160. psn := &models.HisPsn{
  13161. PsnNo: res.Output.Baseinfo.PsnNo,
  13162. PatientId: patient.ID,
  13163. Certno: res.Output.Baseinfo.Certno,
  13164. Brdy: b,
  13165. Age: float64(age),
  13166. Gend: res.Output.Baseinfo.Gend,
  13167. Naty: res.Output.Baseinfo.Naty,
  13168. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13169. PsnName: res.Output.Baseinfo.PsnName,
  13170. Idetinfo: idetinfoStr,
  13171. Insuinfo: infoStr,
  13172. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13173. }
  13174. service.CreateHisPsn(psn)
  13175. var rf []*ResultFive
  13176. json.Unmarshal([]byte(infoStr), &rf)
  13177. var insutypes []*ResultFive
  13178. var insutype string
  13179. var is390 int = 0
  13180. var is310 int = 0
  13181. for _, item := range rf {
  13182. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13183. insutypes = append(insutypes, item)
  13184. }
  13185. }
  13186. if len(insutypes) == 1 {
  13187. insutype = insutypes[0].Insutype
  13188. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13189. } else {
  13190. for _, i := range insutypes {
  13191. if i.Insutype == "390" {
  13192. is390 = 1
  13193. }
  13194. if i.Insutype == "310" {
  13195. is310 = 1
  13196. }
  13197. }
  13198. }
  13199. if is390 == 1 {
  13200. insutype = "390"
  13201. }
  13202. if is310 == 1 {
  13203. insutype = "310"
  13204. }
  13205. if len(insutypes) == 0 {
  13206. insutype = "310"
  13207. }
  13208. c.ServeSuccessJSON(map[string]interface{}{
  13209. "patient": patient,
  13210. "number": res.Output.Baseinfo.Certno,
  13211. "insutype": insutype,
  13212. })
  13213. }
  13214. } else {
  13215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13216. return
  13217. }
  13218. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13219. var api string
  13220. if miConfig.MdtrtareaAdmvs == "320921" {
  13221. 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 +
  13222. "&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
  13223. fmt.Println(api)
  13224. } else {
  13225. 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 +
  13226. "&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)
  13227. }
  13228. resp, requestErr := http.Get(api)
  13229. if requestErr != nil {
  13230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13231. return
  13232. }
  13233. body, ioErr := ioutil.ReadAll(resp.Body)
  13234. if ioErr != nil {
  13235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13237. return
  13238. }
  13239. var respJSON map[string]interface{}
  13240. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13243. return
  13244. }
  13245. var status string
  13246. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13247. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13248. //console.log()
  13249. fmt.Println("type===")
  13250. fmt.Println(card_type)
  13251. var token string
  13252. var res ResultTwo //1101结果
  13253. var res10265 ResultTwo10265 //1101结果
  13254. var card_info string //卡信息
  13255. var busi_card_info string
  13256. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13257. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13258. if status == "0" { //读卡成功
  13259. if card_type == "1" {
  13260. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13261. result, _ := json.Marshal(respJSON)
  13262. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13263. utils.ErrorLog("解析失败:%v", err)
  13264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13265. return
  13266. }
  13267. res.ErrMsg = res10265.ErrMsg
  13268. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13269. res.Infcode = infocode
  13270. res.Output = res10265.Output
  13271. res.InfRefmsgid = res10265.InfRefmsgid
  13272. } else {
  13273. //var card_info string //卡信息
  13274. //var busi_card_info string
  13275. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13276. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13277. //fmt.Println(card_info)
  13278. //fmt.Println(busi_card_info)
  13279. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13280. result, _ := json.Marshal(respJSON)
  13281. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13282. utils.ErrorLog("解析失败:%v", err)
  13283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13284. return
  13285. }
  13286. res.ErrMsg = res10265.ErrMsg
  13287. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13288. res.Infcode = infocode
  13289. res.Output = res10265.Output
  13290. res.InfRefmsgid = res10265.InfRefmsgid
  13291. }
  13292. if res.Infcode == 0 {
  13293. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13294. if err == gorm.ErrRecordNotFound {
  13295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13296. return
  13297. } else if err != nil {
  13298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13299. return
  13300. } else {
  13301. if card_type == "1" {
  13302. bas := strings.Split(card_info, "|")
  13303. basNumber := bas[2]
  13304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13306. infoStr := string(Iinfos)
  13307. idetinfoStr := string(Idetinfos)
  13308. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13309. psn := &models.HisPsn{
  13310. PsnNo: res.Output.Baseinfo.PsnNo,
  13311. PatientId: patient.ID,
  13312. Certno: res.Output.Baseinfo.Certno,
  13313. Brdy: b,
  13314. Age: float64(age),
  13315. Gend: res.Output.Baseinfo.Gend,
  13316. Naty: res.Output.Baseinfo.Naty,
  13317. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13318. PsnName: res.Output.Baseinfo.PsnName,
  13319. Idetinfo: idetinfoStr,
  13320. Insuinfo: infoStr,
  13321. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13322. CardInfo: card_info,
  13323. VerifyNumber: busi_card_info,
  13324. }
  13325. service.CreateHisPsn(psn)
  13326. var rf []*ResultFive
  13327. json.Unmarshal([]byte(infoStr), &rf)
  13328. var insutypes []*ResultFive
  13329. var insutype string
  13330. var is390 int = 0
  13331. var is310 int = 0
  13332. for _, item := range rf {
  13333. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13334. insutypes = append(insutypes, item)
  13335. }
  13336. }
  13337. if len(insutypes) == 1 {
  13338. insutype = insutypes[0].Insutype
  13339. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13340. } else {
  13341. for _, i := range insutypes {
  13342. if i.Insutype == "390" {
  13343. is390 = 1
  13344. }
  13345. if i.Insutype == "310" {
  13346. is310 = 1
  13347. }
  13348. }
  13349. }
  13350. if is390 == 1 {
  13351. insutype = "390"
  13352. }
  13353. if is310 == 1 {
  13354. insutype = "310"
  13355. }
  13356. if len(insutypes) == 0 {
  13357. insutype = "310"
  13358. }
  13359. c.ServeSuccessJSON(map[string]interface{}{
  13360. "patient": patient,
  13361. "number": basNumber,
  13362. "insutype": insutype,
  13363. })
  13364. } else {
  13365. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13366. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13367. infoStr := string(Iinfos)
  13368. idetinfoStr := string(Idetinfos)
  13369. psn := &models.HisPsn{
  13370. PsnNo: res.Output.Baseinfo.PsnNo,
  13371. PatientId: patient.ID,
  13372. Certno: res.Output.Baseinfo.Certno,
  13373. Gend: res.Output.Baseinfo.Gend,
  13374. Naty: res.Output.Baseinfo.Naty,
  13375. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13376. PsnName: res.Output.Baseinfo.PsnName,
  13377. Idetinfo: idetinfoStr,
  13378. Insuinfo: infoStr,
  13379. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13380. CardInfo: card_info,
  13381. VerifyNumber: token,
  13382. }
  13383. service.CreateHisPsn(psn)
  13384. c.ServeSuccessJSON(map[string]interface{}{
  13385. "patient": patient,
  13386. "number": token,
  13387. })
  13388. }
  13389. }
  13390. } else {
  13391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13392. return
  13393. }
  13394. } else { //读卡失败
  13395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13396. return
  13397. }
  13398. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13399. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13400. cardnum = DeleteExtraSpaceTwo(cardnum)
  13401. cardCode = DeleteExtraSpaceTwo(cardCode)
  13402. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13403. name = DeleteExtraSpaceTwo(name)
  13404. errmsg = DeleteExtraSpaceTwo(errmsg)
  13405. cardnum = Remove0000(cardnum)
  13406. cardCode = Remove0000(cardCode)
  13407. id_card_no = Remove0000(id_card_no)
  13408. name = Remove0000(name)
  13409. errmsg = Remove0000(errmsg)
  13410. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13411. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13412. //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)
  13413. //fmt.Println(result2)
  13414. //fmt.Println(requestLog2)
  13415. //fmt.Println(errMsgLog2)
  13416. 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)
  13417. saveLog(result, requestLog, "1101", "获取人员信息")
  13418. fmt.Println(errMsgLog)
  13419. if len(errMsgLog) > 0 {
  13420. } else {
  13421. var dat map[string]interface{}
  13422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13423. fmt.Println(dat)
  13424. } else {
  13425. fmt.Println(err)
  13426. }
  13427. userJSONBytes, _ := json.Marshal(dat)
  13428. var res ResultTwo
  13429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13430. utils.ErrorLog("解析失败:%v", err)
  13431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13432. return
  13433. }
  13434. res.ErrMsg = errMsgLog
  13435. if res.Infcode == 0 {
  13436. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13437. if err == gorm.ErrRecordNotFound {
  13438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13439. return
  13440. } else if err != nil {
  13441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13442. return
  13443. } else {
  13444. fmt.Println(res)
  13445. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13446. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13447. infoStr := string(Iinfos)
  13448. idetinfoStr := string(Idetinfos)
  13449. var rf []*ResultFive
  13450. json.Unmarshal([]byte(infoStr), &rf)
  13451. var insutypes []*ResultFive
  13452. var insutype string
  13453. var is390 int = 0
  13454. var is310 int = 0
  13455. for _, item := range rf {
  13456. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13457. insutypes = append(insutypes, item)
  13458. }
  13459. }
  13460. if len(insutypes) == 1 {
  13461. insutype = insutypes[0].Insutype
  13462. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13463. } else {
  13464. for _, i := range insutypes {
  13465. if i.Insutype == "390" {
  13466. is390 = 1
  13467. }
  13468. if i.Insutype == "310" {
  13469. is310 = 1
  13470. }
  13471. }
  13472. }
  13473. if is390 == 1 {
  13474. insutype = "390"
  13475. }
  13476. if is310 == 1 {
  13477. insutype = "310"
  13478. }
  13479. if len(insutypes) == 0 {
  13480. insutype = "390"
  13481. }
  13482. var insuplc_admdvs string
  13483. for _, item := range rf {
  13484. if item.Insutype == insutype {
  13485. insuplc_admdvs = item.InsuplcAdmdvs
  13486. }
  13487. }
  13488. psn := &models.HisPsn{
  13489. PsnNo: res.Output.Baseinfo.PsnNo,
  13490. PatientId: patient.ID,
  13491. Certno: res.Output.Baseinfo.Certno,
  13492. Gend: res.Output.Baseinfo.Gend,
  13493. Naty: res.Output.Baseinfo.Naty,
  13494. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13495. PsnName: res.Output.Baseinfo.PsnName,
  13496. Idetinfo: idetinfoStr,
  13497. Insuinfo: infoStr,
  13498. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13499. CardInfo: basStr,
  13500. VerifyNumber: "",
  13501. InsuplcAdmdvs: insuplc_admdvs,
  13502. }
  13503. service.CreateHisPsn(psn)
  13504. c.ServeSuccessJSON(map[string]interface{}{
  13505. "patient": patient,
  13506. "number": cardnum,
  13507. "insutype": insutype,
  13508. })
  13509. }
  13510. } else {
  13511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13512. return
  13513. }
  13514. }
  13515. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13516. fmt.Println(initFlag)
  13517. fmt.Println("initFlag")
  13518. if initFlag == 0 {
  13519. c.TestGetJiangXiBasBaseInit()
  13520. }
  13521. basStr := c.GetBasBaseInfo()
  13522. if len(basStr) == 0 {
  13523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13524. return
  13525. }
  13526. fmt.Println(basStr)
  13527. bas := strings.Split(basStr, "|")
  13528. basNumber := bas[1]
  13529. fmt.Println(basNumber)
  13530. card_sn := bas[3]
  13531. fmt.Println(card_sn)
  13532. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13533. 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)
  13534. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13535. var dat map[string]interface{}
  13536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13537. fmt.Println(dat)
  13538. } else {
  13539. fmt.Println(err)
  13540. }
  13541. userJSONBytes, _ := json.Marshal(dat)
  13542. var res ResultTwo
  13543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13544. utils.ErrorLog("解析失败:%v", err)
  13545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13546. return
  13547. }
  13548. if res.Infcode == 0 {
  13549. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13550. if err == gorm.ErrRecordNotFound {
  13551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13552. return
  13553. } else if err != nil {
  13554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13555. return
  13556. } else {
  13557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13558. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13559. infoStr := string(Iinfos)
  13560. idetinfoStr := string(Idetinfos)
  13561. var rf []*ResultFive
  13562. json.Unmarshal([]byte(infoStr), &rf)
  13563. var insutypes []*ResultFive
  13564. var insutype string
  13565. var is390 int = 0
  13566. var is310 int = 0
  13567. var insuplc_admdvs string
  13568. for _, item := range rf {
  13569. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13570. insutypes = append(insutypes, item)
  13571. }
  13572. }
  13573. if len(insutypes) == 1 {
  13574. insutype = insutypes[0].Insutype
  13575. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13576. } else {
  13577. for _, i := range insutypes {
  13578. if i.Insutype == "390" {
  13579. is390 = 1
  13580. }
  13581. if i.Insutype == "310" {
  13582. is310 = 1
  13583. }
  13584. }
  13585. }
  13586. if is390 == 1 {
  13587. insutype = "390"
  13588. }
  13589. if is310 == 1 {
  13590. insutype = "310"
  13591. }
  13592. if len(insutypes) == 0 {
  13593. insutype = "310"
  13594. }
  13595. for _, item := range rf {
  13596. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13597. insuplc_admdvs = item.InsuplcAdmdvs
  13598. }
  13599. }
  13600. psn := &models.HisPsn{
  13601. PsnNo: res.Output.Baseinfo.PsnNo,
  13602. PatientId: patient.ID,
  13603. Certno: res.Output.Baseinfo.Certno,
  13604. Gend: res.Output.Baseinfo.Gend,
  13605. Naty: res.Output.Baseinfo.Naty,
  13606. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13607. PsnName: res.Output.Baseinfo.PsnName,
  13608. Idetinfo: idetinfoStr,
  13609. Insuinfo: infoStr,
  13610. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13611. CardInfo: basStr,
  13612. InsuplcAdmdvs: insuplc_admdvs,
  13613. VerifyNumber: "",
  13614. }
  13615. service.CreateHisPsn(psn)
  13616. c.ServeSuccessJSON(map[string]interface{}{
  13617. "patient": patient,
  13618. "number": basNumber,
  13619. "insutype": insutype,
  13620. })
  13621. }
  13622. } else {
  13623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13624. return
  13625. }
  13626. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13627. basStr := c.GetBasBaseInfo22222()
  13628. fmt.Println(basStr)
  13629. if len(basStr) == 0 {
  13630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13631. return
  13632. }
  13633. fmt.Println(basStr)
  13634. bas := strings.Split(basStr, "|")
  13635. basNumber := bas[2] //卡号
  13636. card_sn := bas[3] //
  13637. id_card_No := bas[1] //卡号
  13638. fmt.Println(basNumber)
  13639. fmt.Println(card_sn)
  13640. fmt.Println(id_card_No)
  13641. var patient service.Patients
  13642. if len(id_card_No) == 0 {
  13643. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13644. } else {
  13645. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13646. }
  13647. 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)
  13648. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13649. var dat map[string]interface{}
  13650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13651. fmt.Println(dat)
  13652. } else {
  13653. fmt.Println(err)
  13654. }
  13655. userJSONBytes, _ := json.Marshal(dat)
  13656. var res ResultTwo
  13657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13658. utils.ErrorLog("解析失败:%v", err)
  13659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13660. return
  13661. }
  13662. if res.Infcode == 0 {
  13663. var pateint2 service.Patients
  13664. var err error
  13665. if len(id_card_No) == 0 {
  13666. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13667. } else {
  13668. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13669. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13670. }
  13671. if err == gorm.ErrRecordNotFound {
  13672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13673. return
  13674. } else if err != nil {
  13675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13676. return
  13677. } else {
  13678. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13679. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13680. infoStr := string(Iinfos)
  13681. idetinfoStr := string(Idetinfos)
  13682. var rf []*ResultFive
  13683. json.Unmarshal([]byte(infoStr), &rf)
  13684. var insutypes []*ResultFive
  13685. var insutype string
  13686. var is390 int = 0
  13687. var is310 int = 0
  13688. var insuplc_admdvs string
  13689. for _, item := range rf {
  13690. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13691. insutypes = append(insutypes, item)
  13692. }
  13693. }
  13694. if len(insutypes) == 1 {
  13695. insutype = insutypes[0].Insutype
  13696. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13697. } else {
  13698. for _, i := range insutypes {
  13699. if i.Insutype == "390" {
  13700. is390 = 1
  13701. }
  13702. if i.Insutype == "310" {
  13703. is310 = 1
  13704. }
  13705. }
  13706. }
  13707. if is390 == 1 {
  13708. insutype = "390"
  13709. }
  13710. if is310 == 1 {
  13711. insutype = "310"
  13712. }
  13713. if len(insutypes) == 0 {
  13714. insutype = "310"
  13715. }
  13716. for _, item := range rf {
  13717. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13718. insuplc_admdvs = item.InsuplcAdmdvs
  13719. }
  13720. }
  13721. psn := &models.HisPsn{
  13722. PsnNo: res.Output.Baseinfo.PsnNo,
  13723. PatientId: pateint2.ID,
  13724. Certno: res.Output.Baseinfo.Certno,
  13725. Gend: res.Output.Baseinfo.Gend,
  13726. Naty: res.Output.Baseinfo.Naty,
  13727. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13728. PsnName: res.Output.Baseinfo.PsnName,
  13729. Idetinfo: idetinfoStr,
  13730. Insuinfo: infoStr,
  13731. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13732. CardInfo: basStr,
  13733. InsuplcAdmdvs: insuplc_admdvs,
  13734. VerifyNumber: "",
  13735. }
  13736. service.CreateHisPsn(psn)
  13737. c.ServeSuccessJSON(map[string]interface{}{
  13738. "patient": patient,
  13739. "number": basNumber,
  13740. "insutype": insutype,
  13741. })
  13742. }
  13743. } else {
  13744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13745. return
  13746. }
  13747. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13748. fmt.Println(initFlag)
  13749. fmt.Println("initFlag")
  13750. if initFlag == 0 {
  13751. c.TestGetHnBasBaseInit()
  13752. }
  13753. basStr := c.GetBasBaseInfo()
  13754. if len(basStr) == 0 {
  13755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13756. return
  13757. }
  13758. fmt.Println(basStr)
  13759. bas := strings.Split(basStr, "|")
  13760. basNumber := bas[1]
  13761. fmt.Println(basNumber)
  13762. card_sn := bas[3]
  13763. card_no := bas[2]
  13764. fmt.Println(card_sn)
  13765. name := bas[4]
  13766. name = ConvertToString(name, "gbk", "utf-8")
  13767. 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)
  13768. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13769. var dat map[string]interface{}
  13770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13771. fmt.Println(dat)
  13772. } else {
  13773. fmt.Println(err)
  13774. }
  13775. userJSONBytes, _ := json.Marshal(dat)
  13776. var res ResultTwo
  13777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13778. utils.ErrorLog("解析失败:%v", err)
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13780. return
  13781. }
  13782. if res.Infcode == 0 {
  13783. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13784. if err == gorm.ErrRecordNotFound {
  13785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13786. return
  13787. } else if err != nil {
  13788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13789. return
  13790. } else {
  13791. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13792. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13793. infoStr := string(Iinfos)
  13794. idetinfoStr := string(Idetinfos)
  13795. psn := &models.HisPsn{
  13796. PsnNo: res.Output.Baseinfo.PsnNo,
  13797. PatientId: patient.ID,
  13798. Certno: res.Output.Baseinfo.Certno,
  13799. Gend: res.Output.Baseinfo.Gend,
  13800. Naty: res.Output.Baseinfo.Naty,
  13801. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13802. PsnName: res.Output.Baseinfo.PsnName,
  13803. Idetinfo: idetinfoStr,
  13804. Insuinfo: infoStr,
  13805. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13806. CardInfo: basStr,
  13807. VerifyNumber: "",
  13808. }
  13809. service.CreateHisPsn(psn)
  13810. var rf []*ResultFive
  13811. json.Unmarshal([]byte(infoStr), &rf)
  13812. var insutypes []*ResultFive
  13813. var insutype string
  13814. var is390 int = 0
  13815. var is310 int = 0
  13816. for _, item := range rf {
  13817. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13818. insutypes = append(insutypes, item)
  13819. }
  13820. }
  13821. if len(insutypes) == 1 {
  13822. insutype = insutypes[0].Insutype
  13823. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13824. } else {
  13825. for _, i := range insutypes {
  13826. if i.Insutype == "390" {
  13827. is390 = 1
  13828. }
  13829. if i.Insutype == "310" {
  13830. is310 = 1
  13831. }
  13832. }
  13833. }
  13834. if is390 == 1 {
  13835. insutype = "390"
  13836. }
  13837. if is310 == 1 {
  13838. insutype = "310"
  13839. }
  13840. if len(insutypes) == 0 {
  13841. insutype = "310"
  13842. }
  13843. c.ServeSuccessJSON(map[string]interface{}{
  13844. "patient": patient,
  13845. "number": basNumber,
  13846. "insutype": insutype,
  13847. })
  13848. }
  13849. } else {
  13850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13851. return
  13852. }
  13853. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13854. var api string
  13855. 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 +
  13856. "&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
  13857. fmt.Println(api)
  13858. resp, requestErr := http.Get(api)
  13859. if requestErr != nil {
  13860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13861. return
  13862. }
  13863. body, ioErr := ioutil.ReadAll(resp.Body)
  13864. if ioErr != nil {
  13865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13867. return
  13868. }
  13869. var respJSON map[string]interface{}
  13870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13873. return
  13874. }
  13875. var res ResultTwo //1101结果
  13876. var res10265 ResultTwo10265 //1101结果
  13877. var card_info string //卡信息
  13878. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13879. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13880. result, _ := json.Marshal(respJSON)
  13881. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13882. utils.ErrorLog("解析失败:%v", err)
  13883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13884. return
  13885. }
  13886. res.ErrMsg = res10265.ErrMsg
  13887. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13888. res.Infcode = infocode
  13889. res.Output = res10265.Output
  13890. res.InfRefmsgid = res10265.InfRefmsgid
  13891. if res.Infcode == 0 {
  13892. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13893. if err == gorm.ErrRecordNotFound {
  13894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13895. return
  13896. } else if err != nil {
  13897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13898. return
  13899. } else {
  13900. bas := strings.Split(card_info, "|")
  13901. basNumber := bas[2]
  13902. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13903. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13904. infoStr := string(Iinfos)
  13905. idetinfoStr := string(Idetinfos)
  13906. psn := &models.HisPsn{
  13907. PsnNo: res.Output.Baseinfo.PsnNo,
  13908. PatientId: patient.ID,
  13909. Certno: res.Output.Baseinfo.Certno,
  13910. Gend: res.Output.Baseinfo.Gend,
  13911. Naty: res.Output.Baseinfo.Naty,
  13912. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13913. PsnName: res.Output.Baseinfo.PsnName,
  13914. Idetinfo: idetinfoStr,
  13915. Insuinfo: infoStr,
  13916. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13917. CardInfo: card_info,
  13918. VerifyNumber: token,
  13919. }
  13920. service.CreateHisPsn(psn)
  13921. var rf []*ResultFive
  13922. json.Unmarshal([]byte(infoStr), &rf)
  13923. var insutypes []*ResultFive
  13924. var insutype string
  13925. var is390 int = 0
  13926. var is310 int = 0
  13927. for _, item := range rf {
  13928. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13929. insutypes = append(insutypes, item)
  13930. }
  13931. }
  13932. if len(insutypes) == 1 {
  13933. insutype = insutypes[0].Insutype
  13934. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13935. } else {
  13936. for _, i := range insutypes {
  13937. if i.Insutype == "390" {
  13938. is390 = 1
  13939. }
  13940. if i.Insutype == "310" {
  13941. is310 = 1
  13942. }
  13943. }
  13944. }
  13945. if is390 == 1 {
  13946. insutype = "390"
  13947. }
  13948. if is310 == 1 {
  13949. insutype = "310"
  13950. }
  13951. if len(insutypes) == 0 {
  13952. insutype = "310"
  13953. }
  13954. c.ServeSuccessJSON(map[string]interface{}{
  13955. "patient": patient,
  13956. "number": basNumber,
  13957. "insutype": insutype,
  13958. })
  13959. }
  13960. } else {
  13961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13962. return
  13963. }
  13964. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13965. res := c.GetoleInfo()
  13966. if res.Infcode == 0 {
  13967. var result string
  13968. if res.Output.MdtrtCertType == "01" {
  13969. 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)
  13970. } else if res.Output.MdtrtCertType == "02" {
  13971. 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)
  13972. } else if res.Output.MdtrtCertType == "03" {
  13973. 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)
  13974. }
  13975. var dat map[string]interface{}
  13976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13977. fmt.Println(dat)
  13978. } else {
  13979. fmt.Println(err)
  13980. }
  13981. userJSONBytes, _ := json.Marshal(dat)
  13982. var res2 ResultTwo
  13983. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13984. utils.ErrorLog("解析失败:%v", err)
  13985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13986. return
  13987. }
  13988. if res2.Infcode == 0 {
  13989. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13990. if err == gorm.ErrRecordNotFound {
  13991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13992. return
  13993. } else if err != nil {
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13995. return
  13996. } else {
  13997. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13998. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13999. infoStr := string(Iinfos)
  14000. idetinfoStr := string(Idetinfos)
  14001. var rf []*ResultFive
  14002. json.Unmarshal([]byte(infoStr), &rf)
  14003. var insutypes []*ResultFive
  14004. var insutype string
  14005. var is390 int = 0
  14006. var is310 int = 0
  14007. //var insuplc_admdvs string
  14008. for _, item := range rf {
  14009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14010. insutypes = append(insutypes, item)
  14011. }
  14012. }
  14013. if len(insutypes) == 1 {
  14014. insutype = insutypes[0].Insutype
  14015. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14016. } else {
  14017. for _, i := range insutypes {
  14018. if i.Insutype == "390" {
  14019. is390 = 1
  14020. }
  14021. if i.Insutype == "310" {
  14022. is310 = 1
  14023. }
  14024. }
  14025. }
  14026. if is390 == 1 {
  14027. insutype = "390"
  14028. }
  14029. if is310 == 1 {
  14030. insutype = "310"
  14031. }
  14032. if len(insutypes) == 0 {
  14033. insutype = "310"
  14034. }
  14035. psn := &models.HisPsn{
  14036. PsnNo: res2.Output.Baseinfo.PsnNo,
  14037. PatientId: patient.ID,
  14038. Certno: res2.Output.Baseinfo.Certno,
  14039. Gend: res2.Output.Baseinfo.Gend,
  14040. Naty: res2.Output.Baseinfo.Naty,
  14041. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14042. PsnName: res2.Output.Baseinfo.PsnName,
  14043. Idetinfo: idetinfoStr,
  14044. Insuinfo: infoStr,
  14045. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14046. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14047. VerifyNumber: res.Output.EcToken,
  14048. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14049. }
  14050. if res.Output.MdtrtCertType == "01" {
  14051. psn.VerifyNumber = res.Output.EcToken
  14052. //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)
  14053. } else if res.Output.MdtrtCertType == "02" {
  14054. psn.VerifyNumber = res.Output.MdtrtCertNo
  14055. //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)
  14056. } else if res.Output.MdtrtCertType == "03" {
  14057. psn.VerifyNumber = res.Output.MdtrtCertNo
  14058. //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)
  14059. }
  14060. var balc float64
  14061. for _, item := range rf {
  14062. if item.Insutype == insutype {
  14063. balc = item.Balc
  14064. }
  14065. }
  14066. service.CreateHisPsn(psn)
  14067. c.ServeSuccessJSON(map[string]interface{}{
  14068. "patient": patient,
  14069. "number": res.Output.CardNo,
  14070. "insutype": insutype,
  14071. "blac": balc,
  14072. "desc": idetinfoStr,
  14073. })
  14074. }
  14075. } else {
  14076. c.ServeSuccessJSON(map[string]interface{}{
  14077. "failed_code": -10,
  14078. "msg": res2.ErrMsg,
  14079. })
  14080. }
  14081. } else {
  14082. c.ServeSuccessJSON(map[string]interface{}{
  14083. "failed_code": -10,
  14084. "msg": res.ErrMsg,
  14085. })
  14086. }
  14087. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14088. var api string
  14089. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14090. "&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
  14091. fmt.Println(api)
  14092. resp, requestErr := http.Get(api)
  14093. if requestErr != nil {
  14094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14095. return
  14096. }
  14097. body, ioErr := ioutil.ReadAll(resp.Body)
  14098. if ioErr != nil {
  14099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14101. return
  14102. }
  14103. var respJSON map[string]interface{}
  14104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14107. return
  14108. }
  14109. var status string
  14110. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14111. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14112. //console.log()
  14113. fmt.Println("type===")
  14114. fmt.Println(card_type)
  14115. var token string
  14116. var res ResultTwo //1101结果
  14117. //var res10265 ResultTwoesultTwo10265 //1101结果
  14118. var card_info string //卡信息
  14119. var busi_card_info string
  14120. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14121. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14122. if status == "0" { //读卡成功
  14123. if card_type == "1" {
  14124. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14125. result, _ := json.Marshal(respJSON)
  14126. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14127. utils.ErrorLog("解析失败:%v", err)
  14128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14129. return
  14130. }
  14131. } else {
  14132. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14133. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14134. result, _ := json.Marshal(respJSON)
  14135. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14136. utils.ErrorLog("解析失败:%v", err)
  14137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14138. return
  14139. }
  14140. }
  14141. if res.Infcode == 0 {
  14142. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14143. if err == gorm.ErrRecordNotFound {
  14144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14145. return
  14146. } else if err != nil {
  14147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14148. return
  14149. } else {
  14150. if card_type == "1" {
  14151. bas := strings.Split(card_info, "|")
  14152. basNumber := bas[2]
  14153. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14154. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14155. infoStr := string(Iinfos)
  14156. idetinfoStr := string(Idetinfos)
  14157. psn := &models.HisPsn{
  14158. PsnNo: res.Output.Baseinfo.PsnNo,
  14159. PatientId: patient.ID,
  14160. Certno: res.Output.Baseinfo.Certno,
  14161. Gend: res.Output.Baseinfo.Gend,
  14162. Naty: res.Output.Baseinfo.Naty,
  14163. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14164. PsnName: res.Output.Baseinfo.PsnName,
  14165. Idetinfo: idetinfoStr,
  14166. Insuinfo: infoStr,
  14167. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14168. CardInfo: card_info,
  14169. VerifyNumber: busi_card_info,
  14170. }
  14171. service.CreateHisPsn(psn)
  14172. var rf []*ResultFive
  14173. json.Unmarshal([]byte(infoStr), &rf)
  14174. var insutypes []*ResultFive
  14175. var insutype string
  14176. var is390 int = 0
  14177. var is310 int = 0
  14178. for _, item := range rf {
  14179. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14180. insutypes = append(insutypes, item)
  14181. }
  14182. }
  14183. if len(insutypes) == 1 {
  14184. insutype = insutypes[0].Insutype
  14185. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14186. } else {
  14187. for _, i := range insutypes {
  14188. if i.Insutype == "390" {
  14189. is390 = 1
  14190. }
  14191. if i.Insutype == "310" {
  14192. is310 = 1
  14193. }
  14194. }
  14195. }
  14196. if is390 == 1 {
  14197. insutype = "390"
  14198. }
  14199. if is310 == 1 {
  14200. insutype = "310"
  14201. }
  14202. if len(insutypes) == 0 {
  14203. insutype = "310"
  14204. }
  14205. c.ServeSuccessJSON(map[string]interface{}{
  14206. "patient": patient,
  14207. "number": basNumber,
  14208. "insutype": insutype,
  14209. })
  14210. } else {
  14211. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14212. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14213. infoStr := string(Iinfos)
  14214. idetinfoStr := string(Idetinfos)
  14215. psn := &models.HisPsn{
  14216. PsnNo: res.Output.Baseinfo.PsnNo,
  14217. PatientId: patient.ID,
  14218. Certno: res.Output.Baseinfo.Certno,
  14219. Gend: res.Output.Baseinfo.Gend,
  14220. Naty: res.Output.Baseinfo.Naty,
  14221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14222. PsnName: res.Output.Baseinfo.PsnName,
  14223. Idetinfo: idetinfoStr,
  14224. Insuinfo: infoStr,
  14225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14226. CardInfo: card_info,
  14227. VerifyNumber: token,
  14228. }
  14229. service.CreateHisPsn(psn)
  14230. c.ServeSuccessJSON(map[string]interface{}{
  14231. "patient": patient,
  14232. "number": token,
  14233. })
  14234. }
  14235. }
  14236. } else {
  14237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14238. return
  14239. }
  14240. } else { //读卡失败
  14241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14242. return
  14243. }
  14244. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14245. var api string
  14246. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14247. "&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
  14248. fmt.Println(api)
  14249. resp, requestErr := http.Get(api)
  14250. if requestErr != nil {
  14251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14252. return
  14253. }
  14254. body, ioErr := ioutil.ReadAll(resp.Body)
  14255. if ioErr != nil {
  14256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14258. return
  14259. }
  14260. var respJSON map[string]interface{}
  14261. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14264. return
  14265. }
  14266. var status string
  14267. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14268. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14269. //console.log()
  14270. fmt.Println("type===")
  14271. fmt.Println(card_type)
  14272. var token string
  14273. var res ResultTwo //1101结果
  14274. //var res10265 ResultTwoesultTwo10265 //1101结果
  14275. var card_info string //卡信息
  14276. //var busi_card_info string
  14277. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14278. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14279. if status == "0" { //读卡成功
  14280. if card_type == "1" {
  14281. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14282. result, _ := json.Marshal(respJSON)
  14283. fmt.Println(result)
  14284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14285. utils.ErrorLog("解析失败:%v", err)
  14286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14287. return
  14288. }
  14289. fmt.Println(res)
  14290. } else {
  14291. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14292. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14293. result, _ := json.Marshal(respJSON)
  14294. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14295. utils.ErrorLog("解析失败:%v", err)
  14296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14297. return
  14298. }
  14299. }
  14300. if res.Infcode == 0 {
  14301. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14302. if err == gorm.ErrRecordNotFound {
  14303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14304. return
  14305. } else if err != nil {
  14306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14307. return
  14308. } else {
  14309. if card_type == "1" {
  14310. bas := strings.Split(card_info, "|")
  14311. basNumber := bas[2]
  14312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14314. infoStr := string(Iinfos)
  14315. idetinfoStr := string(Idetinfos)
  14316. psn := &models.HisPsn{
  14317. PsnNo: res.Output.Baseinfo.PsnNo,
  14318. PatientId: patient.ID,
  14319. Certno: res.Output.Baseinfo.Certno,
  14320. Gend: res.Output.Baseinfo.Gend,
  14321. Naty: res.Output.Baseinfo.Naty,
  14322. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14323. PsnName: res.Output.Baseinfo.PsnName,
  14324. Idetinfo: idetinfoStr,
  14325. Insuinfo: infoStr,
  14326. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14327. CardInfo: card_info,
  14328. //VerifyNumber: busi_card_info,
  14329. }
  14330. service.CreateHisPsn(psn)
  14331. var rf []*ResultFive
  14332. json.Unmarshal([]byte(infoStr), &rf)
  14333. var insutypes []*ResultFive
  14334. var insutype string
  14335. var is390 int = 0
  14336. var is310 int = 0
  14337. for _, item := range rf {
  14338. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14339. insutypes = append(insutypes, item)
  14340. }
  14341. }
  14342. if len(insutypes) == 1 {
  14343. insutype = insutypes[0].Insutype
  14344. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14345. } else {
  14346. for _, i := range insutypes {
  14347. if i.Insutype == "390" {
  14348. is390 = 1
  14349. }
  14350. if i.Insutype == "310" {
  14351. is310 = 1
  14352. }
  14353. }
  14354. }
  14355. if is390 == 1 {
  14356. insutype = "390"
  14357. }
  14358. if is310 == 1 {
  14359. insutype = "310"
  14360. }
  14361. if len(insutypes) == 0 {
  14362. insutype = "310"
  14363. }
  14364. c.ServeSuccessJSON(map[string]interface{}{
  14365. "patient": patient,
  14366. "number": basNumber,
  14367. "insutype": insutype,
  14368. })
  14369. } else {
  14370. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14371. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14372. infoStr := string(Iinfos)
  14373. idetinfoStr := string(Idetinfos)
  14374. psn := &models.HisPsn{
  14375. PsnNo: res.Output.Baseinfo.PsnNo,
  14376. PatientId: patient.ID,
  14377. Certno: res.Output.Baseinfo.Certno,
  14378. Gend: res.Output.Baseinfo.Gend,
  14379. Naty: res.Output.Baseinfo.Naty,
  14380. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14381. PsnName: res.Output.Baseinfo.PsnName,
  14382. Idetinfo: idetinfoStr,
  14383. Insuinfo: infoStr,
  14384. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14385. CardInfo: card_info,
  14386. VerifyNumber: token,
  14387. }
  14388. service.CreateHisPsn(psn)
  14389. c.ServeSuccessJSON(map[string]interface{}{
  14390. "patient": patient,
  14391. "number": token,
  14392. })
  14393. }
  14394. }
  14395. } else {
  14396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14397. return
  14398. }
  14399. } else { //读卡失败
  14400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14401. return
  14402. }
  14403. } else {
  14404. if initFlag == 0 {
  14405. c.TestGetBasBaseInit()
  14406. }
  14407. basStr := c.GetBasBaseInfo()
  14408. if len(basStr) == 0 {
  14409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14410. return
  14411. }
  14412. fmt.Println(basStr)
  14413. bas := strings.Split(basStr, "|")
  14414. basNumber := bas[1]
  14415. fmt.Println(basNumber)
  14416. card_sn := bas[3]
  14417. fmt.Println(card_sn)
  14418. cardNumber := bas[2]
  14419. fmt.Println(cardNumber)
  14420. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14421. var result string
  14422. if bas[0][:2] == "44" {
  14423. 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)
  14424. } else {
  14425. 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)
  14426. }
  14427. var dat map[string]interface{}
  14428. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14429. fmt.Println(dat)
  14430. } else {
  14431. fmt.Println(err)
  14432. }
  14433. userJSONBytes, _ := json.Marshal(dat)
  14434. var res ResultTwo
  14435. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14436. utils.ErrorLog("解析失败:%v", err)
  14437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14438. return
  14439. }
  14440. if res.Infcode == 0 {
  14441. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14442. if err == gorm.ErrRecordNotFound {
  14443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14444. return
  14445. } else if err != nil {
  14446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14447. return
  14448. } else {
  14449. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14450. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14451. infoStr := string(Iinfos)
  14452. idetinfoStr := string(Idetinfos)
  14453. var rf []*ResultFive
  14454. json.Unmarshal([]byte(infoStr), &rf)
  14455. var insutypes []*ResultFive
  14456. var insutype string
  14457. var is390 int = 0
  14458. var is310 int = 0
  14459. var insuplc_admdvs string
  14460. for _, item := range rf {
  14461. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14462. insutypes = append(insutypes, item)
  14463. }
  14464. }
  14465. if len(insutypes) == 1 {
  14466. insutype = insutypes[0].Insutype
  14467. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14468. } else {
  14469. for _, i := range insutypes {
  14470. if i.Insutype == "390" {
  14471. is390 = 1
  14472. }
  14473. if i.Insutype == "310" {
  14474. is310 = 1
  14475. }
  14476. }
  14477. }
  14478. if is390 == 1 {
  14479. insutype = "390"
  14480. }
  14481. if is310 == 1 {
  14482. insutype = "310"
  14483. }
  14484. if len(insutypes) == 0 {
  14485. insutype = "310"
  14486. }
  14487. for _, item := range rf {
  14488. if item.Insutype == insutype {
  14489. insuplc_admdvs = item.InsuplcAdmdvs
  14490. }
  14491. }
  14492. psn := &models.HisPsn{
  14493. PsnNo: res.Output.Baseinfo.PsnNo,
  14494. PatientId: patient.ID,
  14495. Certno: res.Output.Baseinfo.Certno,
  14496. Gend: res.Output.Baseinfo.Gend,
  14497. Naty: res.Output.Baseinfo.Naty,
  14498. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14499. PsnName: res.Output.Baseinfo.PsnName,
  14500. Idetinfo: idetinfoStr,
  14501. Insuinfo: infoStr,
  14502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14503. CardInfo: basStr,
  14504. VerifyNumber: "",
  14505. InsuplcAdmdvs: insuplc_admdvs,
  14506. }
  14507. service.CreateHisPsn(psn)
  14508. c.ServeSuccessJSON(map[string]interface{}{
  14509. "patient": patient,
  14510. "number": basNumber,
  14511. })
  14512. }
  14513. } else {
  14514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14515. return
  14516. }
  14517. break
  14518. }
  14519. case 2:
  14520. if miConfig.MdtrtareaAdmvs == "430800" {
  14521. if initFlag == 0 {
  14522. c.TestGetHnBasBaseInit()
  14523. }
  14524. SFZStr := c.GetSFZBaseInfo()
  14525. if len(SFZStr) == 0 {
  14526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14527. return
  14528. }
  14529. fmt.Println(SFZStr)
  14530. id_card_str := strings.Split(SFZStr, "^")
  14531. card_no := id_card_str[0]
  14532. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14533. //name := id_card_str[1]
  14534. //name = ConvertToString(name, "gbk", "utf-8")
  14535. 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)
  14536. var dat map[string]interface{}
  14537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14538. fmt.Println(dat)
  14539. } else {
  14540. fmt.Println(err)
  14541. }
  14542. userJSONBytes, _ := json.Marshal(dat)
  14543. var res ResultTwo
  14544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14545. utils.ErrorLog("解析失败:%v", err)
  14546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14547. return
  14548. }
  14549. if res.Infcode == 0 {
  14550. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14551. if err == gorm.ErrRecordNotFound {
  14552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14553. return
  14554. } else if err != nil {
  14555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14556. return
  14557. } else {
  14558. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14559. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14560. infoStr := string(Iinfos)
  14561. idetinfoStr := string(Idetinfos)
  14562. var rf []*ResultFive
  14563. json.Unmarshal([]byte(infoStr), &rf)
  14564. var insutypes []*ResultFive
  14565. var insutype string
  14566. var is390 int = 0
  14567. var is310 int = 0
  14568. for _, item := range rf {
  14569. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14570. insutypes = append(insutypes, item)
  14571. }
  14572. }
  14573. if len(insutypes) == 1 {
  14574. insutype = insutypes[0].Insutype
  14575. } else {
  14576. for _, i := range insutypes {
  14577. if i.Insutype == "390" {
  14578. is390 = 1
  14579. }
  14580. if i.Insutype == "310" {
  14581. is310 = 1
  14582. }
  14583. }
  14584. }
  14585. if is390 == 1 {
  14586. insutype = "390"
  14587. }
  14588. if is310 == 1 {
  14589. insutype = "310"
  14590. }
  14591. if len(insutypes) == 0 {
  14592. insutype = "310"
  14593. }
  14594. var InsuplcAdmdvs string
  14595. for _, item := range rf {
  14596. if item.Insutype == insutype {
  14597. InsuplcAdmdvs = item.InsuplcAdmdvs
  14598. }
  14599. }
  14600. psn := &models.HisPsn{
  14601. PsnNo: res.Output.Baseinfo.PsnNo,
  14602. PatientId: patient.ID,
  14603. Certno: res.Output.Baseinfo.Certno,
  14604. Gend: res.Output.Baseinfo.Gend,
  14605. Naty: res.Output.Baseinfo.Naty,
  14606. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14607. PsnName: res.Output.Baseinfo.PsnName,
  14608. Idetinfo: idetinfoStr,
  14609. Insuinfo: infoStr,
  14610. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14611. CardInfo: SFZStr,
  14612. VerifyNumber: "",
  14613. InsuplcAdmdvs: InsuplcAdmdvs,
  14614. }
  14615. service.CreateHisPsn(psn)
  14616. c.ServeSuccessJSON(map[string]interface{}{
  14617. "patient": patient,
  14618. "number": card_no,
  14619. "insutype": insutype,
  14620. })
  14621. }
  14622. } else {
  14623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14624. return
  14625. }
  14626. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14627. var res ResultTwo
  14628. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14629. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14630. "&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)
  14631. resp, requestErr := http.Get(api)
  14632. if requestErr != nil {
  14633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14634. return
  14635. }
  14636. body, ioErr := ioutil.ReadAll(resp.Body)
  14637. if ioErr != nil {
  14638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14640. return
  14641. }
  14642. var respJSON map[string]interface{}
  14643. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14646. return
  14647. }
  14648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14649. result, _ := json.Marshal(respJSON)
  14650. fmt.Println("log")
  14651. fmt.Println(string(result))
  14652. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14653. utils.ErrorLog("解析失败:%v", err)
  14654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14655. return
  14656. }
  14657. if res.Infcode == 0 {
  14658. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14659. if err == gorm.ErrRecordNotFound {
  14660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14661. return
  14662. } else if err != nil {
  14663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14664. return
  14665. } else {
  14666. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14667. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14668. infoStr := string(Iinfos)
  14669. idetinfoStr := string(Idetinfos)
  14670. psn := &models.HisPsn{
  14671. PsnNo: res.Output.Baseinfo.PsnNo,
  14672. PatientId: patient.ID,
  14673. Certno: res.Output.Baseinfo.Certno,
  14674. Gend: res.Output.Baseinfo.Gend,
  14675. Naty: res.Output.Baseinfo.Naty,
  14676. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14677. PsnName: res.Output.Baseinfo.PsnName,
  14678. Idetinfo: idetinfoStr,
  14679. Insuinfo: infoStr,
  14680. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14681. }
  14682. service.CreateHisPsn(psn)
  14683. c.ServeSuccessJSON(map[string]interface{}{
  14684. "patient": patient,
  14685. "number": res.Output.Baseinfo.Certno,
  14686. })
  14687. }
  14688. } else {
  14689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14690. return
  14691. }
  14692. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14693. var res ResultTwo
  14694. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14695. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14696. "&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)
  14697. resp, requestErr := http.Get(api)
  14698. if requestErr != nil {
  14699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14700. return
  14701. }
  14702. body, ioErr := ioutil.ReadAll(resp.Body)
  14703. if ioErr != nil {
  14704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14706. return
  14707. }
  14708. var respJSON map[string]interface{}
  14709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14712. return
  14713. }
  14714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14715. result, _ := json.Marshal(respJSON)
  14716. fmt.Println("log")
  14717. fmt.Println(string(result))
  14718. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14719. utils.ErrorLog("解析失败:%v", err)
  14720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14721. return
  14722. }
  14723. if res.Infcode == 0 {
  14724. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14725. if err == gorm.ErrRecordNotFound {
  14726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14727. return
  14728. } else if err != nil {
  14729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14730. return
  14731. } else {
  14732. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14733. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14734. infoStr := string(Iinfos)
  14735. idetinfoStr := string(Idetinfos)
  14736. psn := &models.HisPsn{
  14737. PsnNo: res.Output.Baseinfo.PsnNo,
  14738. PatientId: patient.ID,
  14739. Certno: res.Output.Baseinfo.Certno,
  14740. Gend: res.Output.Baseinfo.Gend,
  14741. Naty: res.Output.Baseinfo.Naty,
  14742. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14743. PsnName: res.Output.Baseinfo.PsnName,
  14744. Idetinfo: idetinfoStr,
  14745. Insuinfo: infoStr,
  14746. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14747. }
  14748. service.CreateHisPsn(psn)
  14749. c.ServeSuccessJSON(map[string]interface{}{
  14750. "patient": patient,
  14751. "number": res.Output.Baseinfo.Certno,
  14752. })
  14753. }
  14754. } else {
  14755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14756. return
  14757. }
  14758. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14759. var res ResultTwo
  14760. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14761. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14762. "&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)
  14763. resp, requestErr := http.Get(api)
  14764. if requestErr != nil {
  14765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14766. return
  14767. }
  14768. body, ioErr := ioutil.ReadAll(resp.Body)
  14769. if ioErr != nil {
  14770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14772. return
  14773. }
  14774. var respJSON map[string]interface{}
  14775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14778. return
  14779. }
  14780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14781. result, _ := json.Marshal(respJSON)
  14782. fmt.Println("log")
  14783. fmt.Println(string(result))
  14784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14785. utils.ErrorLog("解析失败:%v", err)
  14786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14787. return
  14788. }
  14789. if res.Infcode == 0 {
  14790. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14791. if err == gorm.ErrRecordNotFound {
  14792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14793. return
  14794. } else if err != nil {
  14795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14796. return
  14797. } else {
  14798. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14799. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14800. infoStr := string(Iinfos)
  14801. idetinfoStr := string(Idetinfos)
  14802. var rf []*ResultFive
  14803. json.Unmarshal([]byte(infoStr), &rf)
  14804. var insutypes []*ResultFive
  14805. var insutype string
  14806. var is390 int = 0
  14807. var is310 int = 0
  14808. for _, item := range rf {
  14809. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14810. insutypes = append(insutypes, item)
  14811. }
  14812. }
  14813. if len(insutypes) == 1 {
  14814. insutype = insutypes[0].Insutype
  14815. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14816. } else {
  14817. for _, i := range insutypes {
  14818. if i.Insutype == "390" {
  14819. is390 = 1
  14820. }
  14821. if i.Insutype == "310" {
  14822. is310 = 1
  14823. }
  14824. }
  14825. }
  14826. if is390 == 1 {
  14827. insutype = "390"
  14828. }
  14829. if is310 == 1 {
  14830. insutype = "310"
  14831. }
  14832. if len(insutypes) == 0 {
  14833. insutype = "390"
  14834. }
  14835. var insuplc_admdvs string
  14836. for _, item := range rf {
  14837. if item.Insutype == insutype {
  14838. insuplc_admdvs = item.InsuplcAdmdvs
  14839. }
  14840. }
  14841. psn := &models.HisPsn{
  14842. PsnNo: res.Output.Baseinfo.PsnNo,
  14843. PatientId: patient.ID,
  14844. Certno: res.Output.Baseinfo.Certno,
  14845. Gend: res.Output.Baseinfo.Gend,
  14846. Naty: res.Output.Baseinfo.Naty,
  14847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14848. PsnName: res.Output.Baseinfo.PsnName,
  14849. Idetinfo: idetinfoStr,
  14850. Insuinfo: infoStr,
  14851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14852. InsuplcAdmdvs: insuplc_admdvs,
  14853. }
  14854. service.CreateHisPsn(psn)
  14855. c.ServeSuccessJSON(map[string]interface{}{
  14856. "patient": patient,
  14857. "number": res.Output.Baseinfo.Certno,
  14858. })
  14859. }
  14860. } else {
  14861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14862. return
  14863. }
  14864. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14865. res := c.GetoleInfo()
  14866. if res.Infcode == 0 {
  14867. var result string
  14868. if res.Output.MdtrtCertType == "01" {
  14869. 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)
  14870. } else if res.Output.MdtrtCertType == "02" {
  14871. 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)
  14872. } else if res.Output.MdtrtCertType == "03" {
  14873. 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)
  14874. }
  14875. var dat map[string]interface{}
  14876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14877. fmt.Println(dat)
  14878. } else {
  14879. fmt.Println(err)
  14880. }
  14881. userJSONBytes, _ := json.Marshal(dat)
  14882. var res2 ResultTwo
  14883. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14884. utils.ErrorLog("解析失败:%v", err)
  14885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14886. return
  14887. }
  14888. if res2.Infcode == 0 {
  14889. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14890. if err == gorm.ErrRecordNotFound {
  14891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14892. return
  14893. } else if err != nil {
  14894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14895. return
  14896. } else {
  14897. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14898. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14899. infoStr := string(Iinfos)
  14900. idetinfoStr := string(Idetinfos)
  14901. var rf []*ResultFive
  14902. json.Unmarshal([]byte(infoStr), &rf)
  14903. var insutypes []*ResultFive
  14904. var insutype string
  14905. var is390 int = 0
  14906. var is310 int = 0
  14907. //var insuplc_admdvs string
  14908. for _, item := range rf {
  14909. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14910. insutypes = append(insutypes, item)
  14911. }
  14912. }
  14913. if len(insutypes) == 1 {
  14914. insutype = insutypes[0].Insutype
  14915. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14916. } else {
  14917. for _, i := range insutypes {
  14918. if i.Insutype == "390" {
  14919. is390 = 1
  14920. }
  14921. if i.Insutype == "310" {
  14922. is310 = 1
  14923. }
  14924. }
  14925. }
  14926. if is390 == 1 {
  14927. insutype = "390"
  14928. }
  14929. if is310 == 1 {
  14930. insutype = "310"
  14931. }
  14932. if len(insutypes) == 0 {
  14933. insutype = "310"
  14934. }
  14935. psn := &models.HisPsn{
  14936. PsnNo: res2.Output.Baseinfo.PsnNo,
  14937. PatientId: patient.ID,
  14938. //Brdy: res2.Output.Baseinfo.Brdy,
  14939. Certno: res2.Output.Baseinfo.Certno,
  14940. Gend: res2.Output.Baseinfo.Gend,
  14941. Naty: res2.Output.Baseinfo.Naty,
  14942. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14943. PsnName: res2.Output.Baseinfo.PsnName,
  14944. Idetinfo: idetinfoStr,
  14945. Insuinfo: infoStr,
  14946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14947. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14948. VerifyNumber: res.Output.EcToken,
  14949. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14950. }
  14951. service.CreateHisPsn(psn)
  14952. var balc float64
  14953. for _, item := range rf {
  14954. if item.Insutype == insutype {
  14955. balc = item.Balc
  14956. }
  14957. }
  14958. c.ServeSuccessJSON(map[string]interface{}{
  14959. "patient": patient,
  14960. "number": res.Output.CardNo,
  14961. "insutype": insutype,
  14962. "blac": balc,
  14963. "desc": idetinfoStr,
  14964. })
  14965. }
  14966. } else {
  14967. c.ServeSuccessJSON(map[string]interface{}{
  14968. "failed_code": -10,
  14969. "msg": res2.ErrMsg,
  14970. })
  14971. }
  14972. } else {
  14973. c.ServeSuccessJSON(map[string]interface{}{
  14974. "failed_code": -10,
  14975. "msg": res.ErrMsg,
  14976. })
  14977. }
  14978. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14979. var insuplc_admdvs string
  14980. if len(patient.InsuplcAdmdvs) > 0 {
  14981. insuplc_admdvs = patient.InsuplcAdmdvs
  14982. } else {
  14983. if len(insuplc_admdvs_str) > 0 {
  14984. insuplc_admdvs = insuplc_admdvs_str
  14985. } else {
  14986. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14987. }
  14988. }
  14989. //请求内网数据
  14990. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14991. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14992. "&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=" + ""
  14993. resp, requestErr := http.Get(api)
  14994. if requestErr != nil {
  14995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14996. return
  14997. }
  14998. body, ioErr := ioutil.ReadAll(resp.Body)
  14999. if ioErr != nil {
  15000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15002. return
  15003. }
  15004. var respJSON map[string]interface{}
  15005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15008. return
  15009. }
  15010. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15011. if status == "0" {
  15012. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15013. c.ServeSuccessJSON(map[string]interface{}{
  15014. "failed_code": -10,
  15015. "msg": err_msg,
  15016. })
  15017. return
  15018. }
  15019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15020. var res ResultTwo
  15021. result, _ := json.Marshal(respJSON)
  15022. fmt.Println("log")
  15023. fmt.Println(string(result))
  15024. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15025. utils.ErrorLog("解析失败:%v", err)
  15026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15027. return
  15028. }
  15029. if res.Infcode == 0 {
  15030. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15031. if err == gorm.ErrRecordNotFound {
  15032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15033. return
  15034. } else if err != nil {
  15035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15036. return
  15037. } else {
  15038. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15039. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15040. infoStr := string(Iinfos)
  15041. idetinfoStr := string(Idetinfos)
  15042. psn := &models.HisPsn{
  15043. PsnNo: res.Output.Baseinfo.PsnNo,
  15044. PatientId: patient.ID,
  15045. Certno: res.Output.Baseinfo.Certno,
  15046. Gend: res.Output.Baseinfo.Gend,
  15047. Naty: res.Output.Baseinfo.Naty,
  15048. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15049. PsnName: res.Output.Baseinfo.PsnName,
  15050. Idetinfo: idetinfoStr,
  15051. Insuinfo: infoStr,
  15052. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15053. }
  15054. service.CreateHisPsn(psn)
  15055. var rf []*ResultFive
  15056. json.Unmarshal([]byte(infoStr), &rf)
  15057. var insutypes []*ResultFive
  15058. var is390 int = 0
  15059. var is310 int = 0
  15060. var insutype string
  15061. for _, item := range rf {
  15062. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15063. insutypes = append(insutypes, item)
  15064. }
  15065. }
  15066. if len(insutypes) == 1 {
  15067. insutype = insutypes[0].Insutype
  15068. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15069. } else {
  15070. for _, i := range insutypes {
  15071. if i.Insutype == "390" {
  15072. is390 = 1
  15073. }
  15074. if i.Insutype == "310" {
  15075. is310 = 1
  15076. }
  15077. }
  15078. }
  15079. if is390 == 1 {
  15080. insutype = "390"
  15081. }
  15082. if is310 == 1 {
  15083. insutype = "310"
  15084. }
  15085. if len(insutypes) == 0 {
  15086. insutype = "390"
  15087. }
  15088. c.ServeSuccessJSON(map[string]interface{}{
  15089. "patient": patient,
  15090. "insutype": insutype,
  15091. "number": res.Output.Baseinfo.Certno,
  15092. "info": res,
  15093. })
  15094. }
  15095. } else {
  15096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15097. return
  15098. }
  15099. } else {
  15100. SFZStr := c.GetSFZBaseInfo()
  15101. id_card_str := strings.Split(SFZStr, "^")
  15102. id_card_number := id_card_str[0]
  15103. card_sn := ""
  15104. 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)
  15105. var dat map[string]interface{}
  15106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15107. fmt.Println(dat)
  15108. } else {
  15109. fmt.Println(err)
  15110. }
  15111. userJSONBytes, _ := json.Marshal(dat)
  15112. var res ResultTwo
  15113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15114. utils.ErrorLog("解析失败:%v", err)
  15115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15116. return
  15117. }
  15118. if res.Infcode == 0 {
  15119. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15120. if err == gorm.ErrRecordNotFound {
  15121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15122. return
  15123. } else if err != nil {
  15124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15125. return
  15126. } else {
  15127. c.ServeSuccessJSON(map[string]interface{}{
  15128. "patient": patient,
  15129. "number": id_card_number,
  15130. })
  15131. }
  15132. } else {
  15133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15134. return
  15135. }
  15136. }
  15137. break
  15138. case 3:
  15139. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15140. var api string
  15141. if miConfig.MdtrtareaAdmvs == "320921" {
  15142. 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 +
  15143. "&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
  15144. fmt.Println(api)
  15145. } else {
  15146. 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 +
  15147. "&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)
  15148. }
  15149. resp, requestErr := http.Get(api)
  15150. if requestErr != nil {
  15151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15152. return
  15153. }
  15154. body, ioErr := ioutil.ReadAll(resp.Body)
  15155. if ioErr != nil {
  15156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15158. return
  15159. }
  15160. var respJSON map[string]interface{}
  15161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15164. return
  15165. }
  15166. var status string
  15167. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15168. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15169. var token string
  15170. var res ResultTwo //1101结果
  15171. var res10265 ResultTwo10265 //1101结果
  15172. var card_info string //卡信息
  15173. var busi_card_info string
  15174. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15175. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15176. if status == "0" { //读卡成功
  15177. if card_type == "1" {
  15178. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15179. result, _ := json.Marshal(respJSON)
  15180. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15181. utils.ErrorLog("解析失败:%v", err)
  15182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15183. return
  15184. }
  15185. res.ErrMsg = res10265.ErrMsg
  15186. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15187. res.Infcode = infocode
  15188. res.Output = res10265.Output
  15189. res.InfRefmsgid = res10265.InfRefmsgid
  15190. } else {
  15191. //var card_info string //卡信息
  15192. //var busi_card_info string
  15193. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15194. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15195. //fmt.Println(card_info)
  15196. //fmt.Println(busi_card_info)
  15197. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15198. result, _ := json.Marshal(respJSON)
  15199. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15200. utils.ErrorLog("解析失败:%v", err)
  15201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15202. return
  15203. }
  15204. res.ErrMsg = res10265.ErrMsg
  15205. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15206. res.Infcode = infocode
  15207. res.Output = res10265.Output
  15208. res.InfRefmsgid = res10265.InfRefmsgid
  15209. }
  15210. if res.Infcode == 0 {
  15211. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15212. if err == gorm.ErrRecordNotFound {
  15213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15214. return
  15215. } else if err != nil {
  15216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15217. return
  15218. } else {
  15219. if card_type == "1" {
  15220. bas := strings.Split(card_info, "|")
  15221. basNumber := bas[2]
  15222. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15223. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15224. infoStr := string(Iinfos)
  15225. idetinfoStr := string(Idetinfos)
  15226. psn := &models.HisPsn{
  15227. PsnNo: res.Output.Baseinfo.PsnNo,
  15228. PatientId: patient.ID,
  15229. Certno: res.Output.Baseinfo.Certno,
  15230. //Brdy: res.Output.Baseinfo.Brdy,
  15231. Gend: res.Output.Baseinfo.Gend,
  15232. Naty: res.Output.Baseinfo.Naty,
  15233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15234. PsnName: res.Output.Baseinfo.PsnName,
  15235. Idetinfo: idetinfoStr,
  15236. Insuinfo: infoStr,
  15237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15238. CardInfo: card_info,
  15239. VerifyNumber: busi_card_info,
  15240. }
  15241. service.CreateHisPsn(psn)
  15242. c.ServeSuccessJSON(map[string]interface{}{
  15243. "patient": patient,
  15244. "number": basNumber,
  15245. })
  15246. } else {
  15247. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15248. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15249. infoStr := string(Iinfos)
  15250. idetinfoStr := string(Idetinfos)
  15251. psn := &models.HisPsn{
  15252. PsnNo: res.Output.Baseinfo.PsnNo,
  15253. PatientId: patient.ID,
  15254. Certno: res.Output.Baseinfo.Certno,
  15255. Gend: res.Output.Baseinfo.Gend,
  15256. Naty: res.Output.Baseinfo.Naty,
  15257. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15258. PsnName: res.Output.Baseinfo.PsnName,
  15259. Idetinfo: idetinfoStr,
  15260. Insuinfo: infoStr,
  15261. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15262. CardInfo: card_info,
  15263. VerifyNumber: token,
  15264. }
  15265. service.CreateHisPsn(psn)
  15266. var rf []*ResultFive
  15267. json.Unmarshal([]byte(infoStr), &rf)
  15268. var insutypes []*ResultFive
  15269. var insutype string
  15270. var is390 int = 0
  15271. var is310 int = 0
  15272. for _, item := range rf {
  15273. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15274. insutypes = append(insutypes, item)
  15275. }
  15276. }
  15277. if len(insutypes) == 1 {
  15278. insutype = insutypes[0].Insutype
  15279. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15280. } else {
  15281. for _, i := range insutypes {
  15282. if i.Insutype == "390" {
  15283. is390 = 1
  15284. }
  15285. if i.Insutype == "310" {
  15286. is310 = 1
  15287. }
  15288. }
  15289. }
  15290. if is390 == 1 {
  15291. insutype = "390"
  15292. }
  15293. if is310 == 1 {
  15294. insutype = "310"
  15295. }
  15296. if len(insutypes) == 0 {
  15297. insutype = "310"
  15298. }
  15299. c.ServeSuccessJSON(map[string]interface{}{
  15300. "patient": patient,
  15301. "number": token,
  15302. "insutype": insutype,
  15303. })
  15304. }
  15305. }
  15306. } else {
  15307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15308. return
  15309. }
  15310. } else { //读卡失败
  15311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15312. return
  15313. }
  15314. }
  15315. break
  15316. case 4:
  15317. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15318. var api string
  15319. if miConfig.MdtrtareaAdmvs == "320921" {
  15320. 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 +
  15321. "&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
  15322. fmt.Println(api)
  15323. } else {
  15324. 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 +
  15325. "&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)
  15326. }
  15327. resp, requestErr := http.Get(api)
  15328. if requestErr != nil {
  15329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15330. return
  15331. }
  15332. body, ioErr := ioutil.ReadAll(resp.Body)
  15333. if ioErr != nil {
  15334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15336. return
  15337. }
  15338. var respJSON map[string]interface{}
  15339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15342. return
  15343. }
  15344. var status string
  15345. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15346. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15347. var token string
  15348. var res ResultTwo //1101结果
  15349. var res10265 ResultTwo10265 //1101结果
  15350. if status == "0" { //读卡成功
  15351. var card_info string //卡信息
  15352. var busi_card_info string
  15353. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15354. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15355. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15356. fmt.Println(card_info)
  15357. fmt.Println(busi_card_info)
  15358. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15359. result, _ := json.Marshal(respJSON)
  15360. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15361. utils.ErrorLog("解析失败:%v", err)
  15362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15363. return
  15364. }
  15365. res.ErrMsg = res10265.ErrMsg
  15366. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15367. res.Infcode = infocode
  15368. res.Output = res10265.Output
  15369. res.InfRefmsgid = res10265.InfRefmsgid
  15370. if res.Infcode == 0 {
  15371. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15372. if err == gorm.ErrRecordNotFound {
  15373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15374. return
  15375. } else if err != nil {
  15376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15377. return
  15378. } else {
  15379. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15380. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15381. infoStr := string(Iinfos)
  15382. idetinfoStr := string(Idetinfos)
  15383. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15384. psn := &models.HisPsn{
  15385. PsnNo: res.Output.Baseinfo.PsnNo,
  15386. PatientId: patient.ID,
  15387. Certno: res.Output.Baseinfo.Certno,
  15388. Brdy: b,
  15389. Age: float64(age),
  15390. //Brdy: res.Output.Baseinfo.Brdy,
  15391. Gend: res.Output.Baseinfo.Gend,
  15392. Naty: res.Output.Baseinfo.Naty,
  15393. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15394. PsnName: res.Output.Baseinfo.PsnName,
  15395. Idetinfo: idetinfoStr,
  15396. Insuinfo: infoStr,
  15397. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15398. CardInfo: card_info,
  15399. VerifyNumber: token,
  15400. }
  15401. var rf []*ResultFive
  15402. json.Unmarshal([]byte(infoStr), &rf)
  15403. var insutypes []*ResultFive
  15404. var insutype string
  15405. var is390 int = 0
  15406. var is310 int = 0
  15407. for _, item := range rf {
  15408. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15409. insutypes = append(insutypes, item)
  15410. }
  15411. }
  15412. if len(insutypes) == 1 {
  15413. insutype = insutypes[0].Insutype
  15414. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15415. } else {
  15416. for _, i := range insutypes {
  15417. if i.Insutype == "390" {
  15418. is390 = 1
  15419. }
  15420. if i.Insutype == "310" {
  15421. is310 = 1
  15422. }
  15423. }
  15424. }
  15425. if is390 == 1 {
  15426. insutype = "390"
  15427. }
  15428. if is310 == 1 {
  15429. insutype = "310"
  15430. }
  15431. if len(insutypes) == 0 {
  15432. insutype = "310"
  15433. }
  15434. service.CreateHisPsn(psn)
  15435. c.ServeSuccessJSON(map[string]interface{}{
  15436. "patient": patient,
  15437. "number": token,
  15438. "insutype": insutype,
  15439. })
  15440. }
  15441. } else {
  15442. c.ServeSuccessJSON(map[string]interface{}{
  15443. "failed_code": -10,
  15444. "msg": res.ErrMsg,
  15445. })
  15446. }
  15447. } else { //读卡失败
  15448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15449. return
  15450. }
  15451. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15452. var api string
  15453. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15454. "&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
  15455. resp, requestErr := http.Get(api)
  15456. if requestErr != nil {
  15457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15458. return
  15459. }
  15460. body, ioErr := ioutil.ReadAll(resp.Body)
  15461. if ioErr != nil {
  15462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15464. return
  15465. }
  15466. var respJSON map[string]interface{}
  15467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15470. return
  15471. }
  15472. var status string
  15473. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15474. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15475. var token string
  15476. var res ResultTwo //1101结果
  15477. if status == "1" { //读卡成功
  15478. var card_info string //卡信息
  15479. var busi_card_info string
  15480. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15481. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15482. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15483. fmt.Println(card_info)
  15484. fmt.Println(busi_card_info)
  15485. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15486. result, _ := json.Marshal(respJSON)
  15487. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15488. utils.ErrorLog("解析失败:%v", err)
  15489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15490. return
  15491. }
  15492. if res.Infcode == 0 {
  15493. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15494. if err == gorm.ErrRecordNotFound {
  15495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15496. return
  15497. } else if err != nil {
  15498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15499. return
  15500. } else {
  15501. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15502. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15503. infoStr := string(Iinfos)
  15504. idetinfoStr := string(Idetinfos)
  15505. psn := &models.HisPsn{
  15506. PsnNo: res.Output.Baseinfo.PsnNo,
  15507. PatientId: patient.ID,
  15508. Certno: res.Output.Baseinfo.Certno,
  15509. Gend: res.Output.Baseinfo.Gend,
  15510. Naty: res.Output.Baseinfo.Naty,
  15511. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15512. PsnName: res.Output.Baseinfo.PsnName,
  15513. Idetinfo: idetinfoStr,
  15514. Insuinfo: infoStr,
  15515. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15516. CardInfo: card_info,
  15517. VerifyNumber: token,
  15518. }
  15519. var rf []*ResultFive
  15520. json.Unmarshal([]byte(infoStr), &rf)
  15521. var insutypes []*ResultFive
  15522. var insutype string
  15523. var is390 int = 0
  15524. var is310 int = 0
  15525. for _, item := range rf {
  15526. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15527. insutypes = append(insutypes, item)
  15528. }
  15529. }
  15530. if len(insutypes) == 1 {
  15531. insutype = insutypes[0].Insutype
  15532. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15533. } else {
  15534. for _, i := range insutypes {
  15535. if i.Insutype == "390" {
  15536. is390 = 1
  15537. }
  15538. if i.Insutype == "310" {
  15539. is310 = 1
  15540. }
  15541. }
  15542. }
  15543. if is390 == 1 {
  15544. insutype = "390"
  15545. }
  15546. if is310 == 1 {
  15547. insutype = "310"
  15548. }
  15549. if len(insutypes) == 0 {
  15550. insutype = "310"
  15551. }
  15552. service.CreateHisPsn(psn)
  15553. c.ServeSuccessJSON(map[string]interface{}{
  15554. "patient": patient,
  15555. "number": token,
  15556. "insutype": insutype,
  15557. })
  15558. }
  15559. } else {
  15560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15561. return
  15562. }
  15563. } else { //读卡失败
  15564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15565. return
  15566. }
  15567. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15568. var api string
  15569. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15570. "&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
  15571. resp, requestErr := http.Get(api)
  15572. if requestErr != nil {
  15573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15574. return
  15575. }
  15576. body, ioErr := ioutil.ReadAll(resp.Body)
  15577. if ioErr != nil {
  15578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15580. return
  15581. }
  15582. var respJSON map[string]interface{}
  15583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15586. return
  15587. }
  15588. var status string
  15589. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15590. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15591. var token string
  15592. var res ResultTwo //1101结果
  15593. if status == "1" { //读卡成功
  15594. var card_info string //卡信息
  15595. var busi_card_info string
  15596. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15597. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15598. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15599. fmt.Println(card_info)
  15600. fmt.Println(busi_card_info)
  15601. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15602. result, _ := json.Marshal(respJSON)
  15603. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15604. utils.ErrorLog("解析失败:%v", err)
  15605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15606. return
  15607. }
  15608. if res.Infcode == 0 {
  15609. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15610. if err == gorm.ErrRecordNotFound {
  15611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15612. return
  15613. } else if err != nil {
  15614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15615. return
  15616. } else {
  15617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15618. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15619. infoStr := string(Iinfos)
  15620. idetinfoStr := string(Idetinfos)
  15621. psn := &models.HisPsn{
  15622. PsnNo: res.Output.Baseinfo.PsnNo,
  15623. PatientId: patient.ID,
  15624. Certno: res.Output.Baseinfo.Certno,
  15625. Gend: res.Output.Baseinfo.Gend,
  15626. Naty: res.Output.Baseinfo.Naty,
  15627. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15628. PsnName: res.Output.Baseinfo.PsnName,
  15629. Idetinfo: idetinfoStr,
  15630. Insuinfo: infoStr,
  15631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15632. CardInfo: card_info,
  15633. VerifyNumber: token,
  15634. }
  15635. var rf []*ResultFive
  15636. json.Unmarshal([]byte(infoStr), &rf)
  15637. var insutypes []*ResultFive
  15638. var insutype string
  15639. var is390 int = 0
  15640. var is310 int = 0
  15641. for _, item := range rf {
  15642. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15643. insutypes = append(insutypes, item)
  15644. }
  15645. }
  15646. if len(insutypes) == 1 {
  15647. insutype = insutypes[0].Insutype
  15648. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15649. } else {
  15650. for _, i := range insutypes {
  15651. if i.Insutype == "390" {
  15652. is390 = 1
  15653. }
  15654. if i.Insutype == "310" {
  15655. is310 = 1
  15656. }
  15657. }
  15658. }
  15659. if is390 == 1 {
  15660. insutype = "390"
  15661. }
  15662. if is310 == 1 {
  15663. insutype = "310"
  15664. }
  15665. if len(insutypes) == 0 {
  15666. insutype = "310"
  15667. }
  15668. service.CreateHisPsn(psn)
  15669. c.ServeSuccessJSON(map[string]interface{}{
  15670. "patient": patient,
  15671. "number": token,
  15672. "insutype": insutype,
  15673. })
  15674. }
  15675. } else {
  15676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15677. return
  15678. }
  15679. } else { //读卡失败
  15680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15681. return
  15682. }
  15683. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15684. //idNo := c.GetString("idNo")
  15685. //userName := c.GetString("userName")
  15686. //ecToken := c.GetString("ecToken")
  15687. //insuOrg := c.GetString("insuOrg")
  15688. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15689. utils.ErrorLog("解析失败:%v", json_result)
  15690. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15691. type ELeData struct {
  15692. Data struct {
  15693. IdNo string `json:"idNo"`
  15694. IdType string `json:"idType"`
  15695. UserName string `json:"userName"`
  15696. EcToken string `json:"ecToken"`
  15697. InsuOrg string `json:"insuOrg"`
  15698. Gender string `json:"gender"`
  15699. Birthday string `json:"birthday"`
  15700. Nationality string `json:"nationality"`
  15701. Email string `json:"email"`
  15702. Extra string `json:"extra"`
  15703. } `json:"data"`
  15704. Code int `json:"code"`
  15705. Message string `json:"message"`
  15706. }
  15707. var ele ELeData
  15708. err := json.Unmarshal([]byte(json_result), &ele)
  15709. if err != nil {
  15710. utils.ErrorLog("解析失败:%v", err)
  15711. }
  15712. token := ele.Data.EcToken
  15713. token = Remove0000(token)
  15714. 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)
  15715. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15716. var res ResultTwo
  15717. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15718. utils.ErrorLog("解析失败:%v", err)
  15719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15720. return
  15721. }
  15722. if res.Infcode == 0 {
  15723. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15724. if err == gorm.ErrRecordNotFound {
  15725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15726. return
  15727. } else if err != nil {
  15728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15729. return
  15730. } else {
  15731. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15732. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15733. infoStr := string(Iinfos)
  15734. idetinfoStr := string(Idetinfos)
  15735. psn := &models.HisPsn{
  15736. PsnNo: res.Output.Baseinfo.PsnNo,
  15737. PatientId: patient.ID,
  15738. Certno: res.Output.Baseinfo.Certno,
  15739. Gend: res.Output.Baseinfo.Gend,
  15740. Naty: res.Output.Baseinfo.Naty,
  15741. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15742. PsnName: res.Output.Baseinfo.PsnName,
  15743. Idetinfo: idetinfoStr,
  15744. Insuinfo: infoStr,
  15745. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15746. CardInfo: "",
  15747. Stage: "1",
  15748. VerifyNumber: token,
  15749. InsuplcAdmdvs: ele.Data.InsuOrg,
  15750. }
  15751. service.CreateHisPsn(psn)
  15752. var rf []*ResultFive
  15753. json.Unmarshal([]byte(infoStr), &rf)
  15754. var insutypes []*ResultFive
  15755. var insutype string
  15756. var is390 int = 0
  15757. var is310 int = 0
  15758. for _, item := range rf {
  15759. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15760. insutypes = append(insutypes, item)
  15761. }
  15762. }
  15763. if len(insutypes) == 1 {
  15764. insutype = insutypes[0].Insutype
  15765. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15766. } else {
  15767. for _, i := range insutypes {
  15768. if i.Insutype == "390" {
  15769. is390 = 1
  15770. }
  15771. if i.Insutype == "310" {
  15772. is310 = 1
  15773. }
  15774. }
  15775. }
  15776. if is390 == 1 {
  15777. insutype = "390"
  15778. }
  15779. if is310 == 1 {
  15780. insutype = "310"
  15781. }
  15782. if len(insutypes) == 0 {
  15783. insutype = "310"
  15784. }
  15785. c.ServeSuccessJSON(map[string]interface{}{
  15786. "patient": patient,
  15787. "number": token,
  15788. "insutype": insutype,
  15789. })
  15790. }
  15791. } else {
  15792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15793. return
  15794. }
  15795. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15796. //if initFlag == 0 {
  15797. //c.TestGetJiangXiBasBaseInit()
  15798. //}
  15799. //if initEleFlag == 0 {
  15800. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15801. //}
  15802. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15803. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15804. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15805. type ELeData struct {
  15806. Data struct {
  15807. IdNo string `json:"idNo"`
  15808. IdType string `json:"idType"`
  15809. UserName string `json:"userName"`
  15810. EcToken string `json:"ecToken"`
  15811. InsuOrg string `json:"insuOrg"`
  15812. Gender string `json:"gender"`
  15813. Birthday string `json:"birthday"`
  15814. Nationality string `json:"nationality"`
  15815. Email string `json:"email"`
  15816. Extra string `json:"extra"`
  15817. } `json:"data"`
  15818. Code int `json:"code"`
  15819. Message string `json:"message"`
  15820. }
  15821. var ele ELeData
  15822. err := json.Unmarshal([]byte(result), &ele)
  15823. if err != nil {
  15824. utils.ErrorLog("解析失败:%v", err)
  15825. }
  15826. token := ele.Data.EcToken
  15827. token = Remove0000(token)
  15828. 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)
  15829. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15830. var res ResultTwo
  15831. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15832. utils.ErrorLog("解析失败:%v", err)
  15833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15834. return
  15835. }
  15836. if res.Infcode == 0 {
  15837. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15838. if err == gorm.ErrRecordNotFound {
  15839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15840. return
  15841. } else if err != nil {
  15842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15843. return
  15844. } else {
  15845. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15846. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15847. infoStr := string(Iinfos)
  15848. idetinfoStr := string(Idetinfos)
  15849. psn := &models.HisPsn{
  15850. PsnNo: res.Output.Baseinfo.PsnNo,
  15851. PatientId: patient.ID,
  15852. Certno: res.Output.Baseinfo.Certno,
  15853. Gend: res.Output.Baseinfo.Gend,
  15854. Naty: res.Output.Baseinfo.Naty,
  15855. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15856. PsnName: res.Output.Baseinfo.PsnName,
  15857. Idetinfo: idetinfoStr,
  15858. Insuinfo: infoStr,
  15859. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15860. CardInfo: "",
  15861. VerifyNumber: token,
  15862. InsuplcAdmdvs: ele.Data.InsuOrg,
  15863. }
  15864. service.CreateHisPsn(psn)
  15865. var rf []*ResultFive
  15866. json.Unmarshal([]byte(infoStr), &rf)
  15867. var insutypes []*ResultFive
  15868. var insutype string
  15869. var is390 int = 0
  15870. var is310 int = 0
  15871. for _, item := range rf {
  15872. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15873. insutypes = append(insutypes, item)
  15874. }
  15875. }
  15876. if len(insutypes) == 1 {
  15877. insutype = insutypes[0].Insutype
  15878. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15879. } else {
  15880. for _, i := range insutypes {
  15881. if i.Insutype == "390" {
  15882. is390 = 1
  15883. }
  15884. if i.Insutype == "310" {
  15885. is310 = 1
  15886. }
  15887. }
  15888. }
  15889. if is390 == 1 {
  15890. insutype = "390"
  15891. }
  15892. if is310 == 1 {
  15893. insutype = "310"
  15894. }
  15895. if len(insutypes) == 0 {
  15896. insutype = "310"
  15897. }
  15898. c.ServeSuccessJSON(map[string]interface{}{
  15899. "patient": patient,
  15900. "number": token,
  15901. "insutype": insutype,
  15902. })
  15903. }
  15904. } else {
  15905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15906. return
  15907. }
  15908. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15909. //if initFlag == 0 {
  15910. //c.TestGetJiangXiBasBaseInit()
  15911. //}
  15912. //if initEleFlag == 0 {
  15913. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15914. //}
  15915. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15916. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15917. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15918. type ELeData struct {
  15919. Data struct {
  15920. IdNo string `json:"idNo"`
  15921. IdType string `json:"idType"`
  15922. UserName string `json:"userName"`
  15923. EcToken string `json:"ecToken"`
  15924. InsuOrg string `json:"insuOrg"`
  15925. Gender string `json:"gender"`
  15926. Birthday string `json:"birthday"`
  15927. Nationality string `json:"nationality"`
  15928. Email string `json:"email"`
  15929. Extra string `json:"extra"`
  15930. } `json:"data"`
  15931. Code int `json:"code"`
  15932. Message string `json:"message"`
  15933. }
  15934. var ele ELeData
  15935. err := json.Unmarshal([]byte(result), &ele)
  15936. if err != nil {
  15937. utils.ErrorLog("解析失败:%v", err)
  15938. }
  15939. token := ele.Data.EcToken
  15940. token = Remove0000(token)
  15941. 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)
  15942. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15943. var res ResultTwo
  15944. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15945. utils.ErrorLog("解析失败:%v", err)
  15946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15947. return
  15948. }
  15949. if res.Infcode == 0 {
  15950. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15951. if err == gorm.ErrRecordNotFound {
  15952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15953. return
  15954. } else if err != nil {
  15955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15956. return
  15957. } else {
  15958. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15959. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15960. infoStr := string(Iinfos)
  15961. idetinfoStr := string(Idetinfos)
  15962. psn := &models.HisPsn{
  15963. PsnNo: res.Output.Baseinfo.PsnNo,
  15964. PatientId: patient.ID,
  15965. Certno: res.Output.Baseinfo.Certno,
  15966. Gend: res.Output.Baseinfo.Gend,
  15967. Naty: res.Output.Baseinfo.Naty,
  15968. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15969. PsnName: res.Output.Baseinfo.PsnName,
  15970. Idetinfo: idetinfoStr,
  15971. Insuinfo: infoStr,
  15972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15973. CardInfo: "",
  15974. VerifyNumber: token,
  15975. InsuplcAdmdvs: ele.Data.InsuOrg,
  15976. }
  15977. service.CreateHisPsn(psn)
  15978. var rf []*ResultFive
  15979. json.Unmarshal([]byte(infoStr), &rf)
  15980. var insutypes []*ResultFive
  15981. var insutype string
  15982. var is390 int = 0
  15983. var is310 int = 0
  15984. for _, item := range rf {
  15985. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15986. insutypes = append(insutypes, item)
  15987. }
  15988. }
  15989. if len(insutypes) == 1 {
  15990. insutype = insutypes[0].Insutype
  15991. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15992. } else {
  15993. for _, i := range insutypes {
  15994. if i.Insutype == "390" {
  15995. is390 = 1
  15996. }
  15997. if i.Insutype == "310" {
  15998. is310 = 1
  15999. }
  16000. }
  16001. }
  16002. if is390 == 1 {
  16003. insutype = "390"
  16004. }
  16005. if is310 == 1 {
  16006. insutype = "310"
  16007. }
  16008. if len(insutypes) == 0 {
  16009. insutype = "310"
  16010. }
  16011. c.ServeSuccessJSON(map[string]interface{}{
  16012. "patient": patient,
  16013. "number": token,
  16014. "insutype": insutype,
  16015. })
  16016. }
  16017. } else {
  16018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16019. return
  16020. }
  16021. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16022. //if initFlag == 0 {
  16023. c.TestGetJiangXiBasBaseInit()
  16024. //}
  16025. //if initEleFlag == 0 {
  16026. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16027. //}
  16028. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16029. type ELeData struct {
  16030. Data struct {
  16031. IdNo string `json:"idNo"`
  16032. IdType string `json:"idType"`
  16033. UserName string `json:"userName"`
  16034. EcToken string `json:"ecToken"`
  16035. InsuOrg string `json:"insuOrg"`
  16036. Gender string `json:"gender"`
  16037. Birthday string `json:"birthday"`
  16038. Nationality string `json:"nationality"`
  16039. Email string `json:"email"`
  16040. Extra string `json:"extra"`
  16041. } `json:"data"`
  16042. Code int `json:"code"`
  16043. Message string `json:"message"`
  16044. }
  16045. var ele ELeData
  16046. err := json.Unmarshal([]byte(json_result), &ele)
  16047. if err != nil {
  16048. utils.ErrorLog("解析失败:%v", err)
  16049. }
  16050. token := ele.Data.EcToken
  16051. token = Remove0000(token)
  16052. 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)
  16053. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16054. var res ResultTwo
  16055. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16056. utils.ErrorLog("解析失败:%v", err)
  16057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16058. return
  16059. }
  16060. if res.Infcode == 0 {
  16061. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16062. if err == gorm.ErrRecordNotFound {
  16063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16064. return
  16065. } else if err != nil {
  16066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16067. return
  16068. } else {
  16069. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16070. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16071. infoStr := string(Iinfos)
  16072. idetinfoStr := string(Idetinfos)
  16073. psn := &models.HisPsn{
  16074. PsnNo: res.Output.Baseinfo.PsnNo,
  16075. PatientId: patient.ID,
  16076. Certno: res.Output.Baseinfo.Certno,
  16077. Gend: res.Output.Baseinfo.Gend,
  16078. Naty: res.Output.Baseinfo.Naty,
  16079. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16080. PsnName: res.Output.Baseinfo.PsnName,
  16081. Idetinfo: idetinfoStr,
  16082. Insuinfo: infoStr,
  16083. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16084. CardInfo: "",
  16085. VerifyNumber: token,
  16086. }
  16087. service.CreateHisPsn(psn)
  16088. var rf []*ResultFive
  16089. json.Unmarshal([]byte(infoStr), &rf)
  16090. var insutypes []*ResultFive
  16091. var insutype string
  16092. var is390 int = 0
  16093. var is310 int = 0
  16094. for _, item := range rf {
  16095. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16096. insutypes = append(insutypes, item)
  16097. }
  16098. }
  16099. if len(insutypes) == 1 {
  16100. insutype = insutypes[0].Insutype
  16101. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16102. } else {
  16103. for _, i := range insutypes {
  16104. if i.Insutype == "390" {
  16105. is390 = 1
  16106. }
  16107. if i.Insutype == "310" {
  16108. is310 = 1
  16109. }
  16110. }
  16111. }
  16112. if is390 == 1 {
  16113. insutype = "390"
  16114. }
  16115. if is310 == 1 {
  16116. insutype = "310"
  16117. }
  16118. if len(insutypes) == 0 {
  16119. insutype = "310"
  16120. }
  16121. c.ServeSuccessJSON(map[string]interface{}{
  16122. "patient": patient,
  16123. "number": token,
  16124. "insutype": insutype,
  16125. })
  16126. }
  16127. } else {
  16128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16129. return
  16130. }
  16131. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16132. type ELeData struct {
  16133. Code string `json:"code"`
  16134. Data struct {
  16135. Aac002 string `json:"aac002"`
  16136. Aaz500 string `json:"aaz500"`
  16137. ActCardNo string `json:"actCardNo"`
  16138. Bab520 string `json:"bab520"`
  16139. Bkz543 string `json:"bkz543"`
  16140. BusinessType string `json:"businessType"`
  16141. CertfCodg string `json:"certfCodg"`
  16142. EcIndexNo string `json:"ecIndexNo"`
  16143. EcToken string `json:"ecToken"`
  16144. ID0000 string `json:"id0000"`
  16145. IDNo string `json:"idNo"`
  16146. IDType string `json:"idType"`
  16147. Idcode string `json:"idcode"`
  16148. IdentityToken string `json:"identity_token"`
  16149. InsuOrg string `json:"insuOrg"`
  16150. OfficeID string `json:"officeId"`
  16151. OfficeName string `json:"officeName"`
  16152. OperatorID string `json:"operatorId"`
  16153. OperatorName string `json:"operatorName"`
  16154. OrgID string `json:"orgId"`
  16155. UserName string `json:"userName"`
  16156. } `json:"data"`
  16157. Infno interface{} `json:"infno"`
  16158. Message string `json:"message"`
  16159. OrgID string `json:"orgId"`
  16160. TransType string `json:"transType"`
  16161. }
  16162. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16163. outPutInfo = Remove0000(outPutInfo)
  16164. if len(outPutInfo) > 0 {
  16165. var ele ELeData
  16166. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16167. if err != nil {
  16168. utils.ErrorLog("解析失败:%v", err)
  16169. }
  16170. token := ele.Data.EcToken
  16171. fmt.Println(inputInfo)
  16172. fmt.Println(outPutInfo)
  16173. 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)
  16174. saveLog(result, requestLog, "1101", "获取人员信息")
  16175. var dat map[string]interface{}
  16176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16177. fmt.Println(dat)
  16178. } else {
  16179. fmt.Println(err)
  16180. }
  16181. userJSONBytes, _ := json.Marshal(dat)
  16182. var res ResultTwo
  16183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16184. utils.ErrorLog("解析失败:%v", err)
  16185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16186. return
  16187. }
  16188. res.ErrMsg = errMsgLog
  16189. if res.Infcode == 0 {
  16190. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16191. if err == gorm.ErrRecordNotFound {
  16192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16193. return
  16194. } else if err != nil {
  16195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16196. return
  16197. } else {
  16198. fmt.Println(res)
  16199. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16200. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16201. infoStr := string(Iinfos)
  16202. idetinfoStr := string(Idetinfos)
  16203. psn := &models.HisPsn{
  16204. PsnNo: res.Output.Baseinfo.PsnNo,
  16205. PatientId: patient.ID,
  16206. Certno: res.Output.Baseinfo.Certno,
  16207. Gend: res.Output.Baseinfo.Gend,
  16208. Naty: res.Output.Baseinfo.Naty,
  16209. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16210. PsnName: res.Output.Baseinfo.PsnName,
  16211. Idetinfo: idetinfoStr,
  16212. Insuinfo: infoStr,
  16213. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16214. CardInfo: outPutInfo,
  16215. VerifyNumber: token,
  16216. InsuplcAdmdvs: ele.Data.InsuOrg,
  16217. }
  16218. service.CreateHisPsn(psn)
  16219. var rf []*ResultFive
  16220. json.Unmarshal([]byte(infoStr), &rf)
  16221. var insutypes []*ResultFive
  16222. var insutype string
  16223. var is390 int = 0
  16224. var is310 int = 0
  16225. for _, item := range rf {
  16226. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16227. insutypes = append(insutypes, item)
  16228. }
  16229. }
  16230. if len(insutypes) == 1 {
  16231. insutype = insutypes[0].Insutype
  16232. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16233. } else {
  16234. for _, i := range insutypes {
  16235. if i.Insutype == "390" {
  16236. is390 = 1
  16237. }
  16238. if i.Insutype == "310" {
  16239. is310 = 1
  16240. }
  16241. }
  16242. }
  16243. if is390 == 1 {
  16244. insutype = "390"
  16245. }
  16246. if is310 == 1 {
  16247. insutype = "310"
  16248. }
  16249. if len(insutypes) == 0 {
  16250. insutype = "310"
  16251. }
  16252. c.ServeSuccessJSON(map[string]interface{}{
  16253. "patient": patient,
  16254. "number": token,
  16255. "insutype": insutype,
  16256. })
  16257. }
  16258. } else {
  16259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16260. return
  16261. }
  16262. }
  16263. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16264. var api string
  16265. 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 +
  16266. "&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
  16267. resp, requestErr := http.Get(api)
  16268. if requestErr != nil {
  16269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16270. return
  16271. }
  16272. body, ioErr := ioutil.ReadAll(resp.Body)
  16273. if ioErr != nil {
  16274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16276. return
  16277. }
  16278. var respJSON map[string]interface{}
  16279. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16282. return
  16283. }
  16284. var status string
  16285. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16286. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16287. var token string
  16288. var res ResultTwo //1101结果
  16289. var res10265 ResultTwo10265 //1101结果
  16290. if status == "0" { //读卡成功
  16291. var card_info string //卡信息
  16292. var busi_card_info string
  16293. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16294. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16295. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16296. fmt.Println(card_info)
  16297. fmt.Println(busi_card_info)
  16298. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16299. result, _ := json.Marshal(respJSON)
  16300. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16301. utils.ErrorLog("解析失败:%v", err)
  16302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16303. return
  16304. }
  16305. res.ErrMsg = res10265.ErrMsg
  16306. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16307. res.Infcode = infocode
  16308. res.Output = res10265.Output
  16309. res.InfRefmsgid = res10265.InfRefmsgid
  16310. if res.Infcode == 0 {
  16311. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16312. if err == gorm.ErrRecordNotFound {
  16313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16314. return
  16315. } else if err != nil {
  16316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16317. return
  16318. } else {
  16319. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16320. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16321. infoStr := string(Iinfos)
  16322. idetinfoStr := string(Idetinfos)
  16323. psn := &models.HisPsn{
  16324. PsnNo: res.Output.Baseinfo.PsnNo,
  16325. PatientId: patient.ID,
  16326. Certno: res.Output.Baseinfo.Certno,
  16327. Gend: res.Output.Baseinfo.Gend,
  16328. Naty: res.Output.Baseinfo.Naty,
  16329. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16330. PsnName: res.Output.Baseinfo.PsnName,
  16331. Idetinfo: idetinfoStr,
  16332. Insuinfo: infoStr,
  16333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16334. CardInfo: card_info,
  16335. VerifyNumber: token,
  16336. }
  16337. var rf []*ResultFive
  16338. json.Unmarshal([]byte(infoStr), &rf)
  16339. var insutypes []*ResultFive
  16340. var insutype string
  16341. var is390 int = 0
  16342. var is310 int = 0
  16343. for _, item := range rf {
  16344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16345. insutypes = append(insutypes, item)
  16346. }
  16347. }
  16348. if len(insutypes) == 1 {
  16349. insutype = insutypes[0].Insutype
  16350. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16351. } else {
  16352. for _, i := range insutypes {
  16353. if i.Insutype == "390" {
  16354. is390 = 1
  16355. }
  16356. if i.Insutype == "310" {
  16357. is310 = 1
  16358. }
  16359. }
  16360. }
  16361. if is390 == 1 {
  16362. insutype = "390"
  16363. }
  16364. if is310 == 1 {
  16365. insutype = "310"
  16366. }
  16367. if len(insutypes) == 0 {
  16368. insutype = "310"
  16369. }
  16370. service.CreateHisPsn(psn)
  16371. c.ServeSuccessJSON(map[string]interface{}{
  16372. "patient": patient,
  16373. "number": token,
  16374. "insutype": insutype,
  16375. })
  16376. }
  16377. } else {
  16378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16379. return
  16380. }
  16381. } else { //读卡失败
  16382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16383. return
  16384. }
  16385. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16386. res := c.GetoleInfo()
  16387. if res.Infcode == 0 {
  16388. var result string
  16389. if res.Output.MdtrtCertType == "01" {
  16390. 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)
  16391. } else if res.Output.MdtrtCertType == "02" {
  16392. 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)
  16393. } else if res.Output.MdtrtCertType == "03" {
  16394. 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)
  16395. }
  16396. var dat map[string]interface{}
  16397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16398. fmt.Println(dat)
  16399. } else {
  16400. fmt.Println(err)
  16401. }
  16402. userJSONBytes, _ := json.Marshal(dat)
  16403. var res2 ResultTwo
  16404. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16405. utils.ErrorLog("解析失败:%v", err)
  16406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16407. return
  16408. }
  16409. if res2.Infcode == 0 {
  16410. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16411. if err == gorm.ErrRecordNotFound {
  16412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16413. return
  16414. } else if err != nil {
  16415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16416. return
  16417. } else {
  16418. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16419. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16420. infoStr := string(Iinfos)
  16421. idetinfoStr := string(Idetinfos)
  16422. var rf []*ResultFive
  16423. json.Unmarshal([]byte(infoStr), &rf)
  16424. var insutypes []*ResultFive
  16425. var insutype string
  16426. var is390 int = 0
  16427. var is310 int = 0
  16428. //var insuplc_admdvs string
  16429. for _, item := range rf {
  16430. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16431. insutypes = append(insutypes, item)
  16432. }
  16433. }
  16434. if len(insutypes) == 1 {
  16435. insutype = insutypes[0].Insutype
  16436. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16437. } else {
  16438. for _, i := range insutypes {
  16439. if i.Insutype == "390" {
  16440. is390 = 1
  16441. }
  16442. if i.Insutype == "310" {
  16443. is310 = 1
  16444. }
  16445. }
  16446. }
  16447. if is390 == 1 {
  16448. insutype = "390"
  16449. }
  16450. if is310 == 1 {
  16451. insutype = "310"
  16452. }
  16453. if len(insutypes) == 0 {
  16454. insutype = "310"
  16455. }
  16456. psn := &models.HisPsn{
  16457. PsnNo: res2.Output.Baseinfo.PsnNo,
  16458. PatientId: patient.ID,
  16459. Certno: res2.Output.Baseinfo.Certno,
  16460. Gend: res2.Output.Baseinfo.Gend,
  16461. Naty: res2.Output.Baseinfo.Naty,
  16462. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16463. PsnName: res2.Output.Baseinfo.PsnName,
  16464. Idetinfo: idetinfoStr,
  16465. Insuinfo: infoStr,
  16466. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16467. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16468. VerifyNumber: res.Output.EcToken,
  16469. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16470. }
  16471. if res.Output.MdtrtCertType == "01" {
  16472. psn.VerifyNumber = res.Output.EcToken
  16473. //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)
  16474. } else if res.Output.MdtrtCertType == "02" {
  16475. psn.VerifyNumber = res.Output.CardNo
  16476. //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)
  16477. } else if res.Output.MdtrtCertType == "03" {
  16478. psn.VerifyNumber = res.Output.MdtrtCertNo
  16479. //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)
  16480. }
  16481. service.CreateHisPsn(psn)
  16482. var balc float64
  16483. for _, item := range rf {
  16484. if item.Insutype == insutype {
  16485. balc = item.Balc
  16486. }
  16487. }
  16488. c.ServeSuccessJSON(map[string]interface{}{
  16489. "patient": patient,
  16490. "number": res.Output.CardNo,
  16491. "insutype": insutype,
  16492. "blac": balc,
  16493. "desc": idetinfoStr,
  16494. })
  16495. }
  16496. } else {
  16497. c.ServeSuccessJSON(map[string]interface{}{
  16498. "failed_code": -10,
  16499. "msg": res2.ErrMsg,
  16500. })
  16501. }
  16502. } else {
  16503. c.ServeSuccessJSON(map[string]interface{}{
  16504. "failed_code": -10,
  16505. "msg": res.ErrMsg,
  16506. })
  16507. }
  16508. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16509. var res ResultTwo
  16510. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16511. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16512. "&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)
  16513. resp, requestErr := http.Get(api)
  16514. if requestErr != nil {
  16515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16516. return
  16517. }
  16518. body, ioErr := ioutil.ReadAll(resp.Body)
  16519. if ioErr != nil {
  16520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16522. return
  16523. }
  16524. var respJSON map[string]interface{}
  16525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16528. return
  16529. }
  16530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16531. result, _ := json.Marshal(respJSON)
  16532. fmt.Println("log")
  16533. fmt.Println(string(result))
  16534. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16535. utils.ErrorLog("解析失败:%v", err)
  16536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16537. return
  16538. }
  16539. if res.Infcode == 0 {
  16540. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16541. if err == gorm.ErrRecordNotFound {
  16542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16543. return
  16544. } else if err != nil {
  16545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16546. return
  16547. } else {
  16548. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16549. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16550. infoStr := string(Iinfos)
  16551. idetinfoStr := string(Idetinfos)
  16552. var rf []*ResultFive
  16553. json.Unmarshal([]byte(infoStr), &rf)
  16554. var insutypes []*ResultFive
  16555. var insutype string
  16556. var is390 int = 0
  16557. var is310 int = 0
  16558. for _, item := range rf {
  16559. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16560. insutypes = append(insutypes, item)
  16561. }
  16562. }
  16563. if len(insutypes) == 1 {
  16564. insutype = insutypes[0].Insutype
  16565. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16566. } else {
  16567. for _, i := range insutypes {
  16568. if i.Insutype == "390" {
  16569. is390 = 1
  16570. }
  16571. if i.Insutype == "310" {
  16572. is310 = 1
  16573. }
  16574. }
  16575. }
  16576. if is390 == 1 {
  16577. insutype = "390"
  16578. }
  16579. if is310 == 1 {
  16580. insutype = "310"
  16581. }
  16582. if len(insutypes) == 0 {
  16583. insutype = "390"
  16584. }
  16585. var insuplc_admdvs string
  16586. for _, item := range rf {
  16587. if item.Insutype == insutype {
  16588. insuplc_admdvs = item.InsuplcAdmdvs
  16589. }
  16590. }
  16591. psn := &models.HisPsn{
  16592. PsnNo: res.Output.Baseinfo.PsnNo,
  16593. PatientId: patient.ID,
  16594. Certno: res.Output.Baseinfo.Certno,
  16595. Gend: res.Output.Baseinfo.Gend,
  16596. Naty: res.Output.Baseinfo.Naty,
  16597. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16598. PsnName: res.Output.Baseinfo.PsnName,
  16599. Idetinfo: idetinfoStr,
  16600. Insuinfo: infoStr,
  16601. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16602. InsuplcAdmdvs: insuplc_admdvs,
  16603. }
  16604. service.CreateHisPsn(psn)
  16605. c.ServeSuccessJSON(map[string]interface{}{
  16606. "patient": patient,
  16607. "number": res.Output.Baseinfo.Certno,
  16608. })
  16609. }
  16610. } else {
  16611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16612. return
  16613. }
  16614. } else {
  16615. type ELeData struct {
  16616. Code string `json:"code"`
  16617. Data struct {
  16618. Aac002 string `json:"aac002"`
  16619. Aaz500 string `json:"aaz500"`
  16620. ActCardNo string `json:"actCardNo"`
  16621. Bab520 string `json:"bab520"`
  16622. Bkz543 string `json:"bkz543"`
  16623. BusinessType string `json:"businessType"`
  16624. CertfCodg string `json:"certfCodg"`
  16625. EcIndexNo string `json:"ecIndexNo"`
  16626. EcToken string `json:"ecToken"`
  16627. ID0000 string `json:"id0000"`
  16628. IDNo string `json:"idNo"`
  16629. IDType string `json:"idType"`
  16630. Idcode string `json:"idcode"`
  16631. IdentityToken string `json:"identity_token"`
  16632. InsuOrg string `json:"insuOrg"`
  16633. OfficeID string `json:"officeId"`
  16634. OfficeName string `json:"officeName"`
  16635. OperatorID string `json:"operatorId"`
  16636. OperatorName string `json:"operatorName"`
  16637. OrgID string `json:"orgId"`
  16638. UserName string `json:"userName"`
  16639. } `json:"data"`
  16640. Infno interface{} `json:"infno"`
  16641. Message string `json:"message"`
  16642. OrgID string `json:"orgId"`
  16643. TransType string `json:"transType"`
  16644. }
  16645. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16646. fmt.Println(result)
  16647. outPutInfo := Remove0000(result)
  16648. fmt.Println(outPutInfo)
  16649. if len(outPutInfo) > 0 {
  16650. var ele ELeData
  16651. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16652. if err != nil {
  16653. utils.ErrorLog("解析失败:%v", err)
  16654. }
  16655. token := ele.Data.EcToken
  16656. fmt.Println(outPutInfo)
  16657. 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)
  16658. saveLog(result, requestLog, "1101", "获取人员信息")
  16659. var dat map[string]interface{}
  16660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16661. fmt.Println(dat)
  16662. } else {
  16663. fmt.Println(err)
  16664. }
  16665. userJSONBytes, _ := json.Marshal(dat)
  16666. var res ResultTwo
  16667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16668. utils.ErrorLog("解析失败:%v", err)
  16669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16670. return
  16671. }
  16672. if res.Infcode == 0 {
  16673. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16674. if err == gorm.ErrRecordNotFound {
  16675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16676. return
  16677. } else if err != nil {
  16678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16679. return
  16680. } else {
  16681. fmt.Println(res)
  16682. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16683. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16684. infoStr := string(Iinfos)
  16685. idetinfoStr := string(Idetinfos)
  16686. psn := &models.HisPsn{
  16687. PsnNo: res.Output.Baseinfo.PsnNo,
  16688. PatientId: patient.ID,
  16689. Certno: res.Output.Baseinfo.Certno,
  16690. Gend: res.Output.Baseinfo.Gend,
  16691. Naty: res.Output.Baseinfo.Naty,
  16692. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16693. PsnName: res.Output.Baseinfo.PsnName,
  16694. Idetinfo: idetinfoStr,
  16695. Insuinfo: infoStr,
  16696. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16697. CardInfo: outPutInfo,
  16698. VerifyNumber: token,
  16699. InsuplcAdmdvs: ele.Data.InsuOrg,
  16700. }
  16701. service.CreateHisPsn(psn)
  16702. var rf []*ResultFive
  16703. json.Unmarshal([]byte(infoStr), &rf)
  16704. var insutypes []*ResultFive
  16705. var insutype string
  16706. var is390 int = 0
  16707. var is310 int = 0
  16708. for _, item := range rf {
  16709. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16710. insutypes = append(insutypes, item)
  16711. }
  16712. }
  16713. if len(insutypes) == 1 {
  16714. insutype = insutypes[0].Insutype
  16715. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16716. } else {
  16717. for _, i := range insutypes {
  16718. if i.Insutype == "390" {
  16719. is390 = 1
  16720. }
  16721. if i.Insutype == "310" {
  16722. is310 = 1
  16723. }
  16724. }
  16725. }
  16726. if is390 == 1 {
  16727. insutype = "390"
  16728. }
  16729. if is310 == 1 {
  16730. insutype = "310"
  16731. }
  16732. if len(insutypes) == 0 {
  16733. insutype = "310"
  16734. }
  16735. c.ServeSuccessJSON(map[string]interface{}{
  16736. "patient": patient,
  16737. "number": token,
  16738. "insutype": insutype,
  16739. })
  16740. }
  16741. } else {
  16742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16743. return
  16744. }
  16745. }
  16746. //fmt.Println(result)
  16747. //
  16748. //if initFlag == 0 {
  16749. // c.TestGetBasBaseInit()
  16750. //}
  16751. //token := c.GetEleBaseInfo()
  16752. //
  16753. //token = Remove0000(token)
  16754. //
  16755. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16756. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16757. ////
  16758. //var res ResultTwo
  16759. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16760. // utils.ErrorLog("解析失败:%v", err)
  16761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16762. // return
  16763. //}
  16764. //
  16765. //if res.Infcode == 0 {
  16766. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16767. // if err == gorm.ErrRecordNotFound {
  16768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16769. // return
  16770. // } else if err != nil {
  16771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16772. // return
  16773. //
  16774. // } else {
  16775. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16776. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16777. // infoStr := string(Iinfos)
  16778. // idetinfoStr := string(Idetinfos)
  16779. //
  16780. //
  16781. //
  16782. //
  16783. // var rf []*ResultFive
  16784. // json.Unmarshal([]byte(infoStr), &rf)
  16785. //
  16786. // var insutypes []*ResultFive
  16787. // var insutype string
  16788. // var is390 int = 0
  16789. // var is310 int = 0
  16790. // var insuplc_admdvs string
  16791. //
  16792. // for _, item := range rf {
  16793. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16794. // insutypes = append(insutypes, item)
  16795. // }
  16796. // }
  16797. //
  16798. // if len(insutypes) == 1 {
  16799. // insutype = insutypes[0].Insutype
  16800. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16801. // } else {
  16802. // for _, i := range insutypes {
  16803. // if i.Insutype == "390" {
  16804. // is390 = 1
  16805. // }
  16806. //
  16807. // if i.Insutype == "310" {
  16808. // is310 = 1
  16809. // }
  16810. // }
  16811. // }
  16812. // if is390 == 1 {
  16813. // insutype = "390"
  16814. // }
  16815. //
  16816. // if is310 == 1 {
  16817. // insutype = "310"
  16818. // }
  16819. // if len(insutypes) == 0 {
  16820. // insutype = "310"
  16821. // }
  16822. // for _, item := range rf {
  16823. // if item.Insutype == insutype {
  16824. // insuplc_admdvs = item.InsuplcAdmdvs
  16825. // }
  16826. // }
  16827. // psn := &models.HisPsn{
  16828. // PsnNo: res.Output.Baseinfo.PsnNo,
  16829. // Age: res.Output.Baseinfo.Age,
  16830. // PatientId: patient.ID,
  16831. // Certno: res.Output.Baseinfo.Certno,
  16832. // Brdy: res.Output.Baseinfo.Brdy,
  16833. // Gend: res.Output.Baseinfo.Gend,
  16834. // Naty: res.Output.Baseinfo.Naty,
  16835. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16836. // PsnName: res.Output.Baseinfo.PsnName,
  16837. // Idetinfo: idetinfoStr,
  16838. // Insuinfo: infoStr,
  16839. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16840. // CardInfo: "",
  16841. // VerifyNumber: token,
  16842. // InsuplcAdmdvs: insuplc_admdvs,
  16843. // }
  16844. // service.CreateHisPsn(psn)
  16845. //
  16846. // c.ServeSuccessJSON(map[string]interface{}{
  16847. // "patient": patient,
  16848. // "number": token,
  16849. // })
  16850. // }
  16851. //} else {
  16852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16853. // return
  16854. //}
  16855. }
  16856. break
  16857. case 5:
  16858. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16859. var api string
  16860. if miConfig.MdtrtareaAdmvs == "320921" {
  16861. 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 +
  16862. "&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
  16863. fmt.Println(api)
  16864. } else {
  16865. 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 +
  16866. "&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)
  16867. }
  16868. resp, requestErr := http.Get(api)
  16869. if requestErr != nil {
  16870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16871. return
  16872. }
  16873. body, ioErr := ioutil.ReadAll(resp.Body)
  16874. if ioErr != nil {
  16875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16877. return
  16878. }
  16879. var respJSON map[string]interface{}
  16880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16883. return
  16884. }
  16885. var status string
  16886. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16887. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16888. var token string
  16889. var res ResultTwo //1101结果
  16890. var res10265 ResultTwo10265 //1101结果
  16891. if status == "0" { //读卡成功
  16892. var card_info string //卡信息
  16893. //var busi_card_info string
  16894. var auth_info string
  16895. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16896. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16897. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16898. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16899. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16900. result, _ := json.Marshal(respJSON)
  16901. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16902. utils.ErrorLog("解析失败:%v", err)
  16903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16904. return
  16905. }
  16906. res.ErrMsg = res10265.ErrMsg
  16907. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16908. res.Infcode = infocode
  16909. res.Output = res10265.Output
  16910. res.InfRefmsgid = res10265.InfRefmsgid
  16911. if res.Infcode == 0 {
  16912. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16913. if err == gorm.ErrRecordNotFound {
  16914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16915. return
  16916. } else if err != nil {
  16917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16918. return
  16919. } else {
  16920. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16921. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16922. infoStr := string(Iinfos)
  16923. idetinfoStr := string(Idetinfos)
  16924. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16925. psn := &models.HisPsn{
  16926. PsnNo: res.Output.Baseinfo.PsnNo,
  16927. PatientId: patient.ID,
  16928. Certno: res.Output.Baseinfo.Certno,
  16929. Gend: res.Output.Baseinfo.Gend,
  16930. Brdy: b,
  16931. Age: float64(age),
  16932. Naty: res.Output.Baseinfo.Naty,
  16933. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16934. PsnName: res.Output.Baseinfo.PsnName,
  16935. Idetinfo: idetinfoStr,
  16936. Insuinfo: infoStr,
  16937. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16938. CardInfo: card_info,
  16939. VerifyNumber: token,
  16940. AuthInfo: auth_info,
  16941. }
  16942. var rf []*ResultFive
  16943. json.Unmarshal([]byte(infoStr), &rf)
  16944. var insutypes []*ResultFive
  16945. var insutype string
  16946. var is390 int = 0
  16947. var is310 int = 0
  16948. for _, item := range rf {
  16949. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16950. insutypes = append(insutypes, item)
  16951. }
  16952. }
  16953. if len(insutypes) == 1 {
  16954. insutype = insutypes[0].Insutype
  16955. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16956. } else {
  16957. for _, i := range insutypes {
  16958. if i.Insutype == "390" {
  16959. is390 = 1
  16960. }
  16961. if i.Insutype == "310" {
  16962. is310 = 1
  16963. }
  16964. }
  16965. }
  16966. if is390 == 1 {
  16967. insutype = "390"
  16968. }
  16969. if is310 == 1 {
  16970. insutype = "310"
  16971. }
  16972. if len(insutypes) == 0 {
  16973. insutype = "310"
  16974. }
  16975. service.CreateHisPsn(psn)
  16976. c.ServeSuccessJSON(map[string]interface{}{
  16977. "patient": patient,
  16978. "number": token,
  16979. "insutype": insutype,
  16980. })
  16981. }
  16982. } else {
  16983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16984. return
  16985. }
  16986. } else { //读卡失败
  16987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16988. return
  16989. }
  16990. }
  16991. break
  16992. }
  16993. }
  16994. var initFlag int64 = 0
  16995. var initEleFlag int64 = 0
  16996. func (c *HisApiController) TestGetBasBaseInit() {
  16997. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16998. Iinit := DllDef.MustFindProc("Init")
  16999. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17000. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17001. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17002. if ret != 0 {
  17003. fmt.Println("SSCard的报错原因:", err)
  17004. fmt.Println("SSCard的运算结果为:", ret)
  17005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17006. return
  17007. }
  17008. result := int(ret)
  17009. fmt.Println("SSCard的运算结果为1:", result)
  17010. initFlag = 1
  17011. return
  17012. }
  17013. func (c *HisApiController) HandleJiangXiReadCard() {
  17014. fmt.Println("~~~~~~")
  17015. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17016. admin_user_id, _ := c.GetInt64("admin_user_id")
  17017. id_card_type, _ := c.GetInt64("id_card_type")
  17018. //certificates, _ := c.GetInt64("certificates")
  17019. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17020. if initFlag == 0 {
  17021. c.TestGetJiangXiBasBaseInit()
  17022. }
  17023. basStr := c.GetBasBaseInfo()
  17024. if len(basStr) == 0 {
  17025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17026. return
  17027. }
  17028. fmt.Println(basStr)
  17029. bas := strings.Split(basStr, "|")
  17030. basNumber := bas[1]
  17031. fmt.Println(basNumber)
  17032. card_sn := bas[3]
  17033. fmt.Println(card_sn)
  17034. 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, "")
  17035. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17036. var dat map[string]interface{}
  17037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17038. fmt.Println(dat)
  17039. } else {
  17040. fmt.Println(err)
  17041. }
  17042. userJSONBytes, _ := json.Marshal(dat)
  17043. var res ResultTwo
  17044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17045. utils.ErrorLog("解析失败:%v", err)
  17046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17047. return
  17048. }
  17049. if res.Infcode == 0 {
  17050. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17051. if err == gorm.ErrRecordNotFound {
  17052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17053. return
  17054. } else if err != nil {
  17055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17056. return
  17057. } else {
  17058. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17059. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17060. infoStr := string(Iinfos)
  17061. idetinfoStr := string(Idetinfos)
  17062. psn := &models.HisPsn{
  17063. PsnNo: res.Output.Baseinfo.PsnNo,
  17064. PatientId: patient.ID,
  17065. Certno: res.Output.Baseinfo.Certno,
  17066. Gend: res.Output.Baseinfo.Gend,
  17067. Naty: res.Output.Baseinfo.Naty,
  17068. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17069. PsnName: res.Output.Baseinfo.PsnName,
  17070. Idetinfo: idetinfoStr,
  17071. Insuinfo: infoStr,
  17072. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17073. CardInfo: basStr,
  17074. VerifyNumber: "",
  17075. }
  17076. service.CreateHisPsn(psn)
  17077. c.ServeSuccessJSON(map[string]interface{}{
  17078. "patient": patient,
  17079. "number": basNumber,
  17080. })
  17081. }
  17082. } else {
  17083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17084. return
  17085. }
  17086. }
  17087. func (c *HisApiController) TestGetHnBasBaseInit() {
  17088. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17089. Iinit := DllDef.MustFindProc("Init")
  17090. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17091. //http://10.77.211.236/CSB/hsa-fsi-1303
  17092. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17093. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17094. // 调用 Init 函数
  17095. 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"))))
  17096. //if ret != 0 {
  17097. fmt.Println("SSCard的报错原因:", err)
  17098. fmt.Println("SSCard的运算结果为:", ret)
  17099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17100. // return
  17101. //}
  17102. result := int(ret)
  17103. fmt.Println("SSCard的运算结果为1:", result)
  17104. initFlag = 1
  17105. return
  17106. }
  17107. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17108. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17109. Iinit := DllDef.MustFindProc("Init")
  17110. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17111. //http://10.77.211.236/CSB/hsa-fsi-1303
  17112. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17113. if ret != 0 {
  17114. fmt.Println("SSCard的报错原因:", err)
  17115. fmt.Println("SSCard的运算结果为:", ret)
  17116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17117. return
  17118. }
  17119. result := int(ret)
  17120. fmt.Println("SSCard的运算结果为1:", result)
  17121. initFlag = 1
  17122. return
  17123. }
  17124. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17125. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17126. Iinit := DllDef.MustFindProc("Init")
  17127. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17128. //http://10.77.211.236/CSB/hsa-fsi-1303
  17129. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17130. if ret != 0 {
  17131. fmt.Println("SSCard的报错原因:", err)
  17132. fmt.Println("SSCard的运算结果为:", ret)
  17133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17134. return
  17135. }
  17136. result := int(ret)
  17137. fmt.Println("SSCard的运算结果为1:", result)
  17138. initFlag = 1
  17139. return
  17140. }
  17141. func (c *HisApiController) GetSFZBaseInfo() string {
  17142. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17143. readCard := DllDef.MustFindProc("ReadSFZ")
  17144. if readCard == nil {
  17145. fmt.Println("readcard is nil")
  17146. readCard = DllDef.MustFindProc("ReadSFZ")
  17147. }
  17148. str := make([]byte, 8096)
  17149. str1 := make([]byte, 8096)
  17150. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17151. fmt.Println(r)
  17152. return Remove0000(string(str))
  17153. }
  17154. func (c *HisApiController) GetEleBaseInfo() string {
  17155. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17156. readCard := DllDef.MustFindProc("GetQRBase")
  17157. fmt.Println(readCard)
  17158. if readCard == nil {
  17159. fmt.Println("readcard is nil")
  17160. readCard = DllDef.MustFindProc("GetQRBase")
  17161. }
  17162. str := make([]byte, 1024)
  17163. str1 := make([]byte, 1024)
  17164. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17165. fmt.Println(ret2)
  17166. fmt.Println(string(str1))
  17167. fmt.Println(string(str))
  17168. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17169. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17170. if ret2 != 0 {
  17171. return ""
  17172. }
  17173. return string(str)
  17174. }
  17175. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17176. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17177. readCard := DllDef.MustFindProc("NationEcTrans")
  17178. fmt.Println(readCard)
  17179. fmt.Println("!!!!!")
  17180. pBusiCardInfo := make([]byte, 2048)
  17181. input := make(map[string]interface{})
  17182. inputData := make(map[string]interface{})
  17183. inputData["orgId"] = code
  17184. inputData["businessType"] = "01101"
  17185. inputData["operatorId"] = "1"
  17186. inputData["operatorName"] = "admin"
  17187. inputData["officeId"] = "001"
  17188. inputData["officeName"] = "血透室"
  17189. inputData["deviceType"] = ""
  17190. input["data"] = inputData
  17191. input["orgId"] = code
  17192. input["transType"] = "ec.query"
  17193. bytesData, _ := json.Marshal(input)
  17194. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17195. fmt.Println(ret2)
  17196. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17197. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17198. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17199. }
  17200. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17201. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17202. readCard := DllDef.MustFindProc("NationEcTrans")
  17203. fmt.Println(readCard)
  17204. fmt.Println("!!!!!")
  17205. pBusiCardInfo := make([]byte, 2048)
  17206. input := make(map[string]interface{})
  17207. inputData := make(map[string]interface{})
  17208. inputData["orgId"] = code
  17209. inputData["businessType"] = "01101"
  17210. inputData["operatorId"] = "9"
  17211. inputData["operatorName"] = "admin"
  17212. inputData["officeId"] = "001"
  17213. inputData["officeName"] = "血透室"
  17214. inputData["deviceType"] = ""
  17215. input["data"] = inputData
  17216. input["orgId"] = code
  17217. input["transType"] = "ec.query"
  17218. bytesData, _ := json.Marshal(input)
  17219. 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])))
  17220. fmt.Println(ret2)
  17221. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17222. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17223. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17224. }
  17225. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17226. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17227. readCard := DllDef.MustFindProc("NationEcTrans")
  17228. fmt.Println(readCard)
  17229. fmt.Println("!!!!!")
  17230. pBusiCardInfo := make([]byte, 2048)
  17231. input := make(map[string]interface{})
  17232. inputData := make(map[string]interface{})
  17233. inputData["orgId"] = code
  17234. inputData["businessType"] = "01301"
  17235. inputData["operatorId"] = "9"
  17236. inputData["operatorName"] = "admin"
  17237. inputData["officeId"] = "001"
  17238. inputData["officeName"] = "血透室"
  17239. inputData["deviceType"] = ""
  17240. input["data"] = inputData
  17241. input["orgId"] = code
  17242. input["transType"] = "ec.query"
  17243. bytesData, _ := json.Marshal(input)
  17244. 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])))
  17245. fmt.Println(ret2)
  17246. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17247. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17248. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17249. }
  17250. func GetJxEleBaseInfo(org_id int64) string {
  17251. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17252. readCard := DllDef.MustFindProc("NationEcTrans")
  17253. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17254. if readCard == nil {
  17255. fmt.Println("readcard is nil")
  17256. readCard = DllDef.MustFindProc("NationEcTrans")
  17257. }
  17258. str1 := make([]byte, 1024)
  17259. data := make(map[string]interface{})
  17260. inputData := make(map[string]interface{})
  17261. inputData["orgId"] = miConfig.Code
  17262. inputData["businessType"] = "01101"
  17263. inputData["operatorId"] = "test001"
  17264. inputData["operatorName"] = "cn"
  17265. inputData["officeId"] = "32760"
  17266. inputData["officeName"] = "waike"
  17267. inputData["deviceType"] = ""
  17268. data["data"] = inputData
  17269. data["transType"] = "ec.query"
  17270. data["extra "] = ""
  17271. data["orgId"] = miConfig.Code
  17272. bytesData, _ := json.Marshal(data)
  17273. //bytesData, _ := json.Marshal(data)
  17274. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17275. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17276. fmt.Println(ret2)
  17277. fmt.Println(string(str1))
  17278. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17279. if ret2 != 0 {
  17280. return ""
  17281. }
  17282. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17283. }
  17284. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17285. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17286. // readCard := DllDef.MustFindProc("NationEcTrans")
  17287. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17288. //
  17289. // if readCard == nil {
  17290. // fmt.Println("readcard is nil")
  17291. // readCard = DllDef.MustFindProc("NationEcTrans")
  17292. // }
  17293. // str1 := make([]byte, 1024)
  17294. //
  17295. // data := make(map[string]interface{})
  17296. //
  17297. // inputData := make(map[string]interface{})
  17298. // inputData["orgId"] = miConfig.Code
  17299. // inputData["businessType"] = "01101"
  17300. // inputData["operatorId"] = "test001"
  17301. // inputData["operatorName"] = "cn"
  17302. // inputData["officeId"] = "32760"
  17303. // inputData["officeName"] = "waike"
  17304. // inputData["deviceType"] = ""
  17305. //
  17306. // data["data"] = inputData
  17307. // data["transType"] = "ec.query"
  17308. // data["extra "] = ""
  17309. // data["orgId"] = miConfig.Code
  17310. // bytesData, _ := json.Marshal(data)
  17311. // //bytesData, _ := json.Marshal(data)
  17312. //
  17313. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17314. //
  17315. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17316. // fmt.Println(ret2)
  17317. // fmt.Println(string(str1))
  17318. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17319. //
  17320. // if ret2 != 0 {
  17321. // return ""
  17322. // }
  17323. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17324. //}
  17325. func GetJxEleBaseInitInfo(org_id int64) string {
  17326. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17327. readCard := DllDef.MustFindProc("NationEcTrans")
  17328. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17329. if readCard == nil {
  17330. fmt.Println("readcard is nil")
  17331. readCard = DllDef.MustFindProc("NationEcTrans")
  17332. }
  17333. str1 := make([]byte, 2048)
  17334. data := make(map[string]interface{})
  17335. inputData := make(map[string]interface{})
  17336. inputData["orgId"] = miConfig.Code
  17337. inputData["businessType"] = "01101"
  17338. inputData["operatorId"] = "1"
  17339. inputData["operatorName"] = "huangchuang"
  17340. inputData["officeId"] = "101"
  17341. inputData["officeName"] = "xuetou"
  17342. inputData["deviceType"] = ""
  17343. data["data"] = inputData
  17344. data["transType"] = "ec.query"
  17345. data["orgId"] = miConfig.Code
  17346. bytesData, _ := json.Marshal(data)
  17347. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17348. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17349. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17350. fmt.Println(ret2)
  17351. fmt.Println(string(str1))
  17352. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17353. if ret2 != 0 {
  17354. return ""
  17355. }
  17356. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17357. initEleFlag = 1
  17358. }
  17359. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17360. }
  17361. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17362. // // 构建命令
  17363. // cmd := exec.Command("python", "b.py")
  17364. //
  17365. // // 执行命令并等待完成
  17366. // output, err := cmd.CombinedOutput()
  17367. // if err != nil {
  17368. // fmt.Println("Error executing Python script:", err)
  17369. // return
  17370. // }
  17371. //
  17372. // // 打印Python脚本的输出
  17373. // fmt.Println(string(output))
  17374. //}
  17375. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17376. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17377. readCard := DllDef.MustFindProc("gxyb_call")
  17378. if readCard == nil {
  17379. fmt.Println("readcard is nil")
  17380. readCard = DllDef.MustFindProc("gxyb_call")
  17381. }
  17382. str := make([]byte, 1024)
  17383. str1 := make([]byte, 1024)
  17384. //data := make(map[string]interface{})
  17385. currentTime := time.Now()
  17386. // 格式化时间为 "YYYYMMDDHH24MISS"
  17387. formattedTime := currentTime.Format("20060102150405")
  17388. inputData := make(map[string]interface{})
  17389. inputData2 := make(map[string]interface{})
  17390. inputData["transNo"] = "1401"
  17391. inputData["transType"] = "passwordCheck"
  17392. inputData["timestamp"] = formattedTime
  17393. inputData2["fixmedinsCode"] = code
  17394. inputData2["psnNo"] = ""
  17395. inputData["data"] = inputData2
  17396. jsonBytes, err := json.Marshal(inputData)
  17397. if err != nil {
  17398. fmt.Println("Error encoding map to JSON:", err)
  17399. }
  17400. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17401. fmt.Println(string(str1))
  17402. fmt.Println(string(str))
  17403. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17404. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17405. if ret2 != 0 {
  17406. return ""
  17407. }
  17408. return string(str)
  17409. }
  17410. func (c *HisApiController) GetoleInfo() Response {
  17411. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17412. defer ole.CoUninitialize()
  17413. // Replace with the ProgID or CLSID of your COM object
  17414. progID := "YinHai.XJ.Actual.Interface.New"
  17415. // Create COM object
  17416. unknown, err := oleutil.CreateObject(progID)
  17417. if err != nil {
  17418. fmt.Println("Unable to create COM object:", err)
  17419. }
  17420. defer unknown.Release()
  17421. // Query for the IDispatch interface
  17422. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17423. if err != nil {
  17424. fmt.Println("Unable to get IDispatch interface:", err)
  17425. }
  17426. defer dispatch.Release()
  17427. // Prepare parameters
  17428. transNo := "1401"
  17429. transType := "passwordCheck"
  17430. timestamp := time.Now().Unix()
  17431. fixmedinsCode := "H45072101171"
  17432. psnNo := ""
  17433. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17434. result2 := ""
  17435. // Call COM object's method using the IDispatch interface
  17436. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17437. fmt.Println(resulr)
  17438. fmt.Println(result2)
  17439. if err != nil {
  17440. fmt.Println("调用COM对象方法失败:", err)
  17441. }
  17442. var response Response
  17443. err2 := json.Unmarshal([]byte(result2), &response)
  17444. if err2 != nil {
  17445. fmt.Println("解析JSON失败:", err)
  17446. }
  17447. return response
  17448. }
  17449. func (c *HisApiController) GetBasBaseInfo() string {
  17450. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17451. readCard := DllDef.MustFindProc("ReadCardBas")
  17452. if readCard == nil {
  17453. fmt.Println("readcard is nil")
  17454. readCard = DllDef.MustFindProc("ReadCardBas")
  17455. }
  17456. str := make([]byte, 1024)
  17457. str1 := make([]byte, 1024)
  17458. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17459. fmt.Println(string(str1))
  17460. fmt.Println(string(str))
  17461. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17462. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17463. if ret2 != 0 {
  17464. return ""
  17465. }
  17466. return string(str)
  17467. }
  17468. type Program struct {
  17469. FunctionID string `xml:"function_id"`
  17470. CardInfo string `xml:"cardinfo"`
  17471. User string `xml:"user"`
  17472. }
  17473. func (c *HisApiController) GetBasBaseInfo1111() string {
  17474. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17475. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17476. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17477. if readCard == nil {
  17478. fmt.Println("readcard is nil")
  17479. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17480. }
  17481. if readCard2 == nil {
  17482. fmt.Println("readcard is nil")
  17483. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17484. }
  17485. str := make([]byte, 1024)
  17486. str1 := make([]byte, 1024)
  17487. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17488. str3 := make([]byte, 1024)
  17489. str4 := make([]byte, 1024)
  17490. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17491. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17492. //if err != nil {
  17493. // fmt.Println("Error opening file:", err)
  17494. //}
  17495. //defer file.Close()
  17496. //
  17497. //var lastProgram Program
  17498. //scanner := bufio.NewScanner(file)
  17499. //inProgram := false
  17500. //
  17501. //for scanner.Scan() {
  17502. // line := scanner.Text()
  17503. // if strings.Contains(line, "<program>") {
  17504. // inProgram = true
  17505. // programXML := "<program>"
  17506. // for scanner.Scan() {
  17507. // line = scanner.Text()
  17508. // programXML += line
  17509. // if strings.Contains(line, "</program>") {
  17510. // programXML += "</program>"
  17511. // break
  17512. // }
  17513. // }
  17514. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17515. // // 解析成功,更新最后的 Program
  17516. // }
  17517. // inProgram = false
  17518. // }
  17519. //}
  17520. //
  17521. // fmt.Println("Error reading file:", inProgram)
  17522. //
  17523. //if err := scanner.Err(); err != nil {
  17524. // fmt.Println("Error reading file:", err)
  17525. //}
  17526. // 输出最后一次的 Program
  17527. //fmt.Printf("最后一次的 <program>:\n")
  17528. //fmt.Printf("<program>\n")
  17529. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17530. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17531. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17532. //fmt.Printf("</program>\n")
  17533. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17534. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17535. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17536. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17537. return ConvertToString(string(str), "gbk", "utf-8")
  17538. }
  17539. func (c *HisApiController) GetBasBaseInfo22222() string {
  17540. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17541. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17542. if readCard == nil {
  17543. fmt.Println("readcard is nil")
  17544. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17545. }
  17546. str := make([]byte, 1024)
  17547. str1 := make([]byte, 1024)
  17548. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17549. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17550. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17551. //if err != nil {
  17552. // fmt.Println("Error opening file:", err)
  17553. //}
  17554. //defer file.Close()
  17555. //
  17556. //var lastProgram Program
  17557. //scanner := bufio.NewScanner(file)
  17558. //inProgram := false
  17559. //
  17560. //for scanner.Scan() {
  17561. // line := scanner.Text()
  17562. // if strings.Contains(line, "<program>") {
  17563. // inProgram = true
  17564. // programXML := "<program>"
  17565. // for scanner.Scan() {
  17566. // line = scanner.Text()
  17567. // programXML += line
  17568. // if strings.Contains(line, "</program>") {
  17569. // programXML += "</program>"
  17570. // break
  17571. // }
  17572. // }
  17573. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17574. // // 解析成功,更新最后的 Program
  17575. // }
  17576. // inProgram = false
  17577. // }
  17578. //}
  17579. //
  17580. // fmt.Println("Error reading file:", inProgram)
  17581. //
  17582. //if err := scanner.Err(); err != nil {
  17583. // fmt.Println("Error reading file:", err)
  17584. //}
  17585. // 输出最后一次的 Program
  17586. //fmt.Printf("最后一次的 <program>:\n")
  17587. //fmt.Printf("<program>\n")
  17588. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17589. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17590. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17591. //fmt.Printf("</program>\n")
  17592. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17593. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17594. return ConvertToString(string(str1), "gbk", "utf-8")
  17595. }
  17596. func (c *HisApiController) GetahBasBaseInfo() string {
  17597. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17598. readCard := DllDef.MustFindProc("iReadCardBas")
  17599. if readCard == nil {
  17600. fmt.Println("readcard is nil")
  17601. readCard = DllDef.MustFindProc("iReadCardBas")
  17602. }
  17603. //str := make([]byte, 1024)
  17604. str1 := make([]byte, 1024)
  17605. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17606. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17607. //if err != nil {
  17608. // fmt.Println("Error opening file:", err)
  17609. //}
  17610. //defer file.Close()
  17611. //
  17612. //var lastProgram Program
  17613. //scanner := bufio.NewScanner(file)
  17614. //inProgram := false
  17615. //
  17616. //for scanner.Scan() {
  17617. // line := scanner.Text()
  17618. // if strings.Contains(line, "<program>") {
  17619. // inProgram = true
  17620. // programXML := "<program>"
  17621. // for scanner.Scan() {
  17622. // line = scanner.Text()
  17623. // programXML += line
  17624. // if strings.Contains(line, "</program>") {
  17625. // programXML += "</program>"
  17626. // break
  17627. // }
  17628. // }
  17629. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17630. // // 解析成功,更新最后的 Program
  17631. // }
  17632. // inProgram = false
  17633. // }
  17634. //}
  17635. //
  17636. // fmt.Println("Error reading file:", inProgram)
  17637. //
  17638. //if err := scanner.Err(); err != nil {
  17639. // fmt.Println("Error reading file:", err)
  17640. //}
  17641. // 输出最后一次的 Program
  17642. //fmt.Printf("最后一次的 <program>:\n")
  17643. //fmt.Printf("<program>\n")
  17644. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17645. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17646. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17647. //fmt.Printf("</program>\n")
  17648. fmt.Println(string(str1))
  17649. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17650. if ret2 != 0 {
  17651. return ""
  17652. }
  17653. return string(str1)
  17654. }
  17655. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17656. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17657. readCard := DllDef.MustFindProc("read_cardinfo")
  17658. if readCard == nil {
  17659. fmt.Println("readcard is nil")
  17660. readCard = DllDef.MustFindProc("read_cardinfo")
  17661. }
  17662. str := make([]byte, 1024) //卡号
  17663. str1 := make([]byte, 1024) //卡识别码
  17664. str2 := make([]byte, 1024) //身份证号
  17665. str3 := make([]byte, 1024) //姓名
  17666. str4 := make([]byte, 1024) //错误信息
  17667. 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])))
  17668. fmt.Println(string(str1))
  17669. fmt.Println(string(str))
  17670. fmt.Println(string(str2))
  17671. fmt.Println(string(str3))
  17672. fmt.Println(string(str4))
  17673. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17674. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17675. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17676. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17677. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17678. if ret2 != 0 {
  17679. return "", "", "", "", ""
  17680. }
  17681. return string(str), string(str1), string(str2), string(str3), string(str4)
  17682. }
  17683. type CustomFundPay struct {
  17684. FundPayType string `json:"fund_pay_type"`
  17685. FundPayamt float64 `json:"fund_payamt"`
  17686. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17687. }
  17688. //func (c *HisApiController) GetBatchSettleList() {
  17689. // start_time_str := c.GetString("start_time")
  17690. // //end_time_str := c.GetString("end_time")
  17691. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17692. //
  17693. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17694. //
  17695. // for _, item := range orders {
  17696. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17697. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17698. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17699. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17700. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17701. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17702. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17703. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17704. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17705. //
  17706. // if order.ID == 0 {
  17707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17708. // return
  17709. // }
  17710. //
  17711. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17712. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17713. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17714. // //fmt.Println(count)
  17715. // //var zero string
  17716. // //number := count + 1
  17717. // //if number >= 1000 {
  17718. // // zero = "0000" + strconv.FormatInt(number, 10)
  17719. // //} else if number >= 10000 {
  17720. // // zero = "000" + strconv.FormatInt(number, 10)
  17721. // //} else if number >= 100000 {
  17722. // // zero = "00" + strconv.FormatInt(number, 10)
  17723. // //} else if number >= 1000000 {
  17724. // // zero = "0" + strconv.FormatInt(number, 10)
  17725. // //} else {
  17726. // // zero = strconv.FormatInt(number, 10)
  17727. // //}
  17728. // //fmt.Println(zero)
  17729. //
  17730. // struct4101 := service.Struct4101{
  17731. // PsnNo: order.PsnNo,
  17732. // MdtrtId: order.MdtrtId,
  17733. // SetlId: order.SetlId,
  17734. // PsnName: order.PsnName,
  17735. // Gend: order.Gend,
  17736. // Brdy: his.Brdy,
  17737. // Age: his.Age,
  17738. // Naty: order.Naty,
  17739. // PatnCertType: "01",
  17740. // Certno: order.Certno,
  17741. // Prfs: "90",
  17742. // ConerName: roles[0].UserName,
  17743. // PatnRlts: "99",
  17744. // ConerAddr: miConfig.OrgName,
  17745. // ConerTel: admin.Mobile,
  17746. // HiType: order.Insutype,
  17747. // Insuplc: miConfig.InsuplcAdmdvs,
  17748. // MaindiagFlag: "1",
  17749. // BillCode: order.SetlId,
  17750. // BillNo: order.SetlId,
  17751. // BizSn: order.Number,
  17752. // PsnSelfPay: order.PsnPartAmt,
  17753. // PsnOwnPay: order.PsnPartAmt,
  17754. // AcctPay: order.AcctPay,
  17755. // PsnCashpay: order.PsnCashPay,
  17756. // HiPaymtd: "1",
  17757. // Hsorg: miConfig.InsuplcAdmdvs,
  17758. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17759. // MedinsFillPsn: curRoles.UserName,
  17760. // MedinsFillDept: miConfig.OrgName,
  17761. // IptMedType: "2",
  17762. // }
  17763. // struct4101.SetlBegnDate = order.SetlTime
  17764. // struct4101.SetlEndDate = order.SetlTime
  17765. // time_arr := strings.Split(order.SetlTime, " ")
  17766. // struct4101.AdmTime = time_arr[0]
  17767. // struct4101.AdmEndTime = time_arr[0]
  17768. //
  17769. // var rf []CustomFundPay
  17770. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17771. //
  17772. // var tempFunPays []service.CustomStruct
  17773. // for _, item := range rf {
  17774. // var tempFunPay service.CustomStruct
  17775. // tempFunPay.FundPayamt = item.FundPayamt
  17776. // tempFunPay.FundPayType = item.FundPayType
  17777. // tempFunPays = append(tempFunPays, tempFunPay)
  17778. // }
  17779. // struct4101.CustomStruct = tempFunPays
  17780. //
  17781. // var tempDiaginfos []service.DiaginfoStructTwo
  17782. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17783. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17784. //
  17785. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17786. // var config []*models.HisXtDiagnoseConfig
  17787. // for _, item := range diagnosis_ids {
  17788. // id, _ := strconv.ParseInt(item, 10, 64)
  17789. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17790. // config = append(config, &diagnosisConfig)
  17791. // }
  17792. //
  17793. // for index, item := range config {
  17794. // if index == 0 {
  17795. // var tempDiaginfo service.DiaginfoStructTwo
  17796. // tempDiaginfo.DiagCode = item.CountryCode
  17797. // tempDiaginfo.DiagName = item.CountryContentName
  17798. // tempDiaginfo.DiagType = "1"
  17799. // tempDiaginfo.MaindiagFlag = "1"
  17800. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17801. // } else {
  17802. // var tempDiaginfo service.DiaginfoStructTwo
  17803. // tempDiaginfo.DiagCode = item.CountryCode
  17804. // tempDiaginfo.DiagName = item.CountryContentName
  17805. // tempDiaginfo.DiagType = "1"
  17806. // tempDiaginfo.MaindiagFlag = "0"
  17807. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17808. // }
  17809. // }
  17810. // struct4101.Diseinfo = tempDiaginfos
  17811. //
  17812. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17813. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17814. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17815. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17816. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17817. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17818. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17819. //
  17820. // var iteminfo service.IteminfoStruct
  17821. //
  17822. // var bedCostTotal float64 = 0 //床位总费
  17823. // var bedCostSelfTotal float64 = 0 //床位自费
  17824. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17825. //
  17826. // var operationCostTotal float64 = 0 //手术费
  17827. // var operationCostSelfTotal float64 = 0 //手术费
  17828. // var operationCostPartSelfTotal float64 = 0 //手术费
  17829. //
  17830. // var otherCostTotal float64 = 0 //其他费用
  17831. // var otherCostSelfTotal float64 = 0 //其他费用
  17832. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17833. //
  17834. // var materialCostTotal float64 = 0 //材料费
  17835. // var materialCostSelfTotal float64 = 0 //材料费
  17836. // var materialCostPartSelfTotal float64 = 0 //材料费
  17837. //
  17838. // var westernMedicineCostTotal float64 = 0 //西药费
  17839. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17840. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17841. //
  17842. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17843. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17844. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17845. //
  17846. // var checkCostTotal float64 = 0 //检查费
  17847. // var checkCostSelfTotal float64 = 0 //检查费
  17848. // var checkCostPartSelfTotal float64 = 0 //检查费
  17849. //
  17850. // var laboratoryCostTotal float64 = 0 //化验费
  17851. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17852. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17853. //
  17854. // var treatCostTotal float64 = 0 //治疗费用
  17855. // var treatCostSelfTotal float64 = 0 //治疗费用
  17856. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17857. //
  17858. // decimal.DivisionPrecision = 2
  17859. //
  17860. // var bed_fulamt_ownpay_amt float64 = 0
  17861. // var operation_fulamt_ownpay_amt float64 = 0
  17862. // var other_fulamt_ownpay_amt float64 = 0
  17863. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17864. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17865. // var check_fulamt_ownpay_amt float64 = 0
  17866. // var material_fulamt_ownpay_amt float64 = 0
  17867. // var laboratory_fulamt_ownpay_amt float64 = 0
  17868. // var treat_fulamt_ownpay_amt float64 = 0
  17869. //
  17870. // var bed_claa_sunmfee float64 = 0
  17871. // var bed_clab_amt float64 = 0
  17872. // var bed_other_amt float64 = 0
  17873. //
  17874. // var operation_claa_sunmfee float64 = 0
  17875. // var operation_clab_amt float64 = 0
  17876. // var operation_other_amt float64 = 0
  17877. //
  17878. // var other_claa_sunmfee float64 = 0
  17879. // var other_clab_amt float64 = 0
  17880. // var other_other_amt float64 = 0
  17881. //
  17882. // var westernMedicine_claa_sunmfee float64 = 0
  17883. // var westernMedicine_clab_amt float64 = 0
  17884. // var westernMedicine_other_amt float64 = 0
  17885. //
  17886. // var chineseTraditional_claa_sunmfee float64 = 0
  17887. // var chineseTraditional_clab_amt float64 = 0
  17888. // var chineseTraditional_other_amt float64 = 0
  17889. //
  17890. // var check_claa_sunmfee float64 = 0
  17891. // var check_clab_amt float64 = 0
  17892. // var check_other_amt float64 = 0
  17893. //
  17894. // var material_claa_sunmfee float64 = 0
  17895. // var material_clab_amt float64 = 0
  17896. // var material_other_amt float64 = 0
  17897. //
  17898. // var laboratory_claa_sunmfee float64 = 0
  17899. // var laboratory_clab_amt float64 = 0
  17900. // var laboratory_other_amt float64 = 0
  17901. //
  17902. // var treat_claa_sunmfee float64 = 0
  17903. // var treat_clab_amt float64 = 0
  17904. // var treat_other_amt float64 = 0
  17905. //
  17906. // for _, item := range order.HisOrderInfo {
  17907. // if item.MedChrgitmType == "01" { //床位费
  17908. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17909. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17910. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17911. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17912. // if item.ChrgitmLv == "1" {
  17913. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17914. // }
  17915. // if item.ChrgitmLv == "2" {
  17916. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17917. //
  17918. // }
  17919. // if item.ChrgitmLv == "3" {
  17920. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17921. // }
  17922. //
  17923. // }
  17924. //
  17925. // if item.MedChrgitmType == "03" { //检查费
  17926. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17927. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17928. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17929. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17930. // if item.ChrgitmLv == "1" {
  17931. //
  17932. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17933. //
  17934. // }
  17935. // if item.ChrgitmLv == "2" {
  17936. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17937. //
  17938. // }
  17939. // if item.ChrgitmLv == "3" {
  17940. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17941. // }
  17942. // }
  17943. //
  17944. // if item.MedChrgitmType == "04" { //化验费
  17945. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17946. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17947. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17948. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17949. // if item.ChrgitmLv == "1" {
  17950. //
  17951. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17952. //
  17953. // }
  17954. // if item.ChrgitmLv == "2" {
  17955. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17956. //
  17957. // }
  17958. // if item.ChrgitmLv == "3" {
  17959. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17960. // }
  17961. // }
  17962. //
  17963. // if item.MedChrgitmType == "05" { //治疗费
  17964. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17965. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17966. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17967. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17968. // if item.ChrgitmLv == "1" {
  17969. //
  17970. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17971. //
  17972. // }
  17973. // if item.ChrgitmLv == "2" {
  17974. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17975. //
  17976. // }
  17977. // if item.ChrgitmLv == "3" {
  17978. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17979. // }
  17980. // }
  17981. //
  17982. // if item.MedChrgitmType == "06" { //手术费
  17983. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17984. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17985. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17986. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17987. //
  17988. // if item.ChrgitmLv == "1" {
  17989. //
  17990. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17991. //
  17992. // }
  17993. // if item.ChrgitmLv == "2" {
  17994. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17995. //
  17996. // }
  17997. // if item.ChrgitmLv == "3" {
  17998. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17999. // }
  18000. // }
  18001. //
  18002. // if item.MedChrgitmType == "08" { //材料费
  18003. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18004. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18005. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18006. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18007. // if item.ChrgitmLv == "1" {
  18008. //
  18009. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18010. //
  18011. // }
  18012. // if item.ChrgitmLv == "2" {
  18013. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18014. //
  18015. // }
  18016. // if item.ChrgitmLv == "3" {
  18017. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18018. // }
  18019. // }
  18020. //
  18021. // if item.MedChrgitmType == "09" { //西药费
  18022. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18023. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18024. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18025. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18026. // if item.ChrgitmLv == "1" {
  18027. //
  18028. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18029. //
  18030. // }
  18031. // if item.ChrgitmLv == "2" {
  18032. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18033. //
  18034. // }
  18035. // if item.ChrgitmLv == "3" {
  18036. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18037. // }
  18038. // }
  18039. //
  18040. // if item.MedChrgitmType == "11" { //中成费
  18041. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18042. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18043. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18044. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18045. // if item.ChrgitmLv == "1" {
  18046. //
  18047. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18048. //
  18049. // }
  18050. // if item.ChrgitmLv == "2" {
  18051. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18052. //
  18053. // }
  18054. // if item.ChrgitmLv == "3" {
  18055. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18056. // }
  18057. // }
  18058. //
  18059. // if item.MedChrgitmType == "14" { //其他费
  18060. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18061. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18062. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18063. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18064. // if item.ChrgitmLv == "1" {
  18065. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18066. //
  18067. // }
  18068. // if item.ChrgitmLv == "2" {
  18069. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18070. //
  18071. // }
  18072. // if item.ChrgitmLv == "3" {
  18073. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18074. // }
  18075. // }
  18076. //
  18077. // }
  18078. //
  18079. // var iteminfoStructs []service.IteminfoStruct
  18080. //
  18081. // if bedCostTotal != 0 {
  18082. // iteminfo.MedChrgitm = "01"
  18083. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18084. // iteminfo.Amt = bedCostTotal
  18085. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18086. // iteminfo.ClabAmt = bed_clab_amt
  18087. // iteminfo.OthAmt = bed_other_amt
  18088. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18089. // }
  18090. //
  18091. // if checkCostTotal != 0 {
  18092. // iteminfo.MedChrgitm = "03"
  18093. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18094. // iteminfo.Amt = checkCostTotal
  18095. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18096. // iteminfo.ClabAmt = check_clab_amt
  18097. // iteminfo.OthAmt = check_other_amt
  18098. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18099. //
  18100. // }
  18101. //
  18102. // if laboratoryCostTotal != 0 {
  18103. // iteminfo.MedChrgitm = "04"
  18104. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18105. // iteminfo.Amt = laboratoryCostTotal
  18106. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18107. // iteminfo.ClabAmt = laboratory_clab_amt
  18108. // iteminfo.OthAmt = laboratory_other_amt
  18109. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18110. //
  18111. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18112. //
  18113. // }
  18114. //
  18115. // if treatCostTotal != 0 {
  18116. // iteminfo.MedChrgitm = "05"
  18117. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18118. // iteminfo.Amt = treatCostTotal
  18119. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18120. // iteminfo.ClabAmt = treat_clab_amt
  18121. // iteminfo.OthAmt = treat_other_amt
  18122. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18123. // //(struct4101.IteminfoStruct, iteminfo)
  18124. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18125. // }
  18126. //
  18127. // if operationCostTotal != 0 {
  18128. // iteminfo.MedChrgitm = "06"
  18129. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18130. // iteminfo.Amt = operationCostTotal
  18131. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18132. // iteminfo.ClabAmt = operation_clab_amt
  18133. // iteminfo.OthAmt = operation_other_amt
  18134. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18135. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18136. // }
  18137. //
  18138. // if materialCostTotal != 0 {
  18139. // iteminfo.MedChrgitm = "08"
  18140. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18141. // iteminfo.Amt = materialCostTotal
  18142. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18143. // iteminfo.ClabAmt = material_clab_amt
  18144. // iteminfo.OthAmt = material_other_amt
  18145. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18146. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18147. // }
  18148. //
  18149. // if westernMedicineCostTotal != 0 {
  18150. // iteminfo.MedChrgitm = "09"
  18151. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18152. // iteminfo.Amt = westernMedicineCostTotal
  18153. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18154. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18155. // iteminfo.OthAmt = westernMedicine_other_amt
  18156. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18157. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18158. //
  18159. // }
  18160. // if chineseTraditionalMedicineCostTotal != 0 {
  18161. // iteminfo.MedChrgitm = "11"
  18162. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18163. // iteminfo.Amt = westernMedicineCostTotal
  18164. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18165. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18166. // iteminfo.OthAmt = westernMedicine_other_amt
  18167. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18168. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18169. //
  18170. // }
  18171. // if otherCostTotal != 0 {
  18172. // iteminfo.MedChrgitm = "14"
  18173. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18174. // iteminfo.Amt = otherCostTotal
  18175. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18176. // iteminfo.ClabAmt = other_clab_amt
  18177. // iteminfo.OthAmt = other_other_amt
  18178. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18179. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18180. //
  18181. // }
  18182. // struct4101.IteminfoStruct = iteminfoStructs
  18183. // struct4101.Ntly = "中国"
  18184. // struct4101.AdmCaty = "A03.06"
  18185. //
  18186. // struct4101.DoctorName = doctor.UserName
  18187. // struct4101.DoctorCode = doctor.DoctorNumber
  18188. //
  18189. // var res ResultSeventeen
  18190. //
  18191. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18192. // struct4101.BillCode = order.Number
  18193. // struct4101.BillNo = order.SetlId
  18194. // var resOther ResultSeventeenOther
  18195. // var pp models.PublicParams
  18196. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18197. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18198. // pp.FixmedinsName = miConfig.OrgName
  18199. // pp.FixmedinsCode = miConfig.Code
  18200. // pp.RequestUrl = miConfig.Url
  18201. // pp.Cainfo = miConfig.Cainfo
  18202. // pp.SecretKey = miConfig.SecretKey
  18203. // pp.AccessKey = miConfig.AccessKey
  18204. // pp.OpterName = curRoles.UserName
  18205. //
  18206. // client := &http.Client{}
  18207. // var req *http.Request
  18208. // data := make(map[string]interface{})
  18209. // data["struct4101"] = struct4101
  18210. // data["pp"] = pp
  18211. // bytesData, _ := json.Marshal(data)
  18212. // if miConfig.MdtrtareaAdmvs == "320921" {
  18213. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18214. // } else {
  18215. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18216. // }
  18217. // resp, _ := client.Do(req)
  18218. // defer resp.Body.Close()
  18219. // body, ioErr := ioutil.ReadAll(resp.Body)
  18220. // if ioErr != nil {
  18221. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18223. // return
  18224. // }
  18225. // var respJSON map[string]interface{}
  18226. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18227. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18229. // return
  18230. // }
  18231. //
  18232. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18233. // userJSONBytes, _ := json.Marshal(respJSON)
  18234. // fmt.Println("log")
  18235. // fmt.Println(string(userJSONBytes))
  18236. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18237. // utils.ErrorLog("解析失败:%v", err)
  18238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18239. // return
  18240. // }
  18241. // res.InfRefmsgid = resOther.InfRefmsgid
  18242. // res.Output = resOther.Output
  18243. // res.ErrMsg = resOther.ErrMsg
  18244. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18245. // res.Infcode = infocode
  18246. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18247. //
  18248. // var pp models.PublicParams
  18249. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18250. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18251. // pp.FixmedinsName = miConfig.OrgName
  18252. // pp.FixmedinsCode = miConfig.Code
  18253. // pp.RequestUrl = miConfig.Url
  18254. // pp.Cainfo = miConfig.Cainfo
  18255. // pp.SecretKey = miConfig.SecretKey
  18256. // pp.AccessKey = miConfig.AccessKey
  18257. // pp.OpterName = curRoles.UserName
  18258. // result, _ := service.Jxyb4101(struct4101, pp)
  18259. // var dat map[string]interface{}
  18260. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18261. // fmt.Println(dat)
  18262. // } else {
  18263. // fmt.Println(err)
  18264. // }
  18265. // userJSONBytes, _ := json.Marshal(dat)
  18266. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18267. // utils.ErrorLog("解析失败:%v", err)
  18268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18269. // return
  18270. // }
  18271. //
  18272. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18273. // var pp models.PublicParams
  18274. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18275. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18276. // pp.FixmedinsName = miConfig.OrgName
  18277. // pp.FixmedinsCode = miConfig.Code
  18278. // pp.RequestUrl = miConfig.Url
  18279. // pp.Cainfo = miConfig.Cainfo
  18280. // pp.SecretKey = miConfig.SecretKey
  18281. // pp.AccessKey = miConfig.AccessKey
  18282. // pp.OpterName = curRoles.UserName
  18283. // result, _ := service.Hnyb4101(struct4101, pp)
  18284. // var dat map[string]interface{}
  18285. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18286. // fmt.Println(dat)
  18287. // } else {
  18288. // fmt.Println(err)
  18289. // }
  18290. // userJSONBytes, _ := json.Marshal(dat)
  18291. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18292. // utils.ErrorLog("解析失败:%v", err)
  18293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18294. // return
  18295. // }
  18296. //
  18297. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18298. // var resOther ResultSeventeenOther
  18299. //
  18300. // var pp models.PublicParams
  18301. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18302. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18303. // pp.FixmedinsName = miConfig.OrgName
  18304. // pp.FixmedinsCode = miConfig.Code
  18305. // pp.RequestUrl = miConfig.Url
  18306. // pp.Cainfo = miConfig.Cainfo
  18307. // pp.SecretKey = miConfig.SecretKey
  18308. // pp.AccessKey = miConfig.AccessKey
  18309. // pp.OpterName = curRoles.UserName
  18310. // client := &http.Client{}
  18311. // var req *http.Request
  18312. // data := make(map[string]interface{})
  18313. // data["struct4101"] = struct4101
  18314. // data["pp"] = pp
  18315. // bytesData, _ := json.Marshal(data)
  18316. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18317. // resp, _ := client.Do(req)
  18318. // defer resp.Body.Close()
  18319. // body, ioErr := ioutil.ReadAll(resp.Body)
  18320. // if ioErr != nil {
  18321. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18323. // return
  18324. // }
  18325. // var respJSON map[string]interface{}
  18326. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18327. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18329. // return
  18330. // }
  18331. //
  18332. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18333. // userJSONBytes, _ := json.Marshal(respJSON)
  18334. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18335. // utils.ErrorLog("解析失败:%v", err)
  18336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18337. // return
  18338. // }
  18339. // res.InfRefmsgid = resOther.InfRefmsgid
  18340. // res.Output = resOther.Output
  18341. // res.ErrMsg = resOther.ErrMsg
  18342. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18343. // res.Infcode = infocode
  18344. //
  18345. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18346. // var pp models.PublicParams
  18347. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18348. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18349. // pp.FixmedinsName = miConfig.OrgName
  18350. // pp.FixmedinsCode = miConfig.Code
  18351. // pp.RequestUrl = miConfig.Url
  18352. // pp.Cainfo = miConfig.Cainfo
  18353. // pp.SecretKey = miConfig.SecretKey
  18354. // pp.AccessKey = miConfig.AccessKey
  18355. // pp.OpterName = curRoles.UserName
  18356. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18357. // fmt.Println(requestLog)
  18358. // fmt.Println(errMsgLog)
  18359. //
  18360. // saveLog(result, requestLog, "4101a", "上传清单")
  18361. //
  18362. // var dat map[string]interface{}
  18363. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18364. // fmt.Println(dat)
  18365. // } else {
  18366. // fmt.Println(err)
  18367. // }
  18368. // userJSONBytes, _ := json.Marshal(dat)
  18369. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18370. // utils.ErrorLog("解析失败:%v", err)
  18371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18372. // return
  18373. // }
  18374. //
  18375. // } else {
  18376. //
  18377. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18378. // var dat map[string]interface{}
  18379. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18380. // fmt.Println(dat)
  18381. // } else {
  18382. // fmt.Println(err)
  18383. // }
  18384. // userJSONBytes, _ := json.Marshal(dat)
  18385. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18386. // utils.ErrorLog("解析失败:%v", err)
  18387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18388. // return
  18389. // }
  18390. // }
  18391. //
  18392. // if res.Infcode != 0 {
  18393. // adminUser := c.GetAdminUserInfo()
  18394. // errlog := &models.HisOrderError{
  18395. // UserOrgId: adminUser.CurrentOrgId,
  18396. // Ctime: time.Now().Unix(),
  18397. // Mtime: time.Now().Unix(),
  18398. // ErrMsg: res.ErrMsg,
  18399. // Status: 1,
  18400. // PatientId: order.ID,
  18401. // Stage: 10265,
  18402. // }
  18403. // service.CreateErrMsgLog(errlog)
  18404. // continue
  18405. // } else {
  18406. // //order.FaPiaoNumber = zero
  18407. // //order.FaPiaoCode = last_order.FaPiaoCode
  18408. // //service.UpdateOrder(order)
  18409. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18410. // Number: res.Output.SetlListId,
  18411. // Status: 1,
  18412. // Ctime: time.Now().Unix(),
  18413. // Mtime: time.Now().Unix(),
  18414. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18415. // IsUpload: 1,
  18416. // OrderId: order.ID,
  18417. // }
  18418. // service.CreateUploadRecord(hisFundSettleListResult)
  18419. // c.ServeSuccessJSON(map[string]interface{}{
  18420. // "msg": "上传成功",
  18421. // "result": hisFundSettleListResult,
  18422. // })
  18423. // continue
  18424. // }
  18425. // }
  18426. //}
  18427. func (c *HisApiController) GetbatchSettleList() {
  18428. //order_id, _ := c.GetInt64("order_id")
  18429. admin_user_id, _ := c.GetInt64("admin_user_id")
  18430. orders, _ := service.GetAllHisOrderTwo10485()
  18431. for _, item := range orders {
  18432. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18433. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18434. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18435. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18436. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18437. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18438. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18439. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18440. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18441. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18442. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18443. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18444. //fmt.Println(count)
  18445. //var zero string
  18446. //number := count + 1
  18447. //if number >= 1000 {
  18448. // zero = "0000" + strconv.FormatInt(number, 10)
  18449. //} else if number >= 10000 {
  18450. // zero = "000" + strconv.FormatInt(number, 10)
  18451. //} else if number >= 100000 {
  18452. // zero = "00" + strconv.FormatInt(number, 10)
  18453. //} else if number >= 1000000 {
  18454. // zero = "0" + strconv.FormatInt(number, 10)
  18455. //} else {
  18456. // zero = strconv.FormatInt(number, 10)
  18457. //}
  18458. //fmt.Println(zero)
  18459. struct4101 := service.Struct4101{
  18460. PsnNo: order.PsnNo,
  18461. MdtrtId: order.MdtrtId,
  18462. SetlId: order.SetlId,
  18463. PsnName: order.PsnName,
  18464. Gend: order.Gend,
  18465. Brdy: his.Brdy,
  18466. Age: his.Age,
  18467. Naty: order.Naty,
  18468. PatnCertType: "01",
  18469. Certno: order.Certno,
  18470. Prfs: "90",
  18471. ConerName: roles[0].UserName,
  18472. PatnRlts: "99",
  18473. ConerAddr: miConfig.OrgName,
  18474. ConerTel: admin.Mobile,
  18475. HiType: order.Insutype,
  18476. Insuplc: miConfig.InsuplcAdmdvs,
  18477. MaindiagFlag: "1",
  18478. BillCode: order.SetlId,
  18479. BillNo: order.SetlId,
  18480. BizSn: order.Number,
  18481. PsnSelfPay: order.PsnPartAmt,
  18482. PsnOwnPay: order.PsnPartAmt,
  18483. AcctPay: order.AcctPay,
  18484. PsnCashpay: order.PsnCashPay,
  18485. HiPaymtd: "1",
  18486. Hsorg: miConfig.InsuplcAdmdvs,
  18487. HsorgOpter: miConfig.InsuplcAdmdvs,
  18488. MedinsFillPsn: curRoles.UserName,
  18489. MedinsFillDept: miConfig.OrgName,
  18490. IptMedType: "2",
  18491. }
  18492. struct4101.SetlBegnDate = order.SetlTime
  18493. struct4101.SetlEndDate = order.SetlTime
  18494. time_arr := strings.Split(order.SetlTime, " ")
  18495. struct4101.AdmTime = time_arr[0]
  18496. struct4101.AdmEndTime = time_arr[0]
  18497. //var rf []CustomFundPay
  18498. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18499. //
  18500. //var tempFunPays []service.CustomStruct
  18501. //for _, item := range rf {
  18502. // var tempFunPay service.CustomStruct
  18503. // tempFunPay.FundPayamt = item.FundPayamt
  18504. // tempFunPay.FundPayType = item.FundPayType
  18505. // tempFunPays = append(tempFunPays, tempFunPay)
  18506. //}
  18507. //struct4101.CustomStruct = tempFunPays
  18508. var tempDiaginfos []service.DiaginfoStructTwo
  18509. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18510. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18511. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18512. var config []*models.HisXtDiagnoseConfig
  18513. for _, item := range diagnosis_ids {
  18514. id, _ := strconv.ParseInt(item, 10, 64)
  18515. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18516. config = append(config, &diagnosisConfig)
  18517. }
  18518. for index, item := range config {
  18519. if index == 0 {
  18520. var tempDiaginfo service.DiaginfoStructTwo
  18521. tempDiaginfo.DiagCode = item.CountryCode
  18522. tempDiaginfo.DiagName = item.CountryContentName
  18523. tempDiaginfo.DiagType = "1"
  18524. tempDiaginfo.MaindiagFlag = "1"
  18525. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18526. } else {
  18527. var tempDiaginfo service.DiaginfoStructTwo
  18528. tempDiaginfo.DiagCode = item.CountryCode
  18529. tempDiaginfo.DiagName = item.CountryContentName
  18530. tempDiaginfo.DiagType = "1"
  18531. tempDiaginfo.MaindiagFlag = "0"
  18532. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18533. }
  18534. }
  18535. struct4101.Diseinfo = tempDiaginfos
  18536. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18537. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18538. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18539. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18540. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18541. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18542. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18543. var iteminfo service.IteminfoStruct
  18544. var bedCostTotal float64 = 0 //床位总费
  18545. var bedCostSelfTotal float64 = 0 //床位自费
  18546. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18547. var operationCostTotal float64 = 0 //手术费
  18548. var operationCostSelfTotal float64 = 0 //手术费
  18549. var operationCostPartSelfTotal float64 = 0 //手术费
  18550. var otherCostTotal float64 = 0 //其他费用
  18551. var otherCostSelfTotal float64 = 0 //其他费用
  18552. var otherCostPartSelfTotal float64 = 0 //其他费用
  18553. var materialCostTotal float64 = 0 //材料费
  18554. var materialCostSelfTotal float64 = 0 //材料费
  18555. var materialCostPartSelfTotal float64 = 0 //材料费
  18556. var westernMedicineCostTotal float64 = 0 //西药费
  18557. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18558. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18559. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18560. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18561. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18562. var checkCostTotal float64 = 0 //检查费
  18563. var checkCostSelfTotal float64 = 0 //检查费
  18564. var checkCostPartSelfTotal float64 = 0 //检查费
  18565. var laboratoryCostTotal float64 = 0 //化验费
  18566. var laboratoryCostSelfTotal float64 = 0 //化验费
  18567. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18568. var treatCostTotal float64 = 0 //治疗费用
  18569. var treatCostSelfTotal float64 = 0 //治疗费用
  18570. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18571. decimal.DivisionPrecision = 2
  18572. var bed_fulamt_ownpay_amt float64 = 0
  18573. var operation_fulamt_ownpay_amt float64 = 0
  18574. var other_fulamt_ownpay_amt float64 = 0
  18575. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18576. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18577. var check_fulamt_ownpay_amt float64 = 0
  18578. var material_fulamt_ownpay_amt float64 = 0
  18579. var laboratory_fulamt_ownpay_amt float64 = 0
  18580. var treat_fulamt_ownpay_amt float64 = 0
  18581. var bed_claa_sunmfee float64 = 0
  18582. var bed_clab_amt float64 = 0
  18583. var bed_other_amt float64 = 0
  18584. var operation_claa_sunmfee float64 = 0
  18585. var operation_clab_amt float64 = 0
  18586. var operation_other_amt float64 = 0
  18587. var other_claa_sunmfee float64 = 0
  18588. var other_clab_amt float64 = 0
  18589. var other_other_amt float64 = 0
  18590. var westernMedicine_claa_sunmfee float64 = 0
  18591. var westernMedicine_clab_amt float64 = 0
  18592. var westernMedicine_other_amt float64 = 0
  18593. var chineseTraditional_claa_sunmfee float64 = 0
  18594. var chineseTraditional_clab_amt float64 = 0
  18595. var chineseTraditional_other_amt float64 = 0
  18596. var check_claa_sunmfee float64 = 0
  18597. var check_clab_amt float64 = 0
  18598. var check_other_amt float64 = 0
  18599. var material_claa_sunmfee float64 = 0
  18600. var material_clab_amt float64 = 0
  18601. var material_other_amt float64 = 0
  18602. var laboratory_claa_sunmfee float64 = 0
  18603. var laboratory_clab_amt float64 = 0
  18604. var laboratory_other_amt float64 = 0
  18605. var treat_claa_sunmfee float64 = 0
  18606. var treat_clab_amt float64 = 0
  18607. var treat_other_amt float64 = 0
  18608. for _, item := range order.HisOrderInfo {
  18609. if item.MedChrgitmType == "01" { //床位费
  18610. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18611. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18612. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18613. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18614. if item.ChrgitmLv == "1" {
  18615. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18616. }
  18617. if item.ChrgitmLv == "2" {
  18618. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18619. }
  18620. if item.ChrgitmLv == "3" {
  18621. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18622. }
  18623. }
  18624. if item.MedChrgitmType == "03" { //检查费
  18625. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18626. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18627. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18628. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18629. if item.ChrgitmLv == "1" {
  18630. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18631. }
  18632. if item.ChrgitmLv == "2" {
  18633. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18634. }
  18635. if item.ChrgitmLv == "3" {
  18636. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18637. }
  18638. }
  18639. if item.MedChrgitmType == "04" { //化验费
  18640. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18641. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18642. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18643. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18644. if item.ChrgitmLv == "1" {
  18645. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18646. }
  18647. if item.ChrgitmLv == "2" {
  18648. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18649. }
  18650. if item.ChrgitmLv == "3" {
  18651. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18652. }
  18653. }
  18654. if item.MedChrgitmType == "05" { //治疗费
  18655. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18656. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18657. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18658. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18659. if item.ChrgitmLv == "1" {
  18660. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18661. }
  18662. if item.ChrgitmLv == "2" {
  18663. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18664. }
  18665. if item.ChrgitmLv == "3" {
  18666. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18667. }
  18668. }
  18669. if item.MedChrgitmType == "06" { //手术费
  18670. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18671. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18672. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18673. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18674. if item.ChrgitmLv == "1" {
  18675. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18676. }
  18677. if item.ChrgitmLv == "2" {
  18678. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18679. }
  18680. if item.ChrgitmLv == "3" {
  18681. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18682. }
  18683. }
  18684. if item.MedChrgitmType == "08" { //材料费
  18685. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18686. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18687. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18688. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18689. if item.ChrgitmLv == "1" {
  18690. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18691. }
  18692. if item.ChrgitmLv == "2" {
  18693. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18694. }
  18695. if item.ChrgitmLv == "3" {
  18696. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18697. }
  18698. }
  18699. if item.MedChrgitmType == "09" { //西药费
  18700. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18701. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18702. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18703. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18704. if item.ChrgitmLv == "1" {
  18705. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18706. }
  18707. if item.ChrgitmLv == "2" {
  18708. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18709. }
  18710. if item.ChrgitmLv == "3" {
  18711. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18712. }
  18713. }
  18714. if item.MedChrgitmType == "11" { //中成费
  18715. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18716. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18717. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18718. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18719. if item.ChrgitmLv == "1" {
  18720. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18721. }
  18722. if item.ChrgitmLv == "2" {
  18723. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18724. }
  18725. if item.ChrgitmLv == "3" {
  18726. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18727. }
  18728. }
  18729. if item.MedChrgitmType == "14" { //其他费
  18730. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18731. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18732. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18733. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18734. if item.ChrgitmLv == "1" {
  18735. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18736. }
  18737. if item.ChrgitmLv == "2" {
  18738. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18739. }
  18740. if item.ChrgitmLv == "3" {
  18741. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18742. }
  18743. }
  18744. }
  18745. var iteminfoStructs []service.IteminfoStruct
  18746. if bedCostTotal != 0 {
  18747. iteminfo.MedChrgitm = "01"
  18748. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18749. iteminfo.Amt = bedCostTotal
  18750. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18751. iteminfo.ClabAmt = bed_clab_amt
  18752. iteminfo.OthAmt = bed_other_amt
  18753. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18754. }
  18755. if checkCostTotal != 0 {
  18756. iteminfo.MedChrgitm = "03"
  18757. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18758. iteminfo.Amt = checkCostTotal
  18759. iteminfo.ClaaSumfee = check_claa_sunmfee
  18760. iteminfo.ClabAmt = check_clab_amt
  18761. iteminfo.OthAmt = check_other_amt
  18762. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18763. }
  18764. if laboratoryCostTotal != 0 {
  18765. iteminfo.MedChrgitm = "04"
  18766. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18767. iteminfo.Amt = laboratoryCostTotal
  18768. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18769. iteminfo.ClabAmt = laboratory_clab_amt
  18770. iteminfo.OthAmt = laboratory_other_amt
  18771. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18772. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18773. }
  18774. if treatCostTotal != 0 {
  18775. iteminfo.MedChrgitm = "05"
  18776. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18777. iteminfo.Amt = treatCostTotal
  18778. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18779. iteminfo.ClabAmt = treat_clab_amt
  18780. iteminfo.OthAmt = treat_other_amt
  18781. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18782. //(struct4101.IteminfoStruct, iteminfo)
  18783. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18784. }
  18785. if operationCostTotal != 0 {
  18786. iteminfo.MedChrgitm = "06"
  18787. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18788. iteminfo.Amt = operationCostTotal
  18789. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18790. iteminfo.ClabAmt = operation_clab_amt
  18791. iteminfo.OthAmt = operation_other_amt
  18792. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18793. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18794. }
  18795. if materialCostTotal != 0 {
  18796. iteminfo.MedChrgitm = "08"
  18797. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18798. iteminfo.Amt = materialCostTotal
  18799. iteminfo.ClaaSumfee = material_claa_sunmfee
  18800. iteminfo.ClabAmt = material_clab_amt
  18801. iteminfo.OthAmt = material_other_amt
  18802. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18803. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18804. }
  18805. if westernMedicineCostTotal != 0 {
  18806. iteminfo.MedChrgitm = "09"
  18807. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18808. iteminfo.Amt = westernMedicineCostTotal
  18809. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18810. iteminfo.ClabAmt = westernMedicine_clab_amt
  18811. iteminfo.OthAmt = westernMedicine_other_amt
  18812. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18813. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18814. }
  18815. if chineseTraditionalMedicineCostTotal != 0 {
  18816. iteminfo.MedChrgitm = "11"
  18817. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18818. iteminfo.Amt = westernMedicineCostTotal
  18819. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18820. iteminfo.ClabAmt = westernMedicine_clab_amt
  18821. iteminfo.OthAmt = westernMedicine_other_amt
  18822. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18823. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18824. }
  18825. if otherCostTotal != 0 {
  18826. iteminfo.MedChrgitm = "14"
  18827. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18828. iteminfo.Amt = otherCostTotal
  18829. iteminfo.ClaaSumfee = other_claa_sunmfee
  18830. iteminfo.ClabAmt = other_clab_amt
  18831. iteminfo.OthAmt = other_other_amt
  18832. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18833. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18834. }
  18835. struct4101.IteminfoStruct = iteminfoStructs
  18836. struct4101.Ntly = "中国"
  18837. struct4101.AdmCaty = "A03.06"
  18838. struct4101.DoctorName = doctor.UserName
  18839. struct4101.DoctorCode = doctor.DoctorNumber
  18840. var res ResultSeventeen
  18841. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18842. struct4101.BillCode = order.Number
  18843. struct4101.BillNo = order.SetlId
  18844. var resOther ResultSeventeenOther
  18845. var pp models.PublicParams
  18846. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18847. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18848. pp.FixmedinsName = miConfig.OrgName
  18849. pp.FixmedinsCode = miConfig.Code
  18850. pp.RequestUrl = miConfig.Url
  18851. pp.Cainfo = miConfig.Cainfo
  18852. pp.SecretKey = miConfig.SecretKey
  18853. pp.AccessKey = miConfig.AccessKey
  18854. pp.OpterName = curRoles.UserName
  18855. client := &http.Client{}
  18856. var req *http.Request
  18857. data := make(map[string]interface{})
  18858. data["struct4101"] = struct4101
  18859. data["pp"] = pp
  18860. bytesData, _ := json.Marshal(data)
  18861. if miConfig.MdtrtareaAdmvs == "320921" {
  18862. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18863. } else {
  18864. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18865. }
  18866. resp, _ := client.Do(req)
  18867. defer resp.Body.Close()
  18868. body, ioErr := ioutil.ReadAll(resp.Body)
  18869. if ioErr != nil {
  18870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18872. return
  18873. }
  18874. var respJSON map[string]interface{}
  18875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18878. return
  18879. }
  18880. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18881. userJSONBytes, _ := json.Marshal(respJSON)
  18882. fmt.Println("log")
  18883. fmt.Println(string(userJSONBytes))
  18884. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18885. utils.ErrorLog("解析失败:%v", err)
  18886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18887. return
  18888. }
  18889. res.InfRefmsgid = resOther.InfRefmsgid
  18890. res.Output = resOther.Output
  18891. res.ErrMsg = resOther.ErrMsg
  18892. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18893. res.Infcode = infocode
  18894. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18895. var pp models.PublicParams
  18896. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18897. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18898. pp.FixmedinsName = miConfig.OrgName
  18899. pp.FixmedinsCode = miConfig.Code
  18900. pp.RequestUrl = miConfig.Url
  18901. pp.Cainfo = miConfig.Cainfo
  18902. pp.SecretKey = miConfig.SecretKey
  18903. pp.AccessKey = miConfig.AccessKey
  18904. pp.OpterName = curRoles.UserName
  18905. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18906. result, _ := service.Jxyb4101(struct4101, pp)
  18907. var dat map[string]interface{}
  18908. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18909. fmt.Println(dat)
  18910. } else {
  18911. fmt.Println(err)
  18912. }
  18913. userJSONBytes, _ := json.Marshal(dat)
  18914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18915. utils.ErrorLog("解析失败:%v", err)
  18916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18917. return
  18918. }
  18919. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18920. var pp models.PublicParams
  18921. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18922. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18923. pp.FixmedinsName = miConfig.OrgName
  18924. pp.FixmedinsCode = miConfig.Code
  18925. pp.RequestUrl = miConfig.Url
  18926. pp.Cainfo = miConfig.Cainfo
  18927. pp.SecretKey = miConfig.SecretKey
  18928. pp.AccessKey = miConfig.AccessKey
  18929. pp.OpterName = curRoles.UserName
  18930. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18931. result, _ := service.Jxyb4101(struct4101, pp)
  18932. var dat map[string]interface{}
  18933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18934. fmt.Println(dat)
  18935. } else {
  18936. fmt.Println(err)
  18937. }
  18938. userJSONBytes, _ := json.Marshal(dat)
  18939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18940. utils.ErrorLog("解析失败:%v", err)
  18941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18942. return
  18943. }
  18944. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18945. var pp models.PublicParams
  18946. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18947. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18948. pp.FixmedinsName = miConfig.OrgName
  18949. pp.FixmedinsCode = miConfig.Code
  18950. pp.RequestUrl = miConfig.Url
  18951. pp.Cainfo = miConfig.Cainfo
  18952. pp.SecretKey = miConfig.SecretKey
  18953. pp.AccessKey = miConfig.AccessKey
  18954. pp.OpterName = curRoles.UserName
  18955. result, _ := service.Hnyb4101(struct4101, pp)
  18956. var dat map[string]interface{}
  18957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18958. fmt.Println(dat)
  18959. } else {
  18960. fmt.Println(err)
  18961. }
  18962. userJSONBytes, _ := json.Marshal(dat)
  18963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18964. utils.ErrorLog("解析失败:%v", err)
  18965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18966. return
  18967. }
  18968. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18969. var resOther ResultSeventeenOther
  18970. var pp models.PublicParams
  18971. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18972. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18973. pp.FixmedinsName = miConfig.OrgName
  18974. pp.FixmedinsCode = miConfig.Code
  18975. pp.RequestUrl = miConfig.Url
  18976. pp.Cainfo = miConfig.Cainfo
  18977. pp.SecretKey = miConfig.SecretKey
  18978. pp.AccessKey = miConfig.AccessKey
  18979. pp.OpterName = curRoles.UserName
  18980. client := &http.Client{}
  18981. var req *http.Request
  18982. data := make(map[string]interface{})
  18983. data["struct4101"] = struct4101
  18984. data["pp"] = pp
  18985. bytesData, _ := json.Marshal(data)
  18986. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18987. resp, _ := client.Do(req)
  18988. defer resp.Body.Close()
  18989. body, ioErr := ioutil.ReadAll(resp.Body)
  18990. if ioErr != nil {
  18991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18993. return
  18994. }
  18995. var respJSON map[string]interface{}
  18996. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18999. return
  19000. }
  19001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19002. userJSONBytes, _ := json.Marshal(respJSON)
  19003. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19004. utils.ErrorLog("解析失败:%v", err)
  19005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19006. return
  19007. }
  19008. res.InfRefmsgid = resOther.InfRefmsgid
  19009. res.Output = resOther.Output
  19010. res.ErrMsg = resOther.ErrMsg
  19011. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19012. res.Infcode = infocode
  19013. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19014. var pp models.PublicParams
  19015. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19016. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19017. pp.FixmedinsName = miConfig.OrgName
  19018. pp.FixmedinsCode = miConfig.Code
  19019. pp.RequestUrl = miConfig.Url
  19020. pp.Cainfo = miConfig.Cainfo
  19021. pp.SecretKey = miConfig.SecretKey
  19022. pp.AccessKey = miConfig.AccessKey
  19023. pp.OpterName = curRoles.UserName
  19024. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19025. fmt.Println(requestLog)
  19026. fmt.Println(errMsgLog)
  19027. saveLog(result, requestLog, "4101a", "上传清单")
  19028. var dat map[string]interface{}
  19029. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19030. fmt.Println(dat)
  19031. } else {
  19032. fmt.Println(err)
  19033. }
  19034. userJSONBytes, _ := json.Marshal(dat)
  19035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19036. utils.ErrorLog("解析失败:%v", err)
  19037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19038. return
  19039. }
  19040. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19041. var pp models.PublicParams
  19042. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19043. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19044. pp.FixmedinsName = miConfig.OrgName
  19045. pp.FixmedinsCode = miConfig.Code
  19046. pp.RequestUrl = miConfig.Url
  19047. pp.Cainfo = miConfig.Cainfo
  19048. pp.SecretKey = miConfig.SecretKey
  19049. pp.AccessKey = miConfig.AccessKey
  19050. pp.OpterName = curRoles.UserName
  19051. client := &http.Client{}
  19052. var req *http.Request
  19053. data := make(map[string]interface{})
  19054. data["struct4101"] = struct4101
  19055. data["pp"] = pp
  19056. bytesData, _ := json.Marshal(data)
  19057. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19058. resp, _ := client.Do(req)
  19059. defer resp.Body.Close()
  19060. body, ioErr := ioutil.ReadAll(resp.Body)
  19061. if ioErr != nil {
  19062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19064. return
  19065. }
  19066. var respJSON map[string]interface{}
  19067. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19070. return
  19071. }
  19072. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19073. userJSONBytes, _ := json.Marshal(respJSON)
  19074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19075. utils.ErrorLog("解析失败:%v", err)
  19076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19077. return
  19078. }
  19079. } else {
  19080. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19081. var dat map[string]interface{}
  19082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19083. fmt.Println(dat)
  19084. } else {
  19085. fmt.Println(err)
  19086. }
  19087. userJSONBytes, _ := json.Marshal(dat)
  19088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19089. utils.ErrorLog("解析失败:%v", err)
  19090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19091. return
  19092. }
  19093. }
  19094. if res.Infcode != 0 {
  19095. errlog := &models.HisOrderError{
  19096. UserOrgId: order.UserOrgId,
  19097. Ctime: time.Now().Unix(),
  19098. Mtime: time.Now().Unix(),
  19099. ErrMsg: res.ErrMsg + "解析失败",
  19100. Status: 1,
  19101. PatientId: order.ID,
  19102. Stage: 10485,
  19103. }
  19104. service.CreateErrMsgLog(errlog)
  19105. continue
  19106. //c.ServeSuccessJSON(map[string]interface{}{
  19107. // "failed_code": -10,
  19108. // "msg": res.ErrMsg,
  19109. //})
  19110. } else {
  19111. //order.FaPiaoNumber = zero
  19112. //order.FaPiaoCode = last_order.FaPiaoCode
  19113. //service.UpdateOrder(order)
  19114. hisFundSettleListResult := &models.HisFundSettleListResult{
  19115. Number: res.Output.SetlListId,
  19116. Status: 1,
  19117. Ctime: time.Now().Unix(),
  19118. Mtime: time.Now().Unix(),
  19119. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19120. IsUpload: 1,
  19121. OrderId: order.ID,
  19122. }
  19123. service.CreateUploadRecord(hisFundSettleListResult)
  19124. continue
  19125. }
  19126. }
  19127. }
  19128. func (c *HisApiController) GetSettleList() {
  19129. order_id, _ := c.GetInt64("order_id")
  19130. admin_user_id, _ := c.GetInt64("admin_user_id")
  19131. order, _ := service.GetHisOrderByIDTwo(order_id)
  19132. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19133. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19134. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19135. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19136. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19137. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19138. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19139. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19140. if order.ID == 0 {
  19141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19142. return
  19143. }
  19144. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19145. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19146. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19147. //fmt.Println(count)
  19148. //var zero string
  19149. //number := count + 1
  19150. //if number >= 1000 {
  19151. // zero = "0000" + strconv.FormatInt(number, 10)
  19152. //} else if number >= 10000 {
  19153. // zero = "000" + strconv.FormatInt(number, 10)
  19154. //} else if number >= 100000 {
  19155. // zero = "00" + strconv.FormatInt(number, 10)
  19156. //} else if number >= 1000000 {
  19157. // zero = "0" + strconv.FormatInt(number, 10)
  19158. //} else {
  19159. // zero = strconv.FormatInt(number, 10)
  19160. //}
  19161. //fmt.Println(zero)
  19162. struct4101 := service.Struct4101{
  19163. PsnNo: order.PsnNo,
  19164. MdtrtId: order.MdtrtId,
  19165. SetlId: order.SetlId,
  19166. PsnName: order.PsnName,
  19167. Gend: order.Gend,
  19168. Brdy: his.Brdy,
  19169. Age: his.Age,
  19170. Naty: order.Naty,
  19171. PatnCertType: "01",
  19172. Certno: order.Certno,
  19173. Prfs: "90",
  19174. ConerName: roles[0].UserName,
  19175. PatnRlts: "99",
  19176. ConerAddr: miConfig.OrgName,
  19177. ConerTel: admin.Mobile,
  19178. HiType: order.Insutype,
  19179. Insuplc: miConfig.InsuplcAdmdvs,
  19180. MaindiagFlag: "1",
  19181. BillCode: order.SetlId,
  19182. BillNo: order.SetlId,
  19183. BizSn: order.Number,
  19184. PsnSelfPay: order.PsnPartAmt,
  19185. PsnOwnPay: order.PsnPartAmt,
  19186. AcctPay: order.AcctPay,
  19187. PsnCashpay: order.PsnCashPay,
  19188. HiPaymtd: "1",
  19189. Hsorg: miConfig.InsuplcAdmdvs,
  19190. HsorgOpter: miConfig.InsuplcAdmdvs,
  19191. MedinsFillPsn: curRoles.UserName,
  19192. MedinsFillDept: miConfig.OrgName,
  19193. IptMedType: "2",
  19194. }
  19195. struct4101.SetlBegnDate = order.SetlTime
  19196. struct4101.SetlEndDate = order.SetlTime
  19197. time_arr := strings.Split(order.SetlTime, " ")
  19198. struct4101.AdmTime = time_arr[0]
  19199. struct4101.AdmEndTime = time_arr[0]
  19200. //
  19201. //var rf []CustomFundPay
  19202. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19203. //
  19204. //var tempFunPays []service.CustomStruct
  19205. //for _, item := range rf {
  19206. // var tempFunPay service.CustomStruct
  19207. // tempFunPay.FundPayamt = item.FundPayamt
  19208. // tempFunPay.FundPayType = item.FundPayType
  19209. // tempFunPays = append(tempFunPays, tempFunPay)
  19210. //}
  19211. //struct4101.CustomStruct = tempFunPays
  19212. var tempDiaginfos []service.DiaginfoStructTwo
  19213. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19214. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19215. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19216. var config []*models.HisXtDiagnoseConfig
  19217. for _, item := range diagnosis_ids {
  19218. id, _ := strconv.ParseInt(item, 10, 64)
  19219. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19220. config = append(config, &diagnosisConfig)
  19221. }
  19222. if miConfig.Code == "H15049901371" {
  19223. //for _, item := range config {
  19224. // if item.ID == 138 {
  19225. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19226. var tempDiaginfo service.DiaginfoStructTwo
  19227. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19228. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19229. tempDiaginfo.DiagType = "1"
  19230. tempDiaginfo.MaindiagFlag = "1"
  19231. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19232. //}
  19233. //}
  19234. for _, item := range config {
  19235. if item.ID != 138 {
  19236. var tempDiaginfo service.DiaginfoStructTwo
  19237. tempDiaginfo.DiagCode = item.CountryCode
  19238. tempDiaginfo.DiagName = item.CountryContentName
  19239. tempDiaginfo.DiagType = "1"
  19240. tempDiaginfo.MaindiagFlag = "0"
  19241. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19242. }
  19243. }
  19244. } else {
  19245. for index, item := range config {
  19246. if index == 0 {
  19247. var tempDiaginfo service.DiaginfoStructTwo
  19248. tempDiaginfo.DiagCode = item.CountryCode
  19249. tempDiaginfo.DiagName = item.CountryContentName
  19250. tempDiaginfo.DiagType = "1"
  19251. tempDiaginfo.MaindiagFlag = "1"
  19252. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19253. } else {
  19254. var tempDiaginfo service.DiaginfoStructTwo
  19255. tempDiaginfo.DiagCode = item.CountryCode
  19256. tempDiaginfo.DiagName = item.CountryContentName
  19257. tempDiaginfo.DiagType = "1"
  19258. tempDiaginfo.MaindiagFlag = "0"
  19259. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19260. }
  19261. }
  19262. }
  19263. struct4101.Diseinfo = tempDiaginfos
  19264. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19265. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19266. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19267. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19268. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19269. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19270. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19271. var iteminfo service.IteminfoStruct
  19272. var bedCostTotal float64 = 0 //床位总费
  19273. var bedCostSelfTotal float64 = 0 //床位自费
  19274. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19275. var operationCostTotal float64 = 0 //手术费
  19276. var operationCostSelfTotal float64 = 0 //手术费
  19277. var operationCostPartSelfTotal float64 = 0 //手术费
  19278. var otherCostTotal float64 = 0 //其他费用
  19279. var otherCostSelfTotal float64 = 0 //其他费用
  19280. var otherCostPartSelfTotal float64 = 0 //其他费用
  19281. var materialCostTotal float64 = 0 //材料费
  19282. var materialCostSelfTotal float64 = 0 //材料费
  19283. var materialCostPartSelfTotal float64 = 0 //材料费
  19284. var westernMedicineCostTotal float64 = 0 //西药费
  19285. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19286. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19287. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19288. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19289. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19290. var checkCostTotal float64 = 0 //检查费
  19291. var checkCostSelfTotal float64 = 0 //检查费
  19292. var checkCostPartSelfTotal float64 = 0 //检查费
  19293. var laboratoryCostTotal float64 = 0 //化验费
  19294. var laboratoryCostSelfTotal float64 = 0 //化验费
  19295. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19296. var treatCostTotal float64 = 0 //治疗费用
  19297. var treatCostSelfTotal float64 = 0 //治疗费用
  19298. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19299. decimal.DivisionPrecision = 2
  19300. var bed_fulamt_ownpay_amt float64 = 0
  19301. var operation_fulamt_ownpay_amt float64 = 0
  19302. var other_fulamt_ownpay_amt float64 = 0
  19303. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19304. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19305. var check_fulamt_ownpay_amt float64 = 0
  19306. var material_fulamt_ownpay_amt float64 = 0
  19307. var laboratory_fulamt_ownpay_amt float64 = 0
  19308. var treat_fulamt_ownpay_amt float64 = 0
  19309. var bed_claa_sunmfee float64 = 0
  19310. var bed_clab_amt float64 = 0
  19311. var bed_other_amt float64 = 0
  19312. var operation_claa_sunmfee float64 = 0
  19313. var operation_clab_amt float64 = 0
  19314. var operation_other_amt float64 = 0
  19315. var other_claa_sunmfee float64 = 0
  19316. var other_clab_amt float64 = 0
  19317. var other_other_amt float64 = 0
  19318. var westernMedicine_claa_sunmfee float64 = 0
  19319. var westernMedicine_clab_amt float64 = 0
  19320. var westernMedicine_other_amt float64 = 0
  19321. var chineseTraditional_claa_sunmfee float64 = 0
  19322. var chineseTraditional_clab_amt float64 = 0
  19323. var chineseTraditional_other_amt float64 = 0
  19324. var check_claa_sunmfee float64 = 0
  19325. var check_clab_amt float64 = 0
  19326. var check_other_amt float64 = 0
  19327. var material_claa_sunmfee float64 = 0
  19328. var material_clab_amt float64 = 0
  19329. var material_other_amt float64 = 0
  19330. var laboratory_claa_sunmfee float64 = 0
  19331. var laboratory_clab_amt float64 = 0
  19332. var laboratory_other_amt float64 = 0
  19333. var treat_claa_sunmfee float64 = 0
  19334. var treat_clab_amt float64 = 0
  19335. var treat_other_amt float64 = 0
  19336. for _, item := range order.HisOrderInfo {
  19337. if item.MedChrgitmType == "01" { //床位费
  19338. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19339. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19340. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19341. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19342. if item.ChrgitmLv == "1" {
  19343. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19344. }
  19345. if item.ChrgitmLv == "2" {
  19346. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19347. }
  19348. if item.ChrgitmLv == "3" {
  19349. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19350. }
  19351. }
  19352. if item.MedChrgitmType == "03" { //检查费
  19353. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19354. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19355. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19356. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19357. if item.ChrgitmLv == "1" {
  19358. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19359. }
  19360. if item.ChrgitmLv == "2" {
  19361. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19362. }
  19363. if item.ChrgitmLv == "3" {
  19364. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19365. }
  19366. }
  19367. if item.MedChrgitmType == "04" { //化验费
  19368. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19369. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19370. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19371. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19372. if item.ChrgitmLv == "1" {
  19373. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19374. }
  19375. if item.ChrgitmLv == "2" {
  19376. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19377. }
  19378. if item.ChrgitmLv == "3" {
  19379. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19380. }
  19381. }
  19382. if item.MedChrgitmType == "05" { //治疗费
  19383. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19384. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19385. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19386. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19387. if item.ChrgitmLv == "1" {
  19388. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19389. }
  19390. if item.ChrgitmLv == "2" {
  19391. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19392. }
  19393. if item.ChrgitmLv == "3" {
  19394. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19395. }
  19396. }
  19397. if item.MedChrgitmType == "06" { //手术费
  19398. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19399. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19400. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19401. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19402. if item.ChrgitmLv == "1" {
  19403. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19404. }
  19405. if item.ChrgitmLv == "2" {
  19406. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19407. }
  19408. if item.ChrgitmLv == "3" {
  19409. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19410. }
  19411. }
  19412. if item.MedChrgitmType == "08" { //材料费
  19413. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19414. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19415. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19416. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19417. if item.ChrgitmLv == "1" {
  19418. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19419. }
  19420. if item.ChrgitmLv == "2" {
  19421. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19422. }
  19423. if item.ChrgitmLv == "3" {
  19424. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19425. }
  19426. }
  19427. if item.MedChrgitmType == "09" { //西药费
  19428. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19429. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19430. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19431. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19432. if item.ChrgitmLv == "1" {
  19433. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19434. }
  19435. if item.ChrgitmLv == "2" {
  19436. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19437. }
  19438. if item.ChrgitmLv == "3" {
  19439. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19440. }
  19441. }
  19442. if item.MedChrgitmType == "11" { //中成费
  19443. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19444. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19445. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19446. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19447. if item.ChrgitmLv == "1" {
  19448. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19449. }
  19450. if item.ChrgitmLv == "2" {
  19451. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19452. }
  19453. if item.ChrgitmLv == "3" {
  19454. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19455. }
  19456. }
  19457. if item.MedChrgitmType == "14" { //其他费
  19458. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19459. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19460. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19461. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19462. if item.ChrgitmLv == "1" {
  19463. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19464. }
  19465. if item.ChrgitmLv == "2" {
  19466. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19467. }
  19468. if item.ChrgitmLv == "3" {
  19469. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19470. }
  19471. }
  19472. }
  19473. var iteminfoStructs []service.IteminfoStruct
  19474. if bedCostTotal != 0 {
  19475. iteminfo.MedChrgitm = "01"
  19476. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19477. iteminfo.Amt = bedCostTotal
  19478. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19479. iteminfo.ClabAmt = bed_clab_amt
  19480. iteminfo.OthAmt = bed_other_amt
  19481. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19482. }
  19483. if checkCostTotal != 0 {
  19484. iteminfo.MedChrgitm = "03"
  19485. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19486. iteminfo.Amt = checkCostTotal
  19487. iteminfo.ClaaSumfee = check_claa_sunmfee
  19488. iteminfo.ClabAmt = check_clab_amt
  19489. iteminfo.OthAmt = check_other_amt
  19490. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19491. }
  19492. if laboratoryCostTotal != 0 {
  19493. iteminfo.MedChrgitm = "04"
  19494. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19495. iteminfo.Amt = laboratoryCostTotal
  19496. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19497. iteminfo.ClabAmt = laboratory_clab_amt
  19498. iteminfo.OthAmt = laboratory_other_amt
  19499. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19500. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19501. }
  19502. if treatCostTotal != 0 {
  19503. iteminfo.MedChrgitm = "05"
  19504. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19505. iteminfo.Amt = treatCostTotal
  19506. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19507. iteminfo.ClabAmt = treat_clab_amt
  19508. iteminfo.OthAmt = treat_other_amt
  19509. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19510. //(struct4101.IteminfoStruct, iteminfo)
  19511. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19512. }
  19513. if operationCostTotal != 0 {
  19514. iteminfo.MedChrgitm = "06"
  19515. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19516. iteminfo.Amt = operationCostTotal
  19517. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19518. iteminfo.ClabAmt = operation_clab_amt
  19519. iteminfo.OthAmt = operation_other_amt
  19520. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19521. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19522. }
  19523. if materialCostTotal != 0 {
  19524. iteminfo.MedChrgitm = "08"
  19525. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19526. iteminfo.Amt = materialCostTotal
  19527. iteminfo.ClaaSumfee = material_claa_sunmfee
  19528. iteminfo.ClabAmt = material_clab_amt
  19529. iteminfo.OthAmt = material_other_amt
  19530. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19531. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19532. }
  19533. if westernMedicineCostTotal != 0 {
  19534. iteminfo.MedChrgitm = "09"
  19535. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19536. iteminfo.Amt = westernMedicineCostTotal
  19537. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19538. iteminfo.ClabAmt = westernMedicine_clab_amt
  19539. iteminfo.OthAmt = westernMedicine_other_amt
  19540. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19541. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19542. }
  19543. if chineseTraditionalMedicineCostTotal != 0 {
  19544. iteminfo.MedChrgitm = "11"
  19545. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19546. iteminfo.Amt = westernMedicineCostTotal
  19547. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19548. iteminfo.ClabAmt = westernMedicine_clab_amt
  19549. iteminfo.OthAmt = westernMedicine_other_amt
  19550. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19552. }
  19553. if otherCostTotal != 0 {
  19554. iteminfo.MedChrgitm = "14"
  19555. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19556. iteminfo.Amt = otherCostTotal
  19557. iteminfo.ClaaSumfee = other_claa_sunmfee
  19558. iteminfo.ClabAmt = other_clab_amt
  19559. iteminfo.OthAmt = other_other_amt
  19560. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19562. }
  19563. struct4101.IteminfoStruct = iteminfoStructs
  19564. struct4101.Ntly = "中国"
  19565. struct4101.AdmCaty = "A03.06"
  19566. struct4101.DoctorName = doctor.UserName
  19567. struct4101.DoctorCode = doctor.DoctorNumber
  19568. var res ResultSeventeen
  19569. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19570. struct4101.BillCode = order.Number
  19571. struct4101.BillNo = order.SetlId
  19572. var resOther ResultSeventeenOther
  19573. var pp models.PublicParams
  19574. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19575. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19576. pp.FixmedinsName = miConfig.OrgName
  19577. pp.FixmedinsCode = miConfig.Code
  19578. pp.RequestUrl = miConfig.Url
  19579. pp.Cainfo = miConfig.Cainfo
  19580. pp.SecretKey = miConfig.SecretKey
  19581. pp.AccessKey = miConfig.AccessKey
  19582. pp.OpterName = curRoles.UserName
  19583. client := &http.Client{}
  19584. var req *http.Request
  19585. data := make(map[string]interface{})
  19586. data["struct4101"] = struct4101
  19587. data["pp"] = pp
  19588. bytesData, _ := json.Marshal(data)
  19589. if miConfig.MdtrtareaAdmvs == "320921" {
  19590. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19591. } else {
  19592. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19593. }
  19594. resp, _ := client.Do(req)
  19595. defer resp.Body.Close()
  19596. body, ioErr := ioutil.ReadAll(resp.Body)
  19597. if ioErr != nil {
  19598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19600. return
  19601. }
  19602. var respJSON map[string]interface{}
  19603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19606. return
  19607. }
  19608. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19609. userJSONBytes, _ := json.Marshal(respJSON)
  19610. fmt.Println("log")
  19611. fmt.Println(string(userJSONBytes))
  19612. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19613. utils.ErrorLog("解析失败:%v", err)
  19614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19615. return
  19616. }
  19617. res.InfRefmsgid = resOther.InfRefmsgid
  19618. res.Output = resOther.Output
  19619. res.ErrMsg = resOther.ErrMsg
  19620. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19621. res.Infcode = infocode
  19622. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19623. var pp models.PublicParams
  19624. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19625. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19626. pp.FixmedinsName = miConfig.OrgName
  19627. pp.FixmedinsCode = miConfig.Code
  19628. pp.RequestUrl = miConfig.Url
  19629. pp.Cainfo = miConfig.Cainfo
  19630. pp.SecretKey = miConfig.SecretKey
  19631. pp.AccessKey = miConfig.AccessKey
  19632. pp.OpterName = curRoles.UserName
  19633. result, _ := service.Jxyb4101(struct4101, pp)
  19634. var dat map[string]interface{}
  19635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19636. fmt.Println(dat)
  19637. } else {
  19638. fmt.Println(err)
  19639. }
  19640. userJSONBytes, _ := json.Marshal(dat)
  19641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19642. utils.ErrorLog("解析失败:%v", err)
  19643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19644. return
  19645. }
  19646. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19647. var pp models.PublicParams
  19648. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19649. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19650. pp.FixmedinsName = miConfig.OrgName
  19651. pp.FixmedinsCode = miConfig.Code
  19652. pp.RequestUrl = miConfig.Url
  19653. pp.Cainfo = miConfig.Cainfo
  19654. pp.SecretKey = miConfig.SecretKey
  19655. pp.AccessKey = miConfig.AccessKey
  19656. pp.OpterName = curRoles.UserName
  19657. result, _ := service.Jxyb4101(struct4101, pp)
  19658. var dat map[string]interface{}
  19659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19660. fmt.Println(dat)
  19661. } else {
  19662. fmt.Println(err)
  19663. }
  19664. userJSONBytes, _ := json.Marshal(dat)
  19665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19666. utils.ErrorLog("解析失败:%v", err)
  19667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19668. return
  19669. }
  19670. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19671. var pp models.PublicParams
  19672. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19673. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19674. pp.FixmedinsName = miConfig.OrgName
  19675. pp.FixmedinsCode = miConfig.Code
  19676. pp.RequestUrl = miConfig.Url
  19677. pp.Cainfo = miConfig.Cainfo
  19678. pp.SecretKey = miConfig.SecretKey
  19679. pp.AccessKey = miConfig.AccessKey
  19680. pp.OpterName = curRoles.UserName
  19681. result, _ := service.Hnyb4101(struct4101, pp)
  19682. var dat map[string]interface{}
  19683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19684. fmt.Println(dat)
  19685. } else {
  19686. fmt.Println(err)
  19687. }
  19688. userJSONBytes, _ := json.Marshal(dat)
  19689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19690. utils.ErrorLog("解析失败:%v", err)
  19691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19692. return
  19693. }
  19694. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19695. var resOther ResultSeventeenOther
  19696. var pp models.PublicParams
  19697. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19698. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19699. pp.FixmedinsName = miConfig.OrgName
  19700. pp.FixmedinsCode = miConfig.Code
  19701. pp.RequestUrl = miConfig.Url
  19702. pp.Cainfo = miConfig.Cainfo
  19703. pp.SecretKey = miConfig.SecretKey
  19704. pp.AccessKey = miConfig.AccessKey
  19705. pp.OpterName = curRoles.UserName
  19706. client := &http.Client{}
  19707. var req *http.Request
  19708. data := make(map[string]interface{})
  19709. data["struct4101"] = struct4101
  19710. data["pp"] = pp
  19711. bytesData, _ := json.Marshal(data)
  19712. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19713. resp, _ := client.Do(req)
  19714. defer resp.Body.Close()
  19715. body, ioErr := ioutil.ReadAll(resp.Body)
  19716. if ioErr != nil {
  19717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19719. return
  19720. }
  19721. var respJSON map[string]interface{}
  19722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19725. return
  19726. }
  19727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19728. userJSONBytes, _ := json.Marshal(respJSON)
  19729. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19730. utils.ErrorLog("解析失败:%v", err)
  19731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19732. return
  19733. }
  19734. res.InfRefmsgid = resOther.InfRefmsgid
  19735. res.Output = resOther.Output
  19736. res.ErrMsg = resOther.ErrMsg
  19737. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19738. res.Infcode = infocode
  19739. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19740. var pp models.PublicParams
  19741. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19742. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19743. pp.FixmedinsName = miConfig.OrgName
  19744. pp.FixmedinsCode = miConfig.Code
  19745. pp.RequestUrl = miConfig.Url
  19746. pp.Cainfo = miConfig.Cainfo
  19747. pp.SecretKey = miConfig.SecretKey
  19748. pp.AccessKey = miConfig.AccessKey
  19749. pp.OpterName = curRoles.UserName
  19750. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19751. fmt.Println(requestLog)
  19752. fmt.Println(errMsgLog)
  19753. saveLog(result, requestLog, "4101a", "上传清单")
  19754. var dat map[string]interface{}
  19755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19756. fmt.Println(dat)
  19757. } else {
  19758. fmt.Println(err)
  19759. }
  19760. userJSONBytes, _ := json.Marshal(dat)
  19761. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19762. utils.ErrorLog("解析失败:%v", err)
  19763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19764. return
  19765. }
  19766. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19767. var pp models.PublicParams
  19768. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19769. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19770. pp.FixmedinsName = miConfig.OrgName
  19771. pp.FixmedinsCode = miConfig.Code
  19772. pp.RequestUrl = miConfig.Url
  19773. pp.Cainfo = miConfig.Cainfo
  19774. pp.SecretKey = miConfig.SecretKey
  19775. pp.AccessKey = miConfig.AccessKey
  19776. pp.OpterName = curRoles.UserName
  19777. client := &http.Client{}
  19778. var req *http.Request
  19779. data := make(map[string]interface{})
  19780. data["struct4101"] = struct4101
  19781. data["pp"] = pp
  19782. bytesData, _ := json.Marshal(data)
  19783. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19784. resp, _ := client.Do(req)
  19785. defer resp.Body.Close()
  19786. body, ioErr := ioutil.ReadAll(resp.Body)
  19787. if ioErr != nil {
  19788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19790. return
  19791. }
  19792. var respJSON map[string]interface{}
  19793. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19796. return
  19797. }
  19798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19799. userJSONBytes, _ := json.Marshal(respJSON)
  19800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19801. utils.ErrorLog("解析失败:%v", err)
  19802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19803. return
  19804. }
  19805. } else {
  19806. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19807. var dat map[string]interface{}
  19808. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19809. fmt.Println(dat)
  19810. } else {
  19811. fmt.Println(err)
  19812. }
  19813. userJSONBytes, _ := json.Marshal(dat)
  19814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19815. utils.ErrorLog("解析失败:%v", err)
  19816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19817. return
  19818. }
  19819. }
  19820. if res.Infcode != 0 {
  19821. c.ServeSuccessJSON(map[string]interface{}{
  19822. "failed_code": -10,
  19823. "msg": res.ErrMsg,
  19824. })
  19825. return
  19826. } else {
  19827. //order.FaPiaoNumber = zero
  19828. //order.FaPiaoCode = last_order.FaPiaoCode
  19829. //service.UpdateOrder(order)
  19830. hisFundSettleListResult := &models.HisFundSettleListResult{
  19831. Number: res.Output.SetlListId,
  19832. Status: 1,
  19833. Ctime: time.Now().Unix(),
  19834. Mtime: time.Now().Unix(),
  19835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19836. IsUpload: 1,
  19837. OrderId: order_id,
  19838. }
  19839. service.CreateUploadRecord(hisFundSettleListResult)
  19840. c.ServeSuccessJSON(map[string]interface{}{
  19841. "msg": "上传成功",
  19842. "result": hisFundSettleListResult,
  19843. })
  19844. return
  19845. }
  19846. }
  19847. func (c *HisApiController) GetSettleListHospital() {
  19848. order_id, _ := c.GetInt64("order_id")
  19849. admin_user_id, _ := c.GetInt64("admin_user_id")
  19850. order, _ := service.GetHisOrderByIDTwo(order_id)
  19851. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19852. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19853. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19854. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19855. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19857. if order.ID == 0 {
  19858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19859. return
  19860. }
  19861. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19862. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19863. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19864. fmt.Println(count)
  19865. var zero string
  19866. number := count + 1
  19867. if number >= 1000 {
  19868. zero = "0000" + strconv.FormatInt(number, 10)
  19869. } else if number >= 10000 {
  19870. zero = "000" + strconv.FormatInt(number, 10)
  19871. } else if number >= 100000 {
  19872. zero = "00" + strconv.FormatInt(number, 10)
  19873. } else if number >= 1000000 {
  19874. zero = "0" + strconv.FormatInt(number, 10)
  19875. } else {
  19876. zero = strconv.FormatInt(number, 10)
  19877. }
  19878. fmt.Println(zero)
  19879. struct4101 := service.Struct4101{
  19880. PsnNo: order.PsnNo,
  19881. MdtrtId: order.MdtrtId,
  19882. SetlId: order.SetlId,
  19883. PsnName: order.PsnName,
  19884. Gend: order.Gend,
  19885. Brdy: his.Brdy,
  19886. Age: int64(order.Age),
  19887. Naty: order.Naty,
  19888. PatnCertType: "01",
  19889. Certno: order.Certno,
  19890. Prfs: "90",
  19891. ConerName: roles[0].UserName,
  19892. PatnRlts: "99",
  19893. ConerAddr: miConfig.OrgName,
  19894. ConerTel: admin.Mobile,
  19895. HiType: order.Insutype,
  19896. Insuplc: miConfig.InsuplcAdmdvs,
  19897. MaindiagFlag: "1",
  19898. BillCode: order.SetlId,
  19899. BillNo: order.SetlId,
  19900. BizSn: order.Number,
  19901. PsnSelfPay: order.PsnPartAmt,
  19902. PsnOwnPay: order.PsnPartAmt,
  19903. AcctPay: order.AcctPay,
  19904. PsnCashpay: order.PsnCashPay,
  19905. HiPaymtd: "1",
  19906. Hsorg: miConfig.InsuplcAdmdvs,
  19907. HsorgOpter: miConfig.InsuplcAdmdvs,
  19908. MedinsFillPsn: curRoles.UserName,
  19909. MedinsFillDept: depart.Name,
  19910. IptMedType: "2",
  19911. AdmTime: his.InHosptialTime,
  19912. AdmEndTime: his.OutHosptialTime,
  19913. }
  19914. struct4101.SetlBegnDate = order.SetlTime
  19915. struct4101.SetlEndDate = order.SetlTime
  19916. //var rf []CustomFundPay
  19917. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19918. //
  19919. //var tempFunPays []service.CustomStruct
  19920. //for _, item := range rf {
  19921. // var tempFunPay service.CustomStruct
  19922. // tempFunPay.FundPayamt = item.FundPayamt
  19923. // tempFunPay.FundPayType = item.FundPayType
  19924. // tempFunPays = append(tempFunPays, tempFunPay)
  19925. //}
  19926. //struct4101.CustomStruct = tempFunPays
  19927. var tempDiaginfos []service.DiaginfoStructTwo
  19928. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19929. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19930. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19931. //for _, item := range infos {
  19932. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19933. //}
  19934. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19935. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19936. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19937. fmt.Println(diagnosis_ids_arr)
  19938. if order.UserOrgId == 10210 {
  19939. var diagnosis_ids_arr_two []int64
  19940. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19941. var config []*models.HisXtDiagnoseConfig
  19942. for _, id := range diagnosis_ids_arr_two {
  19943. //id, _ := strconv.ParseInt(item, 10, 64)
  19944. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19945. if diagnosisConfig.ID > 0 {
  19946. config = append(config, &diagnosisConfig)
  19947. }
  19948. }
  19949. for index, item := range config {
  19950. if item.ID > 0 {
  19951. if index == 0 {
  19952. var tempDiaginfo service.DiaginfoStructTwo
  19953. tempDiaginfo.DiagCode = item.CountryCode
  19954. tempDiaginfo.DiagName = item.CountryContentName
  19955. tempDiaginfo.DiagType = "1"
  19956. tempDiaginfo.MaindiagFlag = "1"
  19957. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19958. } else {
  19959. var tempDiaginfo service.DiaginfoStructTwo
  19960. tempDiaginfo.DiagCode = item.CountryCode
  19961. tempDiaginfo.DiagName = item.CountryContentName
  19962. tempDiaginfo.DiagType = "1"
  19963. tempDiaginfo.MaindiagFlag = "0"
  19964. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19965. }
  19966. }
  19967. }
  19968. struct4101.Diseinfo = tempDiaginfos
  19969. } else {
  19970. var config []*models.HisXtDiagnoseConfig
  19971. for _, item := range diagnosis_ids_arr {
  19972. id, _ := strconv.ParseInt(item, 10, 64)
  19973. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19974. if diagnosisConfig.ID > 0 {
  19975. config = append(config, &diagnosisConfig)
  19976. }
  19977. }
  19978. for index, item := range config {
  19979. if item.ID > 0 {
  19980. if index == 0 {
  19981. var tempDiaginfo service.DiaginfoStructTwo
  19982. tempDiaginfo.DiagCode = item.CountryCode
  19983. tempDiaginfo.DiagName = item.CountryContentName
  19984. tempDiaginfo.DiagType = "1"
  19985. tempDiaginfo.MaindiagFlag = "1"
  19986. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19987. } else {
  19988. var tempDiaginfo service.DiaginfoStructTwo
  19989. tempDiaginfo.DiagCode = item.CountryCode
  19990. tempDiaginfo.DiagName = item.CountryContentName
  19991. tempDiaginfo.DiagType = "1"
  19992. tempDiaginfo.MaindiagFlag = "0"
  19993. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19994. }
  19995. }
  19996. }
  19997. struct4101.Diseinfo = tempDiaginfos
  19998. }
  19999. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20000. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20001. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20002. tempOpspdiseinfo2.OprnOprtCode = ""
  20003. tempOpspdiseinfo2.OprnOprtName = ""
  20004. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20005. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20006. var iteminfo service.IteminfoStruct
  20007. var bedCostTotal float64 = 0 //床位总费
  20008. var bedCostSelfTotal float64 = 0 //床位自费
  20009. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20010. var operationCostTotal float64 = 0 //手术费
  20011. var operationCostSelfTotal float64 = 0 //手术费
  20012. var operationCostPartSelfTotal float64 = 0 //手术费
  20013. var otherCostTotal float64 = 0 //其他费用
  20014. var otherCostSelfTotal float64 = 0 //其他费用
  20015. var otherCostPartSelfTotal float64 = 0 //其他费用
  20016. var materialCostTotal float64 = 0 //材料费
  20017. var materialCostSelfTotal float64 = 0 //材料费
  20018. var materialCostPartSelfTotal float64 = 0 //材料费
  20019. var westernMedicineCostTotal float64 = 0 //西药费
  20020. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20021. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20022. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20023. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20024. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20025. var checkCostTotal float64 = 0 //检查费
  20026. var checkCostSelfTotal float64 = 0 //检查费
  20027. var checkCostPartSelfTotal float64 = 0 //检查费
  20028. var laboratoryCostTotal float64 = 0 //化验费
  20029. var laboratoryCostSelfTotal float64 = 0 //化验费
  20030. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20031. var treatCostTotal float64 = 0 //治疗费用
  20032. var treatCostSelfTotal float64 = 0 //治疗费用
  20033. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20034. decimal.DivisionPrecision = 2
  20035. var bed_fulamt_ownpay_amt float64 = 0
  20036. var operation_fulamt_ownpay_amt float64 = 0
  20037. var other_fulamt_ownpay_amt float64 = 0
  20038. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20039. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20040. var check_fulamt_ownpay_amt float64 = 0
  20041. var material_fulamt_ownpay_amt float64 = 0
  20042. var laboratory_fulamt_ownpay_amt float64 = 0
  20043. var treat_fulamt_ownpay_amt float64 = 0
  20044. var bed_claa_sunmfee float64 = 0
  20045. var bed_clab_amt float64 = 0
  20046. var bed_other_amt float64 = 0
  20047. var operation_claa_sunmfee float64 = 0
  20048. var operation_clab_amt float64 = 0
  20049. var operation_other_amt float64 = 0
  20050. var other_claa_sunmfee float64 = 0
  20051. var other_clab_amt float64 = 0
  20052. var other_other_amt float64 = 0
  20053. var westernMedicine_claa_sunmfee float64 = 0
  20054. var westernMedicine_clab_amt float64 = 0
  20055. var westernMedicine_other_amt float64 = 0
  20056. var chineseTraditional_claa_sunmfee float64 = 0
  20057. var chineseTraditional_clab_amt float64 = 0
  20058. var chineseTraditional_other_amt float64 = 0
  20059. var check_claa_sunmfee float64 = 0
  20060. var check_clab_amt float64 = 0
  20061. var check_other_amt float64 = 0
  20062. var material_claa_sunmfee float64 = 0
  20063. var material_clab_amt float64 = 0
  20064. var material_other_amt float64 = 0
  20065. var laboratory_claa_sunmfee float64 = 0
  20066. var laboratory_clab_amt float64 = 0
  20067. var laboratory_other_amt float64 = 0
  20068. var treat_claa_sunmfee float64 = 0
  20069. var treat_clab_amt float64 = 0
  20070. var treat_other_amt float64 = 0
  20071. for _, item := range order.HisOrderInfo {
  20072. if item.MedChrgitmType == "01" { //床位费
  20073. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20074. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20075. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20076. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20077. if item.ChrgitmLv == "1" {
  20078. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20079. }
  20080. if item.ChrgitmLv == "2" {
  20081. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20082. }
  20083. if item.ChrgitmLv == "3" {
  20084. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20085. }
  20086. }
  20087. if item.MedChrgitmType == "03" { //检查费
  20088. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20089. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20090. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20091. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20092. if item.ChrgitmLv == "1" {
  20093. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20094. }
  20095. if item.ChrgitmLv == "2" {
  20096. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20097. }
  20098. if item.ChrgitmLv == "3" {
  20099. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20100. }
  20101. }
  20102. if item.MedChrgitmType == "04" { //化验费
  20103. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20104. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20105. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20106. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20107. if item.ChrgitmLv == "1" {
  20108. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20109. }
  20110. if item.ChrgitmLv == "2" {
  20111. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20112. }
  20113. if item.ChrgitmLv == "3" {
  20114. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20115. }
  20116. }
  20117. if item.MedChrgitmType == "05" { //治疗费
  20118. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20119. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20120. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20121. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20122. if item.ChrgitmLv == "1" {
  20123. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20124. }
  20125. if item.ChrgitmLv == "2" {
  20126. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20127. }
  20128. if item.ChrgitmLv == "3" {
  20129. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20130. }
  20131. }
  20132. if item.MedChrgitmType == "06" { //手术费
  20133. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20134. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20135. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20136. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20137. if item.ChrgitmLv == "1" {
  20138. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20139. }
  20140. if item.ChrgitmLv == "2" {
  20141. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20142. }
  20143. if item.ChrgitmLv == "3" {
  20144. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20145. }
  20146. }
  20147. if item.MedChrgitmType == "08" { //材料费
  20148. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20149. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20150. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20151. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20152. if item.ChrgitmLv == "1" {
  20153. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20154. }
  20155. if item.ChrgitmLv == "2" {
  20156. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20157. }
  20158. if item.ChrgitmLv == "3" {
  20159. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20160. }
  20161. }
  20162. if item.MedChrgitmType == "09" { //西药费
  20163. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20164. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20165. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20166. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20167. if item.ChrgitmLv == "1" {
  20168. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20169. }
  20170. if item.ChrgitmLv == "2" {
  20171. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20172. }
  20173. if item.ChrgitmLv == "3" {
  20174. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20175. }
  20176. }
  20177. if item.MedChrgitmType == "11" { //中成费
  20178. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20179. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20180. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20181. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20182. if item.ChrgitmLv == "1" {
  20183. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20184. }
  20185. if item.ChrgitmLv == "2" {
  20186. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20187. }
  20188. if item.ChrgitmLv == "3" {
  20189. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20190. }
  20191. }
  20192. if item.MedChrgitmType == "14" { //其他费
  20193. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20194. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20195. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20196. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20197. if item.ChrgitmLv == "1" {
  20198. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20199. }
  20200. if item.ChrgitmLv == "2" {
  20201. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20202. }
  20203. if item.ChrgitmLv == "3" {
  20204. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20205. }
  20206. }
  20207. }
  20208. var iteminfoStructs []service.IteminfoStruct
  20209. if bedCostTotal != 0 {
  20210. iteminfo.MedChrgitm = "01"
  20211. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20212. iteminfo.Amt = bedCostTotal
  20213. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20214. iteminfo.ClabAmt = bed_clab_amt
  20215. iteminfo.OthAmt = bed_other_amt
  20216. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20217. }
  20218. if checkCostTotal != 0 {
  20219. iteminfo.MedChrgitm = "03"
  20220. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20221. iteminfo.Amt = checkCostTotal
  20222. iteminfo.ClaaSumfee = check_claa_sunmfee
  20223. iteminfo.ClabAmt = check_clab_amt
  20224. iteminfo.OthAmt = check_other_amt
  20225. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20226. }
  20227. if laboratoryCostTotal != 0 {
  20228. iteminfo.MedChrgitm = "04"
  20229. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20230. iteminfo.Amt = laboratoryCostTotal
  20231. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20232. iteminfo.ClabAmt = laboratory_clab_amt
  20233. iteminfo.OthAmt = laboratory_other_amt
  20234. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20235. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20236. }
  20237. if treatCostTotal != 0 {
  20238. iteminfo.MedChrgitm = "05"
  20239. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20240. iteminfo.Amt = treatCostTotal
  20241. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20242. iteminfo.ClabAmt = treat_clab_amt
  20243. iteminfo.OthAmt = treat_other_amt
  20244. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20245. //(struct4101.IteminfoStruct, iteminfo)
  20246. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20247. }
  20248. if operationCostTotal != 0 {
  20249. iteminfo.MedChrgitm = "06"
  20250. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20251. iteminfo.Amt = operationCostTotal
  20252. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20253. iteminfo.ClabAmt = operation_clab_amt
  20254. iteminfo.OthAmt = operation_other_amt
  20255. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20256. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20257. }
  20258. if materialCostTotal != 0 {
  20259. iteminfo.MedChrgitm = "08"
  20260. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20261. iteminfo.Amt = materialCostTotal
  20262. iteminfo.ClaaSumfee = material_claa_sunmfee
  20263. iteminfo.ClabAmt = material_clab_amt
  20264. iteminfo.OthAmt = material_other_amt
  20265. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20266. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20267. }
  20268. if westernMedicineCostTotal != 0 {
  20269. iteminfo.MedChrgitm = "09"
  20270. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20271. iteminfo.Amt = westernMedicineCostTotal
  20272. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20273. iteminfo.ClabAmt = westernMedicine_clab_amt
  20274. iteminfo.OthAmt = westernMedicine_other_amt
  20275. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20276. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20277. }
  20278. if chineseTraditionalMedicineCostTotal != 0 {
  20279. iteminfo.MedChrgitm = "11"
  20280. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20281. iteminfo.Amt = westernMedicineCostTotal
  20282. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20283. iteminfo.ClabAmt = westernMedicine_clab_amt
  20284. iteminfo.OthAmt = westernMedicine_other_amt
  20285. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20286. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20287. }
  20288. if otherCostTotal != 0 {
  20289. iteminfo.MedChrgitm = "14"
  20290. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20291. iteminfo.Amt = otherCostTotal
  20292. iteminfo.ClaaSumfee = other_claa_sunmfee
  20293. iteminfo.ClabAmt = other_clab_amt
  20294. iteminfo.OthAmt = other_other_amt
  20295. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20296. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20297. }
  20298. struct4101.IteminfoStruct = iteminfoStructs
  20299. struct4101.Ntly = "中国"
  20300. struct4101.AdmCaty = "A03.06"
  20301. var resOther ResultSeventeenOther
  20302. var res ResultSeventeen
  20303. if miConfig.MdtrtareaAdmvs == "150499" {
  20304. var pp models.PublicParams
  20305. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20306. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20307. pp.FixmedinsName = miConfig.OrgName
  20308. pp.FixmedinsCode = miConfig.Code
  20309. pp.RequestUrl = miConfig.Url
  20310. pp.Cainfo = miConfig.Cainfo
  20311. pp.SecretKey = miConfig.SecretKey
  20312. pp.AccessKey = miConfig.AccessKey
  20313. pp.OpterName = curRoles.UserName
  20314. client := &http.Client{}
  20315. var req *http.Request
  20316. data := make(map[string]interface{})
  20317. data["struct4101"] = struct4101
  20318. data["pp"] = pp
  20319. bytesData, _ := json.Marshal(data)
  20320. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20321. resp, _ := client.Do(req)
  20322. defer resp.Body.Close()
  20323. body, ioErr := ioutil.ReadAll(resp.Body)
  20324. if ioErr != nil {
  20325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20327. return
  20328. }
  20329. var respJSON map[string]interface{}
  20330. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20333. return
  20334. }
  20335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20336. userJSONBytes, _ := json.Marshal(respJSON)
  20337. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20338. utils.ErrorLog("解析失败:%v", err)
  20339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20340. return
  20341. }
  20342. res.InfRefmsgid = resOther.InfRefmsgid
  20343. res.Output = resOther.Output
  20344. res.ErrMsg = resOther.ErrMsg
  20345. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20346. res.Infcode = infocode
  20347. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20348. var pp models.PublicParams
  20349. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20350. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20351. pp.FixmedinsName = miConfig.OrgName
  20352. pp.FixmedinsCode = miConfig.Code
  20353. pp.RequestUrl = miConfig.Url
  20354. pp.Cainfo = miConfig.Cainfo
  20355. pp.SecretKey = miConfig.SecretKey
  20356. pp.AccessKey = miConfig.AccessKey
  20357. pp.OpterName = curRoles.UserName
  20358. result, _ := service.Jxyb4101(struct4101, pp)
  20359. var dat map[string]interface{}
  20360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20361. fmt.Println(dat)
  20362. } else {
  20363. fmt.Println(err)
  20364. }
  20365. userJSONBytes, _ := json.Marshal(dat)
  20366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20367. utils.ErrorLog("解析失败:%v", err)
  20368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20369. return
  20370. }
  20371. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20372. var pp models.PublicParams
  20373. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20374. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20375. pp.FixmedinsName = miConfig.OrgName
  20376. pp.FixmedinsCode = miConfig.Code
  20377. pp.RequestUrl = miConfig.Url
  20378. pp.Cainfo = miConfig.Cainfo
  20379. pp.SecretKey = miConfig.SecretKey
  20380. pp.AccessKey = miConfig.AccessKey
  20381. pp.OpterName = curRoles.UserName
  20382. result, _ := service.Jxyb4101(struct4101, pp)
  20383. var dat map[string]interface{}
  20384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20385. fmt.Println(dat)
  20386. } else {
  20387. fmt.Println(err)
  20388. }
  20389. userJSONBytes, _ := json.Marshal(dat)
  20390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20391. utils.ErrorLog("解析失败:%v", err)
  20392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20393. return
  20394. }
  20395. } else {
  20396. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20397. var dat map[string]interface{}
  20398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20399. fmt.Println(dat)
  20400. } else {
  20401. fmt.Println(err)
  20402. }
  20403. userJSONBytes, _ := json.Marshal(dat)
  20404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20405. utils.ErrorLog("解析失败:%v", err)
  20406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20407. return
  20408. }
  20409. }
  20410. if res.Infcode != 0 {
  20411. c.ServeSuccessJSON(map[string]interface{}{
  20412. "failed_code": -10,
  20413. "msg": res.ErrMsg,
  20414. })
  20415. return
  20416. } else {
  20417. if miConfig.MdtrtareaAdmvs != "150499" {
  20418. order.FaPiaoNumber = zero
  20419. order.FaPiaoCode = last_order.FaPiaoCode
  20420. service.UpdateOrder(order)
  20421. }
  20422. hisFundSettleListResult := &models.HisFundSettleListResult{
  20423. Number: res.Output.SetlListId,
  20424. Status: 1,
  20425. Ctime: time.Now().Unix(),
  20426. Mtime: time.Now().Unix(),
  20427. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20428. IsUpload: 1,
  20429. OrderId: order_id,
  20430. }
  20431. service.CreateUploadRecord(hisFundSettleListResult)
  20432. c.ServeSuccessJSON(map[string]interface{}{
  20433. "msg": "上传成功",
  20434. "result": hisFundSettleListResult,
  20435. })
  20436. return
  20437. }
  20438. }
  20439. //func (c *HisApiController) GetBatchSettleList() {
  20440. // orders, _ := service.GetAllHisOrder(10106)
  20441. // for _, item := range orders {
  20442. // order_id := item.ID
  20443. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20444. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20445. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20446. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20447. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20448. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20449. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20450. //
  20451. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20452. //
  20453. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20454. //
  20455. // if order.ID == 0 {
  20456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20457. // return
  20458. // }
  20459. // if his.BalanceAccountsType == 2 {
  20460. // continue
  20461. // }
  20462. // struct4101 := service.Struct4101{
  20463. // PsnNo: order.PsnNo,
  20464. // MdtrtId: order.MdtrtId,
  20465. // SetlId: order.SetlId,
  20466. // PsnName: order.PsnName,
  20467. // Gend: order.Gend,
  20468. // Brdy: his.Brdy,
  20469. // Age: his.Age,
  20470. // Naty: order.Naty,
  20471. // PatnCertType: "01",
  20472. // Certno: order.Certno,
  20473. // Prfs: "90",
  20474. // ConerName: roles[0].UserName,
  20475. // PatnRlts: "99",
  20476. // ConerAddr: miConfig.OrgName,
  20477. // ConerTel: admin.Mobile,
  20478. // HiType: order.Insutype,
  20479. // Insuplc: his.InsuplcAdmdvs,
  20480. // MaindiagFlag: "1",
  20481. // BillCode: order.SetlId,
  20482. // BillNo: order.SetlId,
  20483. // BizSn: order.Number,
  20484. // PsnSelfPay: order.PsnPartAmt,
  20485. // PsnOwnPay: order.PsnPartAmt,
  20486. // AcctPay: order.AcctPay,
  20487. // PsnCashpay: order.PsnCashPay,
  20488. // HiPaymtd: "1",
  20489. // Hsorg: his.InsuplcAdmdvs,
  20490. // HsorgOpter: his.InsuplcAdmdvs,
  20491. // MedinsFillPsn: curRoles.UserName,
  20492. // MedinsFillDept: depart.Name,
  20493. // IptMedType: "2",
  20494. // }
  20495. // struct4101.SetlBegnDate = order.SetlTime
  20496. // struct4101.SetlEndDate = order.SetlTime
  20497. // //if order.SettleType == 1 {
  20498. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20499. // // dateStr := t.Format("2006-01-02")
  20500. // // struct4101.SetlBegnDate = dateStr
  20501. // // struct4101.SetlEndDate = dateStr
  20502. // //} else {
  20503. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20504. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20505. // // dateStartStr := t.Format("2006-01-02")
  20506. // // dateEndStr := t2.Format("2006-01-02")
  20507. // // struct4101.SetlBegnDate = dateStartStr
  20508. // // struct4101.SetlEndDate = dateEndStr
  20509. // //}
  20510. //
  20511. // var rf []CustomFundPay
  20512. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20513. //
  20514. // var tempFunPays []service.CustomStruct
  20515. // var tempFunPay610100 service.CustomStruct
  20516. //
  20517. // for _, item := range rf {
  20518. // if item.FundPayType == "610100" {
  20519. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20520. // tempFunPay610100.FundPayType = item.FundPayType
  20521. // } else {
  20522. // var tempFunPay service.CustomStruct
  20523. // tempFunPay.FundPayamt = item.FundPayamt
  20524. // tempFunPay.FundPayType = item.FundPayType
  20525. // tempFunPays = append(tempFunPays, tempFunPay)
  20526. // }
  20527. // }
  20528. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20529. // struct4101.CustomStruct = tempFunPays
  20530. //
  20531. // var tempDiaginfos []service.DiaginfoStructTwo
  20532. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20533. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20534. //
  20535. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20536. // var config []*models.HisXtDiagnoseConfig
  20537. // for _, item := range diagnosis_ids {
  20538. // id, _ := strconv.ParseInt(item, 10, 64)
  20539. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20540. // config = append(config, &diagnosisConfig)
  20541. // }
  20542. //
  20543. // for index, item := range config {
  20544. // if index == 0 {
  20545. // var tempDiaginfo service.DiaginfoStructTwo
  20546. // tempDiaginfo.DiagCode = item.CountryCode
  20547. // tempDiaginfo.DiagName = item.CountryContentName
  20548. // tempDiaginfo.DiagType = "1"
  20549. // tempDiaginfo.MaindiagFlag = "1"
  20550. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20551. // } else {
  20552. //
  20553. // var tempDiaginfo service.DiaginfoStructTwo
  20554. // tempDiaginfo.DiagCode = item.CountryCode
  20555. // tempDiaginfo.DiagName = item.CountryContentName
  20556. // tempDiaginfo.DiagType = "2"
  20557. // tempDiaginfo.MaindiagFlag = "0"
  20558. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20559. // }
  20560. // }
  20561. // struct4101.Diseinfo = tempDiaginfos
  20562. //
  20563. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20564. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20565. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20566. // tempOpspdiseinfo2.OprnOprtCode = ""
  20567. // tempOpspdiseinfo2.OprnOprtName = ""
  20568. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20569. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20570. //
  20571. // var iteminfo service.IteminfoStruct
  20572. //
  20573. // var bedCostTotal float64 = 0 //床位总费
  20574. // var bedCostSelfTotal float64 = 0 //床位自费
  20575. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20576. //
  20577. // var examineCostTotal float64 = 0 //诊查总费
  20578. // var examineCostSelfTotal float64 = 0 //诊查自费
  20579. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20580. //
  20581. // var nursingCostTotal float64 = 0 //护理总费
  20582. // var nursingCostSelfTotal float64 = 0 //护理自费
  20583. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20584. //
  20585. // var chineseMedicineCostTotal float64 = 0 //中成药
  20586. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20587. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20588. //
  20589. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20590. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20591. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20592. //
  20593. // var registerCostTotal float64 = 0 //一般诊疗费
  20594. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20595. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20596. //
  20597. // var operationCostTotal float64 = 0 //手术费
  20598. // var operationCostSelfTotal float64 = 0 //手术费
  20599. // var operationCostPartSelfTotal float64 = 0 //手术费
  20600. //
  20601. // var otherCostTotal float64 = 0 //其他费用
  20602. // var otherCostSelfTotal float64 = 0 //其他费用
  20603. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20604. //
  20605. // var materialCostTotal float64 = 0 //材料费
  20606. // var materialCostSelfTotal float64 = 0 //材料费
  20607. // var materialCostPartSelfTotal float64 = 0 //材料费
  20608. //
  20609. // var westernMedicineCostTotal float64 = 0 //西药费
  20610. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20611. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20612. //
  20613. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20614. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20615. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20616. //
  20617. // var checkCostTotal float64 = 0 //检查费
  20618. // var checkCostSelfTotal float64 = 0 //检查费
  20619. // var checkCostPartSelfTotal float64 = 0 //检查费
  20620. //
  20621. // var laboratoryCostTotal float64 = 0 //化验费
  20622. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20623. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20624. //
  20625. // var treatCostTotal float64 = 0 //治疗费用
  20626. // var treatCostSelfTotal float64 = 0 //治疗费用
  20627. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20628. //
  20629. // decimal.DivisionPrecision = 2
  20630. //
  20631. // var bed_fulamt_ownpay_amt float64 = 0
  20632. //
  20633. // var examine_fulamt_ownpay_amt float64 = 0
  20634. //
  20635. // var nursing_fulamt_ownpay_amt float64 = 0
  20636. //
  20637. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20638. //
  20639. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20640. //
  20641. // var register_fulamt_ownpay_amt float64 = 0
  20642. //
  20643. // var operation_fulamt_ownpay_amt float64 = 0
  20644. // var other_fulamt_ownpay_amt float64 = 0
  20645. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20646. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20647. // var check_fulamt_ownpay_amt float64 = 0
  20648. // var material_fulamt_ownpay_amt float64 = 0
  20649. // var laboratory_fulamt_ownpay_amt float64 = 0
  20650. // var treat_fulamt_ownpay_amt float64 = 0
  20651. //
  20652. // var bed_claa_sunmfee float64 = 0
  20653. // var bed_clab_amt float64 = 0
  20654. // var bed_other_amt float64 = 0
  20655. //
  20656. // var examine_claa_sunmfee float64 = 0
  20657. // var examine_clab_amt float64 = 0
  20658. // var examine_other_amt float64 = 0
  20659. //
  20660. // var nursing_claa_sunmfee float64 = 0
  20661. // var nursing_clab_amt float64 = 0
  20662. // var nursing_other_amt float64 = 0
  20663. //
  20664. // var chinese_medicine_claa_sunmfee float64 = 0
  20665. // var chinese_medicine_clab_amt float64 = 0
  20666. // var chinese_medicine_other_amt float64 = 0
  20667. //
  20668. // var commonly_treatment_claa_sunmfee float64 = 0
  20669. // var commonly_treatment_clab_amt float64 = 0
  20670. // var commonly_treatment_other_amt float64 = 0
  20671. //
  20672. // var operation_claa_sunmfee float64 = 0
  20673. // var operation_clab_amt float64 = 0
  20674. // var operation_other_amt float64 = 0
  20675. //
  20676. // var other_claa_sunmfee float64 = 0
  20677. // var other_clab_amt float64 = 0
  20678. // var other_other_amt float64 = 0
  20679. //
  20680. // var westernMedicine_claa_sunmfee float64 = 0
  20681. // var westernMedicine_clab_amt float64 = 0
  20682. // var westernMedicine_other_amt float64 = 0
  20683. //
  20684. // var chineseTraditional_claa_sunmfee float64 = 0
  20685. // var chineseTraditional_clab_amt float64 = 0
  20686. // var chineseTraditional_other_amt float64 = 0
  20687. //
  20688. // var check_claa_sunmfee float64 = 0
  20689. // var check_clab_amt float64 = 0
  20690. // var check_other_amt float64 = 0
  20691. //
  20692. // var material_claa_sunmfee float64 = 0
  20693. // var material_clab_amt float64 = 0
  20694. // var material_other_amt float64 = 0
  20695. //
  20696. // var laboratory_claa_sunmfee float64 = 0
  20697. // var laboratory_clab_amt float64 = 0
  20698. // var laboratory_other_amt float64 = 0
  20699. //
  20700. // var treat_claa_sunmfee float64 = 0
  20701. // var treat_clab_amt float64 = 0
  20702. // var treat_other_amt float64 = 0
  20703. //
  20704. // var register_claa_sunmfee float64 = 0
  20705. // var register_clab_amt float64 = 0
  20706. // var register_other_amt float64 = 0
  20707. //
  20708. // for _, item := range order.HisOrderInfo {
  20709. // if item.MedChrgitmType == "01" { //床位费
  20710. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20711. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20712. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20713. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20714. // if item.ChrgitmLv == "1" {
  20715. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20716. // }
  20717. // if item.ChrgitmLv == "2" {
  20718. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20719. //
  20720. // }
  20721. // if item.ChrgitmLv == "3" {
  20722. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20723. // }
  20724. //
  20725. // }
  20726. //
  20727. // if item.MedChrgitmType == "02" { //诊查
  20728. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20729. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20730. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20731. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20732. // if item.ChrgitmLv == "1" {
  20733. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20734. // }
  20735. // if item.ChrgitmLv == "2" {
  20736. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20737. //
  20738. // }
  20739. // if item.ChrgitmLv == "3" {
  20740. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20741. // }
  20742. //
  20743. // }
  20744. //
  20745. // if item.MedChrgitmType == "03" { //检查费
  20746. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20747. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20748. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20749. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20750. // if item.ChrgitmLv == "1" {
  20751. //
  20752. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20753. //
  20754. // }
  20755. // if item.ChrgitmLv == "2" {
  20756. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20757. //
  20758. // }
  20759. // if item.ChrgitmLv == "3" {
  20760. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20761. // }
  20762. // }
  20763. //
  20764. // if item.MedChrgitmType == "04" { //化验费
  20765. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20766. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20767. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20768. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20769. // if item.ChrgitmLv == "1" {
  20770. //
  20771. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20772. //
  20773. // }
  20774. // if item.ChrgitmLv == "2" {
  20775. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20776. //
  20777. // }
  20778. // if item.ChrgitmLv == "3" {
  20779. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20780. // }
  20781. // }
  20782. //
  20783. // if item.MedChrgitmType == "05" { //治疗费
  20784. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20785. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20786. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20787. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20788. // if item.ChrgitmLv == "1" {
  20789. //
  20790. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20791. //
  20792. // }
  20793. // if item.ChrgitmLv == "2" {
  20794. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20795. //
  20796. // }
  20797. // if item.ChrgitmLv == "3" {
  20798. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20799. // }
  20800. // }
  20801. //
  20802. // if item.MedChrgitmType == "06" { //手术费
  20803. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20804. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20805. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20806. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20807. //
  20808. // if item.ChrgitmLv == "1" {
  20809. //
  20810. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20811. //
  20812. // }
  20813. // if item.ChrgitmLv == "2" {
  20814. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20815. //
  20816. // }
  20817. // if item.ChrgitmLv == "3" {
  20818. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20819. // }
  20820. // }
  20821. //
  20822. // if item.MedChrgitmType == "07" { //手术费
  20823. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20824. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20825. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20826. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20827. //
  20828. // if item.ChrgitmLv == "1" {
  20829. //
  20830. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20831. //
  20832. // }
  20833. // if item.ChrgitmLv == "2" {
  20834. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20835. //
  20836. // }
  20837. // if item.ChrgitmLv == "3" {
  20838. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20839. // }
  20840. // }
  20841. //
  20842. // if item.MedChrgitmType == "08" { //材料费
  20843. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20844. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20845. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20846. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20847. // if item.ChrgitmLv == "1" {
  20848. //
  20849. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20850. //
  20851. // }
  20852. // if item.ChrgitmLv == "2" {
  20853. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20854. //
  20855. // }
  20856. // if item.ChrgitmLv == "3" {
  20857. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20858. // }
  20859. // }
  20860. // if item.MedChrgitmType == "09" { //西药费
  20861. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20862. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20863. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20864. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20865. // if item.ChrgitmLv == "1" {
  20866. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20867. // }
  20868. // if item.ChrgitmLv == "2" {
  20869. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20870. // }
  20871. // if item.ChrgitmLv == "3" {
  20872. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20873. // }
  20874. // }
  20875. // if item.MedChrgitmType == "10" { //中药饮片
  20876. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20877. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20878. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20879. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20880. // if item.ChrgitmLv == "1" {
  20881. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20882. // }
  20883. // if item.ChrgitmLv == "2" {
  20884. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20885. // }
  20886. // if item.ChrgitmLv == "3" {
  20887. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20888. // }
  20889. // }
  20890. //
  20891. // if item.MedChrgitmType == "11" { //中成费
  20892. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20893. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20894. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20895. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20896. // if item.ChrgitmLv == "1" {
  20897. //
  20898. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20899. //
  20900. // }
  20901. // if item.ChrgitmLv == "2" {
  20902. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20903. //
  20904. // }
  20905. // if item.ChrgitmLv == "3" {
  20906. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20907. // }
  20908. // }
  20909. //
  20910. // if item.MedChrgitmType == "12" { //中成费
  20911. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20912. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20913. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20914. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20915. // if item.ChrgitmLv == "1" {
  20916. //
  20917. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20918. //
  20919. // }
  20920. // if item.ChrgitmLv == "2" {
  20921. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20922. //
  20923. // }
  20924. // if item.ChrgitmLv == "3" {
  20925. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20926. // }
  20927. // }
  20928. //
  20929. // if item.MedChrgitmType == "13" { //中成费
  20930. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20931. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20932. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20933. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20934. // if item.ChrgitmLv == "1" {
  20935. //
  20936. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20937. //
  20938. // }
  20939. // if item.ChrgitmLv == "2" {
  20940. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20941. //
  20942. // }
  20943. // if item.ChrgitmLv == "3" {
  20944. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20945. // }
  20946. // }
  20947. //
  20948. // if item.MedChrgitmType == "14" { //其他费
  20949. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20950. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20951. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20952. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20953. // if item.ChrgitmLv == "1" {
  20954. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20955. //
  20956. // }
  20957. // if item.ChrgitmLv == "2" {
  20958. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20959. //
  20960. // }
  20961. // if item.ChrgitmLv == "3" {
  20962. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20963. // }
  20964. // }
  20965. //
  20966. // }
  20967. //
  20968. // var iteminfoStructs []service.IteminfoStruct
  20969. //
  20970. // if bedCostTotal != 0 {
  20971. // iteminfo.MedChrgitm = "01"
  20972. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20973. // iteminfo.Amt = bedCostTotal
  20974. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20975. // iteminfo.ClabAmt = bed_clab_amt
  20976. // iteminfo.OthAmt = bed_other_amt
  20977. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20978. // }
  20979. //
  20980. // if examineCostTotal != 0 {
  20981. // iteminfo.MedChrgitm = "02"
  20982. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20983. // iteminfo.Amt = examineCostTotal
  20984. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20985. // iteminfo.ClabAmt = examine_clab_amt
  20986. // iteminfo.OthAmt = examine_other_amt
  20987. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20988. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20989. // }
  20990. //
  20991. // if checkCostTotal != 0 {
  20992. // iteminfo.MedChrgitm = "03"
  20993. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20994. // iteminfo.Amt = checkCostTotal
  20995. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20996. // iteminfo.ClabAmt = check_clab_amt
  20997. // iteminfo.OthAmt = check_other_amt
  20998. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20999. //
  21000. // }
  21001. //
  21002. // if laboratoryCostTotal != 0 {
  21003. // iteminfo.MedChrgitm = "04"
  21004. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21005. // iteminfo.Amt = laboratoryCostTotal
  21006. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21007. // iteminfo.ClabAmt = laboratory_clab_amt
  21008. // iteminfo.OthAmt = laboratory_other_amt
  21009. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21010. //
  21011. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21012. //
  21013. // }
  21014. //
  21015. // if treatCostTotal != 0 {
  21016. // iteminfo.MedChrgitm = "05"
  21017. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21018. // iteminfo.Amt = treatCostTotal
  21019. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21020. // iteminfo.ClabAmt = treat_clab_amt
  21021. // iteminfo.OthAmt = treat_other_amt
  21022. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21023. // //(struct4101.IteminfoStruct, iteminfo)
  21024. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21025. // }
  21026. //
  21027. // if operationCostTotal != 0 {
  21028. // iteminfo.MedChrgitm = "06"
  21029. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21030. // iteminfo.Amt = operationCostTotal
  21031. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21032. // iteminfo.ClabAmt = operation_clab_amt
  21033. // iteminfo.OthAmt = operation_other_amt
  21034. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21035. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21036. // }
  21037. //
  21038. // if nursingCostTotal != 0 {
  21039. // iteminfo.MedChrgitm = "07"
  21040. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21041. // iteminfo.Amt = nursingCostTotal
  21042. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21043. // iteminfo.ClabAmt = nursing_clab_amt
  21044. // iteminfo.OthAmt = nursing_other_amt
  21045. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21046. // }
  21047. //
  21048. // if materialCostTotal != 0 {
  21049. // iteminfo.MedChrgitm = "08"
  21050. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21051. // iteminfo.Amt = materialCostTotal
  21052. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21053. // iteminfo.ClabAmt = material_clab_amt
  21054. // iteminfo.OthAmt = material_other_amt
  21055. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21056. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21057. // }
  21058. //
  21059. // if westernMedicineCostTotal != 0 {
  21060. // iteminfo.MedChrgitm = "09"
  21061. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21062. // iteminfo.Amt = westernMedicineCostTotal
  21063. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21064. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21065. // iteminfo.OthAmt = westernMedicine_other_amt
  21066. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21067. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21068. //
  21069. // }
  21070. //
  21071. // if chineseMedicineCostTotal != 0 {
  21072. // iteminfo.MedChrgitm = "10"
  21073. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21074. // iteminfo.Amt = chineseMedicineCostTotal
  21075. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21076. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21077. // iteminfo.OthAmt = chinese_medicine_other_amt
  21078. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21079. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21080. //
  21081. // }
  21082. //
  21083. // if chineseTraditionalMedicineCostTotal != 0 {
  21084. // iteminfo.MedChrgitm = "11"
  21085. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21086. // iteminfo.Amt = westernMedicineCostTotal
  21087. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21088. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21089. // iteminfo.OthAmt = westernMedicine_other_amt
  21090. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21091. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21092. //
  21093. // }
  21094. //
  21095. // if commonlyTreatmentCostTotal != 0 {
  21096. // iteminfo.MedChrgitm = "12"
  21097. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21098. // iteminfo.Amt = commonlyTreatmentCostTotal
  21099. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21100. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21101. // iteminfo.OthAmt = commonly_treatment_other_amt
  21102. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21103. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21104. //
  21105. // }
  21106. //
  21107. // if registerCostTotal != 0 {
  21108. // iteminfo.MedChrgitm = "13"
  21109. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21110. // iteminfo.Amt = registerCostTotal
  21111. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21112. // iteminfo.ClabAmt = register_clab_amt
  21113. // iteminfo.OthAmt = register_other_amt
  21114. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21115. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21116. //
  21117. // }
  21118. //
  21119. // if otherCostTotal != 0 {
  21120. // iteminfo.MedChrgitm = "14"
  21121. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21122. // iteminfo.Amt = otherCostTotal
  21123. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21124. // iteminfo.ClabAmt = other_clab_amt
  21125. // iteminfo.OthAmt = other_other_amt
  21126. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21127. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21128. //
  21129. // }
  21130. // struct4101.IteminfoStruct = iteminfoStructs
  21131. // time_arr := strings.Split(order.SetlTime, " ")
  21132. // struct4101.AdmTime = time_arr[0]
  21133. // struct4101.AdmEndTime = time_arr[0]
  21134. //
  21135. // struct4101.DoctorName = doctor.UserName
  21136. // struct4101.DoctorCode = doctor.DoctorNumber
  21137. //
  21138. // struct4101.Ntly = "中国"
  21139. // struct4101.AdmCaty = "A03.06"
  21140. // var res ResultSeventeen
  21141. // if miConfig.MdtrtareaAdmvs == "421300" {
  21142. // data := make(map[string]interface{})
  21143. // data["struct4101"] = struct4101
  21144. // data["secret_key"] = miConfig.SecretKey
  21145. // data["org_name"] = miConfig.OrgName
  21146. // data["opera"] = curRoles.UserName
  21147. // data["code"] = miConfig.Code
  21148. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21149. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21150. //
  21151. // client := &http.Client{}
  21152. // bytesData, _ := json.Marshal(data)
  21153. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21154. // resp, _ := client.Do(req)
  21155. // defer resp.Body.Close()
  21156. // body, ioErr := ioutil.ReadAll(resp.Body)
  21157. // if ioErr != nil {
  21158. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21159. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21160. // return
  21161. // }
  21162. // var respJSON map[string]interface{}
  21163. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21164. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21166. // return
  21167. // }
  21168. //
  21169. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21170. // userJSONBytes, _ := json.Marshal(respJSON)
  21171. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21172. // utils.ErrorLog("解析失败:%v", err)
  21173. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21174. // adminUser := c.GetAdminUserInfo()
  21175. // errlog := &models.HisOrderError{
  21176. // UserOrgId: adminUser.CurrentOrgId,
  21177. // Ctime: time.Now().Unix(),
  21178. // Mtime: time.Now().Unix(),
  21179. // ErrMsg: res.ErrMsg + "解析失败",
  21180. // Status: 1,
  21181. // PatientId: order_id,
  21182. // Stage: 10088,
  21183. // }
  21184. // service.CreateErrMsgLog(errlog)
  21185. // continue
  21186. // }
  21187. //
  21188. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21189. // data := make(map[string]interface{})
  21190. // data["struct4101"] = struct4101
  21191. // data["secret_key"] = miConfig.SecretKey
  21192. // data["org_name"] = miConfig.OrgName
  21193. // data["opera"] = curRoles.UserName
  21194. // data["code"] = miConfig.Code
  21195. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21196. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21197. //
  21198. // client := &http.Client{}
  21199. // bytesData, _ := json.Marshal(data)
  21200. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21201. // resp, _ := client.Do(req)
  21202. // defer resp.Body.Close()
  21203. // body, ioErr := ioutil.ReadAll(resp.Body)
  21204. // if ioErr != nil {
  21205. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21207. // return
  21208. // }
  21209. // var respJSON map[string]interface{}
  21210. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21211. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21213. // return
  21214. // }
  21215. //
  21216. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21217. // userJSONBytes, _ := json.Marshal(respJSON)
  21218. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21219. // utils.ErrorLog("解析失败:%v", err)
  21220. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21221. // adminUser := c.GetAdminUserInfo()
  21222. // errlog := &models.HisOrderError{
  21223. // UserOrgId: adminUser.CurrentOrgId,
  21224. // Ctime: time.Now().Unix(),
  21225. // Mtime: time.Now().Unix(),
  21226. // ErrMsg: res.ErrMsg + "解析失败",
  21227. // Status: 1,
  21228. // PatientId: order_id,
  21229. // Stage: 10088,
  21230. // }
  21231. // service.CreateErrMsgLog(errlog)
  21232. // continue
  21233. // }
  21234. //
  21235. // } else {
  21236. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21237. // fmt.Println(result)
  21238. //
  21239. // var dat map[string]interface{}
  21240. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21241. // fmt.Println(dat)
  21242. // } else {
  21243. // fmt.Println(err)
  21244. // }
  21245. // userJSONBytes, _ := json.Marshal(dat)
  21246. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21247. // utils.ErrorLog("解析失败:%v", err)
  21248. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21249. // adminUser := c.GetAdminUserInfo()
  21250. // errlog := &models.HisOrderError{
  21251. // UserOrgId: adminUser.CurrentOrgId,
  21252. // Ctime: time.Now().Unix(),
  21253. // Mtime: time.Now().Unix(),
  21254. // ErrMsg: res.ErrMsg + "解析失败",
  21255. // Status: 1,
  21256. // PatientId: order_id,
  21257. // Stage: 10106,
  21258. // }
  21259. // service.CreateErrMsgLog(errlog)
  21260. // continue
  21261. // }
  21262. // }
  21263. //
  21264. // if res.Infcode != 0 {
  21265. // adminUser := c.GetAdminUserInfo()
  21266. // errlog := &models.HisOrderError{
  21267. // UserOrgId: adminUser.CurrentOrgId,
  21268. // Ctime: time.Now().Unix(),
  21269. // Mtime: time.Now().Unix(),
  21270. // ErrMsg: res.ErrMsg,
  21271. // Status: 1,
  21272. // PatientId: order_id,
  21273. // Stage: 10106,
  21274. // }
  21275. // service.CreateErrMsgLog(errlog)
  21276. // continue
  21277. // } else {
  21278. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21279. // Number: res.Output.SetlListId,
  21280. // Status: 1,
  21281. // Ctime: time.Now().Unix(),
  21282. // Mtime: time.Now().Unix(),
  21283. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21284. // IsUpload: 1,
  21285. // OrderId: order_id,
  21286. // }
  21287. // service.CreateUploadRecord(hisFundSettleListResult)
  21288. // continue
  21289. // }
  21290. // }
  21291. //}
  21292. func (c *HisApiController) GetOrgInfo() {
  21293. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21294. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21295. }
  21296. func (c *HisApiController) GetHisPatientInfo() {
  21297. medical_insurance_card := c.GetString("medical_insurance_card")
  21298. id_card_type, _ := c.GetInt64("id_card_type")
  21299. id_card := c.GetString("id_card")
  21300. adminInfo := c.GetAdminUserInfo()
  21301. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21302. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21303. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21304. IdCardNo := ""
  21305. if id_card_type == 1 {
  21306. IdCardNo = medical_insurance_card
  21307. } else if id_card_type == 2 {
  21308. IdCardNo = id_card
  21309. }
  21310. if config.IsOpen == 1 {
  21311. 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
  21312. resp, requestErr := http.Get(api)
  21313. if requestErr != nil {
  21314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21315. return
  21316. }
  21317. defer resp.Body.Close()
  21318. body, ioErr := ioutil.ReadAll(resp.Body)
  21319. if ioErr != nil {
  21320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21322. return
  21323. }
  21324. var respJSON map[string]interface{}
  21325. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21328. return
  21329. }
  21330. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21331. userJSONBytes, _ := json.Marshal(userJSON)
  21332. var res ResultTwo
  21333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21334. utils.ErrorLog("解析失败:%v", err)
  21335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21336. return
  21337. }
  21338. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21339. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21340. infoStr := string(Iinfos)
  21341. idetinfoStr := string(Idetinfos)
  21342. if res.Infcode == 0 {
  21343. his := models.VMHisPatient{
  21344. Status: 1,
  21345. Ctime: time.Now().Unix(),
  21346. Mtime: time.Now().Unix(),
  21347. PsnNo: res.Output.Baseinfo.PsnNo,
  21348. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21349. Certno: res.Output.Baseinfo.Certno,
  21350. PsnName: res.Output.Baseinfo.PsnName,
  21351. Gend: res.Output.Baseinfo.Gend,
  21352. Naty: res.Output.Baseinfo.Naty,
  21353. Iinfo: infoStr,
  21354. Idetinfo: idetinfoStr,
  21355. UserOrgId: adminInfo.CurrentOrgId,
  21356. IsReturn: 1,
  21357. IdCardType: id_card_type,
  21358. }
  21359. c.ServeSuccessJSON(map[string]interface{}{
  21360. "info": his,
  21361. })
  21362. } else {
  21363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21364. return
  21365. }
  21366. }
  21367. }
  21368. //func GetBasBaseInfo() (jsonStr string, err error) {
  21369. //
  21370. // handle := syscall.NewLazyDLL("SSCard.dll")
  21371. // add := handle.NewProc("ReadCardBas")
  21372. // str := make([]byte, 1024)
  21373. // str1 := make([]byte, 1024)
  21374. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21375. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21376. //
  21377. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21378. //
  21379. // fmt.Println("> Add(4,5)的结果为:", ret)
  21380. // handle.Release()
  21381. //
  21382. // return "", nil
  21383. //
  21384. //}
  21385. //func GetQRBaseInfo() (jsonStr string, err error) {
  21386. // handle := syscall.LoadDLL("SSCard.dll")
  21387. // ReadCardBas := handle.FindProc("GetQRBase")
  21388. //
  21389. // str := make([]byte, 256)
  21390. // str1 := make([]byte, 256)
  21391. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21392. //
  21393. // fmt.Println(string(str))
  21394. // fmt.Println(r)
  21395. // return string(str), nil
  21396. //}
  21397. //func CardInit() int {
  21398. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21399. // add := DllTestDef.MustFindProc("Init")
  21400. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21401. // if err != nil {
  21402. // fmt.Println("SSCard的运算结果为:", ret)
  21403. // }
  21404. // result := int(ret)
  21405. // return result
  21406. //}
  21407. //func CardInit() int {
  21408. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21409. // if err != nil {
  21410. // fmt.Println("SSCard的运算结果为:", ret)
  21411. // }
  21412. // fmt.Println(err)
  21413. // result := int(ret)
  21414. // return result
  21415. //}
  21416. func IntPtr(n int) uintptr {
  21417. return uintptr(n)
  21418. }
  21419. func StrPtr(s string) uintptr {
  21420. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21421. }
  21422. type Result2001 struct {
  21423. Cainfo interface{} `json:"cainfo"`
  21424. ErrMsg string `json:"err_msg"`
  21425. InfRefmsgid string `json:"inf_refmsgid"`
  21426. Infcode int64 `json:"infcode"`
  21427. Output struct {
  21428. Trtinfo struct {
  21429. PsnNo string `json:"psn_no"`
  21430. TrtChkType string `json:"trt_chk_type"`
  21431. FundPayType string `json:"fund_pay_type"`
  21432. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21433. Begndate string `json:"begndate"`
  21434. Enddate string `json:"enddate"`
  21435. TrtChkRslt string `json:"trt_chk_rslt"`
  21436. } `json:"trtinfo"`
  21437. } `json:"output"`
  21438. RefmsgTime string `json:"refmsg_time"`
  21439. RespondTime string `json:"respond_time"`
  21440. Signtype interface{} `json:"signtype"`
  21441. WarnMsg interface{} `json:"warn_msg"`
  21442. }
  21443. type Result2001Org10265 struct {
  21444. Cainfo interface{} `json:"cainfo"`
  21445. ErrMsg string `json:"err_msg"`
  21446. InfRefmsgid string `json:"inf_refmsgid"`
  21447. Infcode string `json:"infcode"`
  21448. Output struct {
  21449. Trtinfo struct {
  21450. PsnNo string `json:"psn_no"`
  21451. TrtChkType string `json:"trt_chk_type"`
  21452. FundPayType string `json:"fund_pay_type"`
  21453. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21454. Begndate string `json:"begndate"`
  21455. Enddate string `json:"enddate"`
  21456. TrtChkRslt string `json:"trt_chk_rslt"`
  21457. } `json:"trtinfo"`
  21458. } `json:"output"`
  21459. RefmsgTime string `json:"refmsg_time"`
  21460. RespondTime string `json:"respond_time"`
  21461. Signtype interface{} `json:"signtype"`
  21462. WarnMsg interface{} `json:"warn_msg"`
  21463. }
  21464. type ResultTwo struct {
  21465. ErrMsg string `json:"err_msg"`
  21466. InfRefmsgid string `json:"inf_refmsgid"`
  21467. Infcode int64 `json:"infcode"`
  21468. Output struct {
  21469. Baseinfo struct {
  21470. //Brdy string `json:"brdy"`
  21471. Certno string `json:"certno"`
  21472. Gend string `json:"gend"`
  21473. Naty string `json:"naty"`
  21474. PsnCertType string `json:"psn_cert_type"`
  21475. PsnName string `json:"psn_name"`
  21476. PsnNo string `json:"psn_no"`
  21477. } `json:"baseinfo"`
  21478. Idetinfo []interface{} `json:"idetinfo"`
  21479. Iinfo []struct {
  21480. Balc float64 `json:"balc"`
  21481. CvlservFlag string `json:"cvlserv_flag"`
  21482. EmpName string `json:"emp_name"`
  21483. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21484. Insutype string `json:"insutype"`
  21485. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21486. //PausInsuDate string `json:"paus_insu_date"`
  21487. //PsnInsuDate string `json:"psn_insu_date"`
  21488. PsnInsuStas string `json:"psn_insu_stas"`
  21489. PsnType string `json:"psn_type"`
  21490. } `json:"insuinfo"`
  21491. } `json:"output"`
  21492. RefmsgTime string `json:"refmsg_time"`
  21493. RespondTime string `json:"respond_time"`
  21494. Signtype interface{} `json:"signtype"`
  21495. WarnInfo interface{} `json:"warn_info"`
  21496. }
  21497. type ResultTwo10265 struct {
  21498. ErrMsg string `json:"err_msg"`
  21499. InfRefmsgid string `json:"inf_refmsgid"`
  21500. Infcode string `json:"infcode"`
  21501. Output struct {
  21502. Baseinfo struct {
  21503. //Brdy string `json:"brdy"`
  21504. Certno string `json:"certno"`
  21505. Gend string `json:"gend"`
  21506. Naty string `json:"naty"`
  21507. PsnCertType string `json:"psn_cert_type"`
  21508. PsnName string `json:"psn_name"`
  21509. PsnNo string `json:"psn_no"`
  21510. } `json:"baseinfo"`
  21511. Idetinfo []interface{} `json:"idetinfo"`
  21512. Iinfo []struct {
  21513. Balc float64 `json:"balc"`
  21514. CvlservFlag string `json:"cvlserv_flag"`
  21515. EmpName string `json:"emp_name"`
  21516. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21517. Insutype string `json:"insutype"`
  21518. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21519. PsnInsuStas string `json:"psn_insu_stas"`
  21520. PsnType string `json:"psn_type"`
  21521. } `json:"insuinfo"`
  21522. } `json:"output"`
  21523. RefmsgTime string `json:"refmsg_time"`
  21524. RespondTime string `json:"respond_time"`
  21525. Signtype interface{} `json:"signtype"`
  21526. WarnInfo interface{} `json:"warn_info"`
  21527. }
  21528. type ResultThree struct {
  21529. Cainfo interface{} `json:"cainfo"`
  21530. ErrMsg string `json:"err_msg"`
  21531. InfRefmsgid string `json:"inf_refmsgid"`
  21532. Infcode int64 `json:"infcode"`
  21533. Output struct {
  21534. Data struct {
  21535. IptOtpNo string `json:"ipt_otp_no"`
  21536. MdtrtID string `json:"mdtrt_id"`
  21537. PsnNo string `json:"psn_no"`
  21538. } `json:"data"`
  21539. } `json:"output"`
  21540. RefmsgTime string `json:"refmsg_time"`
  21541. RespondTime string `json:"respond_time"`
  21542. Signtype interface{} `json:"signtype"`
  21543. WarnMsg interface{} `json:"warn_msg"`
  21544. }
  21545. type ResultThree10265 struct {
  21546. Cainfo interface{} `json:"cainfo"`
  21547. ErrMsg string `json:"err_msg"`
  21548. InfRefmsgid string `json:"inf_refmsgid"`
  21549. Infcode string `json:"infcode"`
  21550. Output struct {
  21551. Data struct {
  21552. IptOtpNo string `json:"ipt_otp_no"`
  21553. MdtrtID string `json:"mdtrt_id"`
  21554. PsnNo string `json:"psn_no"`
  21555. } `json:"data"`
  21556. } `json:"output"`
  21557. RefmsgTime string `json:"refmsg_time"`
  21558. RespondTime string `json:"respond_time"`
  21559. Signtype interface{} `json:"signtype"`
  21560. WarnMsg interface{} `json:"warn_msg"`
  21561. }
  21562. type ResultFour struct {
  21563. Cainfo string `json:"cainfo"`
  21564. ErrMsg string `json:"err_msg"`
  21565. InfRefmsgid string `json:"inf_refmsgid"`
  21566. Infcode int64 `json:"infcode"`
  21567. Output struct {
  21568. Result []struct {
  21569. BasMednFlag string `json:"bas_medn_flag"`
  21570. ChldMedcFlag string `json:"chld_medc_flag"`
  21571. ChrgitmLv string `json:"chrgitm_lv"`
  21572. Cnt float64 `json:"cnt"`
  21573. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21574. DrtReimFlag string `json:"drt_reim_flag"`
  21575. FeedetlSn string `json:"feedetl_sn"`
  21576. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21577. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21578. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21579. ListSpItemFlag string `json:"list_sp_item_flag"`
  21580. LmtUsedFlag string `json:"lmt_used_flag"`
  21581. MedChrgitmType string `json:"med_chrgitm_type"`
  21582. Memo string `json:"memo"`
  21583. OverlmtAmt float64 `json:"overlmt_amt"`
  21584. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21585. Pric float64 `json:"pric"`
  21586. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21587. SelfpayProp float64 `json:"selfpay_prop"`
  21588. } `json:"result"`
  21589. } `json:"output"`
  21590. RefmsgTime string `json:"refmsg_time"`
  21591. RespondTime string `json:"respond_time"`
  21592. Signtype string `json:"signtype"`
  21593. WarnMsg string `json:"warn_msg"`
  21594. }
  21595. type ResultFour10265 struct {
  21596. Cainfo string `json:"cainfo"`
  21597. ErrMsg string `json:"err_msg"`
  21598. InfRefmsgid string `json:"inf_refmsgid"`
  21599. Infcode string `json:"infcode"`
  21600. Output struct {
  21601. Result []struct {
  21602. BasMednFlag string `json:"bas_medn_flag"`
  21603. ChldMedcFlag string `json:"chld_medc_flag"`
  21604. ChrgitmLv string `json:"chrgitm_lv"`
  21605. Cnt float64 `json:"cnt"`
  21606. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21607. DrtReimFlag string `json:"drt_reim_flag"`
  21608. FeedetlSn string `json:"feedetl_sn"`
  21609. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21610. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21611. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21612. ListSpItemFlag string `json:"list_sp_item_flag"`
  21613. LmtUsedFlag string `json:"lmt_used_flag"`
  21614. MedChrgitmType string `json:"med_chrgitm_type"`
  21615. Memo string `json:"memo"`
  21616. OverlmtAmt float64 `json:"overlmt_amt"`
  21617. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21618. Pric float64 `json:"pric"`
  21619. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21620. SelfpayProp float64 `json:"selfpay_prop"`
  21621. } `json:"result"`
  21622. } `json:"output"`
  21623. RefmsgTime string `json:"refmsg_time"`
  21624. RespondTime string `json:"respond_time"`
  21625. Signtype string `json:"signtype"`
  21626. WarnMsg string `json:"warn_msg"`
  21627. }
  21628. type ResultMemo struct {
  21629. InsuAdmdvs string `json:"insuAdmdvs"`
  21630. }
  21631. // [{"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}]
  21632. type ResultIDInfo struct {
  21633. Begntime string `json:"begntime"`
  21634. Endtime string `json:"endtime"`
  21635. Memo string `json:"memo"`
  21636. }
  21637. type ResultFive struct {
  21638. Balc float64 `json:"balc"`
  21639. CvlservFlag string `json:"cvlserv_flag"`
  21640. EmpName string `json:"emp_name"`
  21641. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21642. Insutype string `json:"insutype"`
  21643. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21644. PausInsuDate string `json:"paus_insu_date"`
  21645. PsnInsuDate string `json:"psn_insu_date"`
  21646. PsnInsuStas string `json:"psn_insu_stas"`
  21647. PsnType string `json:"psn_type"`
  21648. }
  21649. type ResultSix struct {
  21650. Cainfo interface{} `json:"cainfo"`
  21651. ErrMsg string `json:"err_msg"`
  21652. InfRefmsgid string `json:"inf_refmsgid"`
  21653. Infcode int64 `json:"infcode"`
  21654. Output struct {
  21655. } `json:"output"`
  21656. RefmsgTime string `json:"refmsg_time"`
  21657. RespondTime string `json:"respond_time"`
  21658. Signtype interface{} `json:"signtype"`
  21659. WarnMsg interface{} `json:"warn_msg"`
  21660. }
  21661. type FJ3507Result struct {
  21662. Cainfo interface{} `json:"cainfo"`
  21663. ErrMsg string `json:"err_msg"`
  21664. InfRefmsgid string `json:"inf_refmsgid"`
  21665. Infcode int64 `json:"infcode"`
  21666. Output struct {
  21667. retRslt string `json:"retRslt"`
  21668. msgRslt string `json:"msgRslt"`
  21669. } `json:"output"`
  21670. RefmsgTime string `json:"refmsg_time"`
  21671. RespondTime string `json:"respond_time"`
  21672. Signtype interface{} `json:"signtype"`
  21673. WarnMsg interface{} `json:"warn_msg"`
  21674. }
  21675. type FJ3507ResultFor10188 struct {
  21676. Cainfo interface{} `json:"cainfo"`
  21677. ErrMsg string `json:"err_msg"`
  21678. InfRefmsgid string `json:"inf_refmsgid"`
  21679. Infcode string `json:"infcode"`
  21680. RefmsgTime string `json:"refmsg_time"`
  21681. RespondTime string `json:"respond_time"`
  21682. Signtype interface{} `json:"signtype"`
  21683. WarnMsg interface{} `json:"warn_msg"`
  21684. }
  21685. type Result2406 struct {
  21686. Cainfo interface{} `json:"cainfo"`
  21687. ErrMsg string `json:"err_msg"`
  21688. InfRefmsgid string `json:"inf_refmsgid"`
  21689. Infcode int64 `json:"infcode"`
  21690. Output struct {
  21691. Result struct {
  21692. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21693. } `json:"result"`
  21694. } `json:"output"`
  21695. RefmsgTime string `json:"refmsg_time"`
  21696. RespondTime string `json:"respond_time"`
  21697. Signtype interface{} `json:"signtype"`
  21698. WarnMsg interface{} `json:"warn_msg"`
  21699. }
  21700. type GZResultSix struct {
  21701. Cainfo interface{} `json:"cainfo"`
  21702. ErrMsg string `json:"err_msg"`
  21703. InfRefmsgid string `json:"inf_refmsgid"`
  21704. Infcode int64 `json:"infcode"`
  21705. Output string `json:"output"`
  21706. RefmsgTime string `json:"refmsg_time"`
  21707. RespondTime string `json:"respond_time"`
  21708. Signtype interface{} `json:"signtype"`
  21709. WarnMsg interface{} `json:"warn_msg"`
  21710. }
  21711. type ResultSix10265 struct {
  21712. Cainfo interface{} `json:"cainfo"`
  21713. ErrMsg string `json:"err_msg"`
  21714. InfRefmsgid string `json:"inf_refmsgid"`
  21715. Infcode string `json:"infcode"`
  21716. Output struct {
  21717. } `json:"output"`
  21718. RefmsgTime string `json:"refmsg_time"`
  21719. RespondTime string `json:"respond_time"`
  21720. Signtype interface{} `json:"signtype"`
  21721. WarnMsg interface{} `json:"warn_msg"`
  21722. }
  21723. type ResultSeven struct {
  21724. Cainfo string `json:"cainfo"`
  21725. ErrMsg string `json:"err_msg"`
  21726. InfRefmsgid string `json:"inf_refmsgid"`
  21727. Infcode int64 `json:"infcode"`
  21728. Output struct {
  21729. Setlinfo struct {
  21730. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21731. AcctPay float64 `json:"acct_pay"`
  21732. ActPayDedc float64 `json:"act_pay_dedc"`
  21733. Age float64 `json:"age"`
  21734. Balc float64 `json:"balc"`
  21735. Certno string `json:"certno"`
  21736. ClrOptins string `json:"clr_optins"`
  21737. ClrType string `json:"clr_type"`
  21738. ClrWay string `json:"clr_way"`
  21739. CvlservFlag string `json:"cvlserv_flag"`
  21740. CvlservPay float64 `json:"cvlserv_pay"`
  21741. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21742. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21743. Gend string `json:"gend"`
  21744. HifesPay float64 `json:"hifes_pay"`
  21745. HifmiPay float64 `json:"hifmi_pay"`
  21746. HifpPay float64 `json:"hifp_pay"`
  21747. HospPartAmt float64 `json:"hosp_part_amt"`
  21748. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21749. Insutype string `json:"insutype"`
  21750. MafPay float64 `json:"maf_pay"`
  21751. MdtrtCertType string `json:"mdtrt_cert_type"`
  21752. HifobPay float64 `json:"hifob_pay"`
  21753. MdtrtID string `json:"mdtrt_id"`
  21754. MedType string `json:"med_type"`
  21755. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21756. MedinsSetlID string `json:"medins_setl_id"`
  21757. Naty string `json:"naty"`
  21758. OthPay float64 `json:"oth_pay"`
  21759. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21760. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21761. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21762. PsnCashPay float64 `json:"psn_cash_pay"`
  21763. PsnCertType string `json:"psn_cert_type"`
  21764. PsnName string `json:"psn_name"`
  21765. PsnNo string `json:"psn_no"`
  21766. PsnPartAmt float64 `json:"psn_part_amt"`
  21767. PsnType string `json:"psn_type"`
  21768. SetlID string `json:"setl_id"`
  21769. SetlTime string `json:"setl_time"`
  21770. } `json:"setlinfo"`
  21771. Setldetail interface{} `json:"setldetail"`
  21772. } `json:"output"`
  21773. RefmsgTime string `json:"refmsg_time"`
  21774. RespondTime string `json:"respond_time"`
  21775. Signtype interface{} `json:"signtype"`
  21776. WarnMsg interface{} `json:"warn_msg"`
  21777. }
  21778. type ResultSevenAH struct {
  21779. Cainfo string `json:"cainfo"`
  21780. ErrMsg string `json:"err_msg"`
  21781. InfRefmsgid string `json:"inf_refmsgid"`
  21782. Infcode int64 `json:"infcode"`
  21783. Output struct {
  21784. Setlinfo struct {
  21785. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21786. AcctPay float64 `json:"acct_pay"`
  21787. ActPayDedc float64 `json:"act_pay_dedc"`
  21788. Age float64 `json:"age"`
  21789. Balc float64 `json:"balc"`
  21790. Certno string `json:"certno"`
  21791. ClrOptins string `json:"clr_optins"`
  21792. ClrType string `json:"clr_type"`
  21793. ClrWay string `json:"clr_way"`
  21794. CvlservFlag string `json:"cvlserv_flag"`
  21795. CvlservPay float64 `json:"cvlserv_pay"`
  21796. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21797. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21798. Gend string `json:"gend"`
  21799. HifesPay float64 `json:"hifes_pay"`
  21800. HifmiPay float64 `json:"hifmi_pay"`
  21801. HifpPay float64 `json:"hifp_pay"`
  21802. HospPartAmt float64 `json:"hosp_part_amt"`
  21803. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21804. Insutype string `json:"insutype"`
  21805. MafPay float64 `json:"maf_pay"`
  21806. MdtrtCertType string `json:"mdtrt_cert_type"`
  21807. HifobPay float64 `json:"hifob_pay"`
  21808. MdtrtID string `json:"mdtrt_id"`
  21809. MedType string `json:"med_type"`
  21810. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21811. MedinsSetlID string `json:"medins_setl_id"`
  21812. Naty string `json:"naty"`
  21813. OthPay float64 `json:"oth_pay"`
  21814. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21815. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21816. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21817. PsnCashPay float64 `json:"psn_cash_pay"`
  21818. PsnCertType string `json:"psn_cert_type"`
  21819. PsnName string `json:"psn_name"`
  21820. PsnNo string `json:"psn_no"`
  21821. PsnPartAmt float64 `json:"psn_part_amt"`
  21822. PsnType string `json:"psn_type"`
  21823. SetlID string `json:"setl_id"`
  21824. SetlTime int64 `json:"setl_time"`
  21825. } `json:"setlinfo"`
  21826. Setldetail interface{} `json:"setldetail"`
  21827. } `json:"output"`
  21828. RefmsgTime string `json:"refmsg_time"`
  21829. RespondTime string `json:"respond_time"`
  21830. Signtype interface{} `json:"signtype"`
  21831. WarnMsg interface{} `json:"warn_msg"`
  21832. }
  21833. type ResultSeven10265 struct {
  21834. Cainfo string `json:"cainfo"`
  21835. ErrMsg string `json:"err_msg"`
  21836. InfRefmsgid string `json:"inf_refmsgid"`
  21837. Infcode string `json:"infcode"`
  21838. Output struct {
  21839. Setlinfo struct {
  21840. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21841. AcctPay float64 `json:"acct_pay"`
  21842. ActPayDedc float64 `json:"act_pay_dedc"`
  21843. Age float64 `json:"age"`
  21844. Balc float64 `json:"balc"`
  21845. Certno string `json:"certno"`
  21846. ClrOptins string `json:"clr_optins"`
  21847. ClrType string `json:"clr_type"`
  21848. ClrWay string `json:"clr_way"`
  21849. CvlservFlag string `json:"cvlserv_flag"`
  21850. CvlservPay float64 `json:"cvlserv_pay"`
  21851. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21852. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21853. Gend string `json:"gend"`
  21854. HifesPay float64 `json:"hifes_pay"`
  21855. HifmiPay float64 `json:"hifmi_pay"`
  21856. HifpPay float64 `json:"hifp_pay"`
  21857. HospPartAmt float64 `json:"hosp_part_amt"`
  21858. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21859. Insutype string `json:"insutype"`
  21860. MafPay float64 `json:"maf_pay"`
  21861. MdtrtCertType string `json:"mdtrt_cert_type"`
  21862. HifobPay float64 `json:"hifob_pay"`
  21863. MdtrtID string `json:"mdtrt_id"`
  21864. MedType string `json:"med_type"`
  21865. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21866. MedinsSetlID string `json:"medins_setl_id"`
  21867. Naty string `json:"naty"`
  21868. OthPay float64 `json:"oth_pay"`
  21869. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21870. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21871. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21872. PsnCashPay float64 `json:"psn_cash_pay"`
  21873. PsnCertType string `json:"psn_cert_type"`
  21874. PsnName string `json:"psn_name"`
  21875. PsnNo string `json:"psn_no"`
  21876. PsnPartAmt float64 `json:"psn_part_amt"`
  21877. PsnType string `json:"psn_type"`
  21878. SetlID string `json:"setl_id"`
  21879. SetlTime string `json:"setl_time"`
  21880. } `json:"setlinfo"`
  21881. Setldetail interface{} `json:"setldetail"`
  21882. } `json:"output"`
  21883. RefmsgTime string `json:"refmsg_time"`
  21884. RespondTime string `json:"respond_time"`
  21885. Signtype interface{} `json:"signtype"`
  21886. WarnMsg interface{} `json:"warn_msg"`
  21887. }
  21888. type ResultSeven10265Two struct {
  21889. Cainfo string `json:"cainfo"`
  21890. ErrMsg string `json:"err_msg"`
  21891. InfRefmsgid string `json:"inf_refmsgid"`
  21892. Infcode string `json:"infcode"`
  21893. Output struct {
  21894. Setlinfo struct {
  21895. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21896. AcctPay float64 `json:"acct_pay"`
  21897. ActPayDedc float64 `json:"act_pay_dedc"`
  21898. Age float64 `json:"age"`
  21899. Balc float64 `json:"balc"`
  21900. Certno string `json:"certno"`
  21901. ClrOptins string `json:"clr_optins"`
  21902. ClrType string `json:"clr_type"`
  21903. ClrWay string `json:"clr_way"`
  21904. CvlservFlag string `json:"cvlserv_flag"`
  21905. CvlservPay float64 `json:"cvlserv_pay"`
  21906. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21907. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21908. Gend string `json:"gend"`
  21909. HifesPay float64 `json:"hifes_pay"`
  21910. HifmiPay float64 `json:"hifmi_pay"`
  21911. HifpPay float64 `json:"hifp_pay"`
  21912. HospPartAmt string `json:"hosp_part_amt"`
  21913. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21914. Insutype string `json:"insutype"`
  21915. MafPay float64 `json:"maf_pay"`
  21916. MdtrtCertType string `json:"mdtrt_cert_type"`
  21917. HifobPay float64 `json:"hifob_pay"`
  21918. MdtrtID string `json:"mdtrt_id"`
  21919. MedType string `json:"med_type"`
  21920. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21921. MedinsSetlID string `json:"medins_setl_id"`
  21922. Naty string `json:"naty"`
  21923. OthPay float64 `json:"oth_pay"`
  21924. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21925. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21926. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21927. PsnCashPay float64 `json:"psn_cash_pay"`
  21928. PsnCertType string `json:"psn_cert_type"`
  21929. PsnName string `json:"psn_name"`
  21930. PsnNo string `json:"psn_no"`
  21931. PsnPartAmt float64 `json:"psn_part_amt"`
  21932. PsnType string `json:"psn_type"`
  21933. SetlID string `json:"setl_id"`
  21934. SetlTime string `json:"setl_time"`
  21935. } `json:"setlinfo"`
  21936. Setldetail interface{} `json:"setldetail"`
  21937. } `json:"output"`
  21938. RefmsgTime string `json:"refmsg_time"`
  21939. RespondTime string `json:"respond_time"`
  21940. Signtype interface{} `json:"signtype"`
  21941. WarnMsg interface{} `json:"warn_msg"`
  21942. }
  21943. type GZResultSeven10265Two struct {
  21944. Cainfo string `json:"cainfo"`
  21945. ErrMsg string `json:"err_msg"`
  21946. InfRefmsgid string `json:"inf_refmsgid"`
  21947. Infcode int64 `json:"infcode"`
  21948. Output struct {
  21949. Setlinfo struct {
  21950. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21951. AcctPay float64 `json:"acct_pay"`
  21952. ActPayDedc float64 `json:"act_pay_dedc"`
  21953. Age float64 `json:"age"`
  21954. Balc float64 `json:"balc"`
  21955. Certno string `json:"certno"`
  21956. ClrOptins string `json:"clr_optins"`
  21957. ClrType string `json:"clr_type"`
  21958. ClrWay string `json:"clr_way"`
  21959. CvlservFlag string `json:"cvlserv_flag"`
  21960. CvlservPay float64 `json:"cvlserv_pay"`
  21961. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21962. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21963. Gend string `json:"gend"`
  21964. HifesPay float64 `json:"hifes_pay"`
  21965. HifmiPay float64 `json:"hifmi_pay"`
  21966. HifpPay float64 `json:"hifp_pay"`
  21967. HospPartAmt float64 `json:"hosp_part_amt"`
  21968. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21969. Insutype string `json:"insutype"`
  21970. MafPay float64 `json:"maf_pay"`
  21971. MdtrtCertType string `json:"mdtrt_cert_type"`
  21972. HifobPay float64 `json:"hifob_pay"`
  21973. MdtrtID string `json:"mdtrt_id"`
  21974. MedType string `json:"med_type"`
  21975. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21976. MedinsSetlID string `json:"medins_setl_id"`
  21977. Naty string `json:"naty"`
  21978. OthPay float64 `json:"oth_pay"`
  21979. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21980. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21981. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21982. PsnCashPay float64 `json:"psn_cash_pay"`
  21983. PsnCertType string `json:"psn_cert_type"`
  21984. PsnName string `json:"psn_name"`
  21985. PsnNo string `json:"psn_no"`
  21986. PsnPartAmt float64 `json:"psn_part_amt"`
  21987. PsnType string `json:"psn_type"`
  21988. SetlID string `json:"setl_id"`
  21989. SetlTime string `json:"setl_time"`
  21990. } `json:"setlinfo"`
  21991. Setldetail interface{} `json:"setldetail"`
  21992. } `json:"output"`
  21993. RefmsgTime string `json:"refmsg_time"`
  21994. RespondTime string `json:"respond_time"`
  21995. Signtype interface{} `json:"signtype"`
  21996. WarnMsg interface{} `json:"warn_msg"`
  21997. }
  21998. type ResultEight struct {
  21999. Cainfo string `json:"cainfo"`
  22000. ErrMsg string `json:"err_msg"`
  22001. InfRefmsgid string `json:"inf_refmsgid"`
  22002. Infcode int64 `json:"infcode"`
  22003. Output struct {
  22004. Stmtinfo struct {
  22005. SetlOptins string `json:"setl_optins"`
  22006. StmtRslt string `json:"stmt_rslt"`
  22007. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22008. } `json:"stmtinfo"`
  22009. } `json:"output"`
  22010. RefmsgTime string `json:"refmsg_time"`
  22011. RespondTime string `json:"respond_time"`
  22012. Signtype interface{} `json:"signtype"`
  22013. WarnMsg interface{} `json:"warn_msg"`
  22014. }
  22015. type ResultEightFor10188 struct {
  22016. Cainfo string `json:"cainfo"`
  22017. ErrMsg string `json:"err_msg"`
  22018. InfRefmsgid string `json:"inf_refmsgid"`
  22019. Infcode string `json:"infcode"`
  22020. Output struct {
  22021. Stmtinfo struct {
  22022. SetlOptins string `json:"setl_optins"`
  22023. StmtRslt string `json:"stmt_rslt"`
  22024. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22025. } `json:"stmtinfo"`
  22026. } `json:"output"`
  22027. RefmsgTime string `json:"refmsg_time"`
  22028. RespondTime string `json:"respond_time"`
  22029. Signtype interface{} `json:"signtype"`
  22030. WarnMsg interface{} `json:"warn_msg"`
  22031. }
  22032. type ResultNine struct {
  22033. Cainfo string `json:"cainfo"`
  22034. ErrMsg string `json:"err_msg"`
  22035. InfRefmsgid string `json:"inf_refmsgid"`
  22036. Infcode int64 `json:"infcode"`
  22037. Output struct {
  22038. FileQuryNo string `json:"file_qury_no"`
  22039. } `json:"output"`
  22040. RefmsgTime string `json:"refmsg_time"`
  22041. RespondTime string `json:"respond_time"`
  22042. Signtype interface{} `json:"signtype"`
  22043. WarnMsg interface{} `json:"warn_msg"`
  22044. }
  22045. type ResultTen struct {
  22046. Cainfo string `json:"cainfo"`
  22047. ErrMsg string `json:"err_msg"`
  22048. InfRefmsgid string `json:"inf_refmsgid"`
  22049. Infcode int64 `json:"infcode"`
  22050. Output struct {
  22051. Fileinfo struct {
  22052. DldEndtime string `json:"dld_endtime"`
  22053. FileQuryNo string `json:"file_qury_no"`
  22054. Filename string `json:"filename"`
  22055. } `json:"fileinfo"`
  22056. } `json:"output"`
  22057. RefmsgTime string `json:"refmsg_time"`
  22058. RespondTime string `json:"respond_time"`
  22059. Signtype interface{} `json:"signtype"`
  22060. WarnMsg interface{} `json:"warn_msg"`
  22061. }
  22062. type Result5262 struct {
  22063. ErrMsg string `json:"err_msg"`
  22064. InfRefmsgid string `json:"inf_refmsgid"`
  22065. Infcode int64 `json:"infcode"`
  22066. Output struct {
  22067. PageInfo struct {
  22068. Size int `json:"size"`
  22069. RecordCounts int `json:"record_counts"`
  22070. } `json:"page_info"`
  22071. Idetinfo []interface{} `json:"idetinfo"`
  22072. Result []struct {
  22073. SetlID string `json:"setl_id"`
  22074. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22075. MdtrtID string `json:"mdtrt_id"`
  22076. InitSetlID string `json:"init_setl_id,omitempty"`
  22077. PsnNo string `json:"psn_no"`
  22078. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22079. PsnName string `json:"psn_name"`
  22080. PsnCertType string `json:"psn_cert_type"`
  22081. Certno string `json:"certno"`
  22082. Gend string `json:"gend,omitempty"`
  22083. Naty string `json:"naty,omitempty"`
  22084. Brdy string `json:"brdy,omitempty"`
  22085. Age float64 `json:"age,omitempty"`
  22086. Insutype string `json:"insutype,omitempty"`
  22087. PsnType string `json:"psn_type"`
  22088. CvlservFlag string `json:"cvlserv_flag"`
  22089. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22090. SpPsnType string `json:"sp_psn_type,omitempty"`
  22091. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22092. ClctGrde string `json:"clct_grde,omitempty"`
  22093. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22094. NwbFlag string `json:"nwb_flag,omitempty"`
  22095. InsuAdmdvs string `json:"insu_admdvs"`
  22096. EmpNo string `json:"emp_no,omitempty"`
  22097. EmpName string `json:"emp_name,omitempty"`
  22098. EmpType string `json:"emp_type,omitempty"`
  22099. EconType string `json:"econ_type,omitempty"`
  22100. AfilIndu string `json:"afil_indu,omitempty"`
  22101. AfilRlts string `json:"afil_rlts,omitempty"`
  22102. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22103. PayLoc string `json:"pay_loc,omitempty"`
  22104. FixmedinsCode string `json:"fixmedins_code"`
  22105. FixmedinsName string `json:"fixmedins_name"`
  22106. HospLv string `json:"hosp_lv,omitempty"`
  22107. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22108. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22109. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22110. Begndate string `json:"begndate"`
  22111. Enddate string `json:"enddate"`
  22112. SetlTime string `json:"setl_time"`
  22113. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22114. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22115. MedType string `json:"med_type"`
  22116. SetlType string `json:"setl_type,omitempty"`
  22117. ClrType string `json:"clr_type,omitempty"`
  22118. ClrWay string `json:"clr_way,omitempty"`
  22119. PsnSetlway string `json:"psn_setlway,omitempty"`
  22120. ClrOptins string `json:"clr_optins,omitempty"`
  22121. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22122. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22123. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22124. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22125. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22126. DedcStd float64 `json:"dedc_std,omitempty"`
  22127. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22128. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22129. HifpPay float64 `json:"hifp_pay,omitempty"`
  22130. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22131. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22132. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22133. HifesPay float64 `json:"hifes_pay,omitempty"`
  22134. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22135. HifobPay float64 `json:"hifob_pay,omitempty"`
  22136. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22137. MafPay float64 `json:"maf_pay,omitempty"`
  22138. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22139. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22140. PsnPay float64 `json:"psn_pay,omitempty"`
  22141. AcctPay float64 `json:"acct_pay,omitempty"`
  22142. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22143. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22144. Balc float64 `json:"balc,omitempty"`
  22145. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22146. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22147. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22148. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22149. Year string `json:"year,omitempty"`
  22150. DiseNo string `json:"dise_no,omitempty"`
  22151. DiseName string `json:"dise_name,omitempty"`
  22152. Invono string `json:"invono,omitempty"`
  22153. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22154. ValiFlag string `json:"vali_flag,omitempty"`
  22155. Memo string `json:"memo,omitempty"`
  22156. Rid string `json:"rid"`
  22157. UpdtTime string `json:"updt_time,omitempty"`
  22158. CrterID string `json:"crter_id,omitempty"`
  22159. CrterName string `json:"crter_name,omitempty"`
  22160. CrteTime string `json:"crte_time,omitempty"`
  22161. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22162. OpterID string `json:"opter_id,omitempty"`
  22163. OpterName string `json:"opter_name,omitempty"`
  22164. OptTime string `json:"opt_time,omitempty"`
  22165. OptinsNo string `json:"optins_no,omitempty"`
  22166. PoolareaNo string `json:"poolarea_no,omitempty"`
  22167. } `json:"result"`
  22168. } `json:"output"`
  22169. RefmsgTime string `json:"refmsg_time"`
  22170. RespondTime string `json:"respond_time"`
  22171. Signtype interface{} `json:"signtype"`
  22172. WarnInfo interface{} `json:"warn_info"`
  22173. }
  22174. type Result5267 struct {
  22175. ErrMsg string `json:"err_msg"`
  22176. InfRefmsgid string `json:"inf_refmsgid"`
  22177. Infcode int64 `json:"infcode"`
  22178. Output struct {
  22179. PageInfo struct {
  22180. Size int `json:"size"`
  22181. RecordCounts int `json:"record_counts"`
  22182. } `json:"pageinfo"`
  22183. Result []struct {
  22184. SetlID string `json:"setl_id"`
  22185. ClrOptins string `json:"clr_optins"`
  22186. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22187. MdtrtID string `json:"mdtrt_id"`
  22188. InitSetlID string `json:"init_setl_id,omitempty"`
  22189. PsnNo string `json:"psn_no"`
  22190. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22191. PsnName string `json:"psn_name"`
  22192. PsnCertType string `json:"psn_cert_type"`
  22193. Certno string `json:"certno"`
  22194. Gend string `json:"gend,omitempty"`
  22195. Naty string `json:"naty,omitempty"`
  22196. Brdy string `json:"brdy,omitempty"`
  22197. Age float64 `json:"age,omitempty"`
  22198. Insutype string `json:"insutype,omitempty"`
  22199. PsnType string `json:"psn_type"`
  22200. CvlservFlag string `json:"cvlserv_flag"`
  22201. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22202. SpPsnType string `json:"sp_psn_type,omitempty"`
  22203. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22204. ClctGrde string `json:"clct_grde,omitempty"`
  22205. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22206. NwbFlag string `json:"nwb_flag,omitempty"`
  22207. InsuAdmdvs string `json:"insu_admdvs"`
  22208. EmpNo string `json:"emp_no,omitempty"`
  22209. EmpName string `json:"emp_name,omitempty"`
  22210. EmpType string `json:"emp_type,omitempty"`
  22211. EconType string `json:"econ_type,omitempty"`
  22212. AfilIndu string `json:"afil_indu,omitempty"`
  22213. AfilRlts string `json:"afil_rlts,omitempty"`
  22214. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22215. PayLoc string `json:"pay_loc,omitempty"`
  22216. FixmedinsCode string `json:"fixmedins_code"`
  22217. FixmedinsName string `json:"fixmedins_name"`
  22218. HospLv string `json:"hosp_lv,omitempty"`
  22219. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22220. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22221. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22222. Begndate string `json:"begndate,omitempty"`
  22223. Enddate string `json:"enddate,omitempty"`
  22224. SetlTime string `json:"setl_time,omitempty"`
  22225. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22226. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22227. MedType string `json:"med_type"`
  22228. SetlType string `json:"setl_type,omitempty"`
  22229. ClrType string `json:"clr_type,omitempty"`
  22230. ClrWay string `json:"clr_way,omitempty"`
  22231. PsnSetlway string `json:"psn_setlway,omitempty"`
  22232. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22233. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22234. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22235. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22236. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22237. DedcStd float64 `json:"dedc_std,omitempty"`
  22238. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22239. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22240. HifpPay float64 `json:"hifp_pay,omitempty"`
  22241. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22242. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22243. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22244. HifesPay float64 `json:"hifes_pay,omitempty"`
  22245. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22246. HifobPay float64 `json:"hifob_pay,omitempty"`
  22247. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22248. MafPay float64 `json:"maf_pay,omitempty"`
  22249. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22250. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22251. PsnPay float64 `json:"psn_pay,omitempty"`
  22252. AcctPay float64 `json:"acct_pay,omitempty"`
  22253. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22254. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22255. Balc float64 `json:"balc,omitempty"`
  22256. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22257. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22258. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22259. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22260. Year string `json:"year,omitempty"`
  22261. DiseNo string `json:"dise_no,omitempty"`
  22262. DiseName string `json:"dise_name,omitempty"`
  22263. Invono string `json:"invono,omitempty"`
  22264. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22265. Memo string `json:"memo,omitempty"`
  22266. UpdtTime string `json:"updt_time,omitempty"`
  22267. OpterID string `json:"opter_id,omitempty"`
  22268. OpterName string `json:"opter_name,omitempty"`
  22269. OptTime string `json:"opt_time,omitempty"`
  22270. OptinsNo string `json:"optins_no,omitempty"`
  22271. PoolareaNo string `json:"poolarea_no,omitempty"`
  22272. } `json:"result"`
  22273. } `json:"output"`
  22274. RefmsgTime string `json:"refmsg_time"`
  22275. RespondTime string `json:"respond_time"`
  22276. Signtype interface{} `json:"signtype"`
  22277. WarnInfo interface{} `json:"warn_info"`
  22278. }
  22279. // type Autogenerated struct {
  22280. // Output struct {
  22281. // Setlinfo struct {
  22282. // SetlTime string `json:"setl_time"`
  22283. // CvlservPay float64 `json:"cvlserv_pay"`
  22284. // Year string `json:"year"`
  22285. // MedType string `json:"med_type"`
  22286. // PsnPay float64 `json:"psn_pay"`
  22287. // OpterID string `json:"opter_id"`
  22288. // Begndate string `json:"begndate"`
  22289. // FlxempeFlag string `json:"flxempe_flag"`
  22290. // HifmiPay float64 `json:"hifmi_pay"`
  22291. // PsnNo string `json:"psn_no"`
  22292. // ActPayDedc float64 `json:"act_pay_dedc"`
  22293. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22294. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22295. // ClrWay string `json:"clr_way"`
  22296. // OthPay float64 `json:"oth_pay"`
  22297. // Gend string `json:"gend"`
  22298. // MdtrtID string `json:"mdtrt_id"`
  22299. // AcctPay float64 `json:"acct_pay"`
  22300. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22301. // Insutype string `json:"insutype"`
  22302. // Invono interface{} `json:"invono"`
  22303. // Enddate string `json:"enddate"`
  22304. // CashPayamt float64 `json:"cash_payamt"`
  22305. // PsnType string `json:"psn_type"`
  22306. // FixmedinsName string `json:"fixmedins_name"`
  22307. // HifpPay float64 `json:"hifp_pay"`
  22308. // NewFlag interface{} `json:"new_flag"`
  22309. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22310. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22311. // PayLoc string `json:"pay_loc"`
  22312. // ClrType string `json:"clr_type"`
  22313. // RefdSetlFlag string `json:"refd_setl_flag"`
  22314. // CvlservFlag string `json:"cvlserv_flag"`
  22315. // EmpName string `json:"emp_name"`
  22316. // Brdy string `json:"brdy"`
  22317. // Naty string `json:"naty"`
  22318. // Certno string `json:"certno"`
  22319. // DiseCode string `json:"dise_code"`
  22320. // FixmedinsCode string `json:"fixmedins_code"`
  22321. // DedcHospLv string `json:"dedc_hosp_lv"`
  22322. // OpterName string `json:"opter_name"`
  22323. // Balc float64 `json:"balc"`
  22324. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22325. // PsnCertType string `json:"psn_cert_type"`
  22326. // HifobPay float64 `json:"hifob_pay"`
  22327. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22328. // HifesPay float64 `json:"hifes_pay"`
  22329. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22330. // OptTime string `json:"opt_time"`
  22331. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22332. // SetlID string `json:"setl_id"`
  22333. // MafPay float64 `json:"maf_pay"`
  22334. // PsnName string `json:"psn_name"`
  22335. // InsuOptins interface{} `json:"insu_optins"`
  22336. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22337. // ClrOptins string `json:"clr_optins"`
  22338. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22339. // DiseName string `json:"dise_name"`
  22340. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22341. // Age float64 `json:"age"`
  22342. // DtrtCertType string `json:"dtrt_cert_type"`
  22343. // HospLv string `json:"hosp_lv"`
  22344. // } `json:"setlinfo"`
  22345. // Setldetail []struct {
  22346. // FundPayType string `json:"fund_pay_type"`
  22347. // FundPayamt float64 `json:"fund_payamt"`
  22348. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22349. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22350. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22351. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22352. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22353. // } `json:"setldetail"`
  22354. // } `json:"output"`
  22355. // Infcode int `json:"infcode"`
  22356. // WarnMsg interface{} `json:"warn_msg"`
  22357. // Cainfo interface{} `json:"cainfo"`
  22358. // ErrMsg interface{} `json:"err_msg"`
  22359. // RefmsgTime string `json:"refmsg_time"`
  22360. // Signtype interface{} `json:"signtype"`
  22361. // RespondTime string `json:"respond_time"`
  22362. // InfRefmsgid string `json:"inf_refmsgid"`
  22363. // }
  22364. type Result002 struct {
  22365. Cainfo interface{} `json:"cainfo"`
  22366. ErrMsg string `json:"err_msg"`
  22367. InfRefmsgid string `json:"inf_refmsgid"`
  22368. Infcode int64 `json:"infcode"`
  22369. Output struct {
  22370. RxFile string `json:"rx_file"`
  22371. SignDigest string `json:"sign_digest"`
  22372. SignCertSn string `json:"sign_cert_sn"`
  22373. SignCertDn string `json:"sign_cert_dn"`
  22374. } `json:"output"`
  22375. RefmsgTime string `json:"refmsg_time"`
  22376. RespondTime string `json:"respond_time"`
  22377. Signtype interface{} `json:"signtype"`
  22378. WarnMsg interface{} `json:"warn_msg"`
  22379. }
  22380. type Result003 struct {
  22381. Cainfo interface{} `json:"cainfo"`
  22382. ErrMsg string `json:"err_msg"`
  22383. InfRefmsgid string `json:"inf_refmsgid"`
  22384. Infcode int64 `json:"infcode"`
  22385. Output struct {
  22386. HiRxno string `json:"hi_rxno"`
  22387. RxStasCodg string `json:"rx_stas_codg"`
  22388. RxStasName string `json:"rx_stas_name"`
  22389. } `json:"output"`
  22390. RefmsgTime string `json:"refmsg_time"`
  22391. RespondTime string `json:"respond_time"`
  22392. Signtype interface{} `json:"signtype"`
  22393. WarnMsg interface{} `json:"warn_msg"`
  22394. }
  22395. type ResultEleven struct {
  22396. Cainfo string `json:"cainfo"`
  22397. ErrMsg string `json:"err_msg"`
  22398. InfRefmsgid string `json:"inf_refmsgid"`
  22399. Infcode int64 `json:"infcode"`
  22400. Output struct {
  22401. Setlinfo struct {
  22402. SetlTime string `json:"setl_time"`
  22403. CvlservPay float64 `json:"cvlserv_pay"`
  22404. Year string `json:"year"`
  22405. MedType string `json:"med_type"`
  22406. PsnPay float64 `json:"psn_pay"`
  22407. OpterID string `json:"opter_id"`
  22408. Begndate string `json:"begndate"`
  22409. FlxempeFlag string `json:"flxempe_flag"`
  22410. HifmiPay float64 `json:"hifmi_pay"`
  22411. PsnNo string `json:"psn_no"`
  22412. ActPayDedc float64 `json:"act_pay_dedc"`
  22413. MedinsSetlID interface{} `json:"medins_setl_id"`
  22414. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22415. ClrWay string `json:"clr_way"`
  22416. OthPay float64 `json:"oth_pay"`
  22417. Gend string `json:"gend"`
  22418. MdtrtID string `json:"mdtrt_id"`
  22419. AcctPay float64 `json:"acct_pay"`
  22420. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22421. Insutype string `json:"insutype"`
  22422. Invono interface{} `json:"invono"`
  22423. Enddate string `json:"enddate"`
  22424. CashPayamt float64 `json:"cash_payamt"`
  22425. PsnType string `json:"psn_type"`
  22426. FixmedinsName string `json:"fixmedins_name"`
  22427. HifpPay float64 `json:"hifp_pay"`
  22428. NewFlag interface{} `json:"new_flag"`
  22429. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22430. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22431. PayLoc string `json:"pay_loc"`
  22432. ClrType string `json:"clr_type"`
  22433. RefdSetlFlag string `json:"refd_setl_flag"`
  22434. CvlservFlag string `json:"cvlserv_flag"`
  22435. EmpName string `json:"emp_name"`
  22436. Brdy string `json:"brdy"`
  22437. Naty string `json:"naty"`
  22438. Certno string `json:"certno"`
  22439. DiseCode string `json:"dise_code"`
  22440. FixmedinsCode string `json:"fixmedins_code"`
  22441. DedcHospLv string `json:"dedc_hosp_lv"`
  22442. OpterName string `json:"opter_name"`
  22443. Balc float64 `json:"balc"`
  22444. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22445. PsnCertType string `json:"psn_cert_type"`
  22446. HifobPay float64 `json:"hifob_pay"`
  22447. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22448. HifesPay float64 `json:"hifes_pay"`
  22449. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22450. OptTime string `json:"opt_time"`
  22451. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22452. SetlID string `json:"setl_id"`
  22453. MafPay float64 `json:"maf_pay"`
  22454. PsnName string `json:"psn_name"`
  22455. InsuOptins interface{} `json:"insu_optins"`
  22456. PrefFundPay interface{} `json:"pref_fund_pay"`
  22457. ClrOptins string `json:"clr_optins"`
  22458. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22459. DiseName string `json:"dise_name"`
  22460. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22461. Age float64 `json:"age"`
  22462. DtrtCertType string `json:"dtrt_cert_type"`
  22463. HospLv string `json:"hosp_lv"`
  22464. PsnCashPay float64 `json:"psn_cash_pay"`
  22465. } `json:"setlinfo"`
  22466. } `json:"output"`
  22467. RefmsgTime string `json:"refmsg_time"`
  22468. RespondTime string `json:"respond_time"`
  22469. Signtype interface{} `json:"signtype"`
  22470. WarnMsg interface{} `json:"warn_msg"`
  22471. }
  22472. type ResultElevenah struct {
  22473. Cainfo string `json:"cainfo"`
  22474. ErrMsg string `json:"err_msg"`
  22475. InfRefmsgid string `json:"inf_refmsgid"`
  22476. Infcode int64 `json:"infcode"`
  22477. Output struct {
  22478. Setlinfo struct {
  22479. SetlTime int64 `json:"setl_time"`
  22480. CvlservPay float64 `json:"cvlserv_pay"`
  22481. Year string `json:"year"`
  22482. MedType string `json:"med_type"`
  22483. PsnPay float64 `json:"psn_pay"`
  22484. OpterID string `json:"opter_id"`
  22485. Begndate int64 `json:"begndate"`
  22486. FlxempeFlag string `json:"flxempe_flag"`
  22487. HifmiPay float64 `json:"hifmi_pay"`
  22488. PsnNo string `json:"psn_no"`
  22489. ActPayDedc float64 `json:"act_pay_dedc"`
  22490. MedinsSetlID interface{} `json:"medins_setl_id"`
  22491. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22492. ClrWay string `json:"clr_way"`
  22493. OthPay float64 `json:"oth_pay"`
  22494. Gend string `json:"gend"`
  22495. MdtrtID string `json:"mdtrt_id"`
  22496. AcctPay float64 `json:"acct_pay"`
  22497. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22498. Insutype string `json:"insutype"`
  22499. Invono interface{} `json:"invono"`
  22500. Enddate int64 `json:"enddate"`
  22501. CashPayamt float64 `json:"cash_payamt"`
  22502. PsnType string `json:"psn_type"`
  22503. FixmedinsName string `json:"fixmedins_name"`
  22504. HifpPay float64 `json:"hifp_pay"`
  22505. NewFlag interface{} `json:"new_flag"`
  22506. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22507. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22508. PayLoc string `json:"pay_loc"`
  22509. ClrType string `json:"clr_type"`
  22510. RefdSetlFlag string `json:"refd_setl_flag"`
  22511. CvlservFlag string `json:"cvlserv_flag"`
  22512. EmpName string `json:"emp_name"`
  22513. Brdy int64 `json:"brdy"`
  22514. Naty string `json:"naty"`
  22515. Certno string `json:"certno"`
  22516. DiseCode string `json:"dise_code"`
  22517. FixmedinsCode string `json:"fixmedins_code"`
  22518. DedcHospLv string `json:"dedc_hosp_lv"`
  22519. OpterName string `json:"opter_name"`
  22520. Balc float64 `json:"balc"`
  22521. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22522. PsnCertType string `json:"psn_cert_type"`
  22523. HifobPay float64 `json:"hifob_pay"`
  22524. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22525. HifesPay float64 `json:"hifes_pay"`
  22526. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22527. OptTime int64 `json:"opt_time"`
  22528. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22529. SetlID string `json:"setl_id"`
  22530. MafPay float64 `json:"maf_pay"`
  22531. PsnName string `json:"psn_name"`
  22532. InsuOptins interface{} `json:"insu_optins"`
  22533. PrefFundPay interface{} `json:"pref_fund_pay"`
  22534. ClrOptins string `json:"clr_optins"`
  22535. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22536. DiseName string `json:"dise_name"`
  22537. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22538. Age float64 `json:"age"`
  22539. DtrtCertType string `json:"dtrt_cert_type"`
  22540. HospLv string `json:"hosp_lv"`
  22541. PsnCashPay float64 `json:"psn_cash_pay"`
  22542. } `json:"setlinfo"`
  22543. } `json:"output"`
  22544. RefmsgTime string `json:"refmsg_time"`
  22545. RespondTime string `json:"respond_time"`
  22546. Signtype interface{} `json:"signtype"`
  22547. WarnMsg interface{} `json:"warn_msg"`
  22548. }
  22549. type ResultEleven10265 struct {
  22550. Cainfo string `json:"cainfo"`
  22551. ErrMsg string `json:"err_msg"`
  22552. InfRefmsgid string `json:"inf_refmsgid"`
  22553. Infcode string `json:"infcode"`
  22554. Output struct {
  22555. Setlinfo struct {
  22556. SetlTime string `json:"setl_time"`
  22557. CvlservPay float64 `json:"cvlserv_pay"`
  22558. Year string `json:"year"`
  22559. MedType string `json:"med_type"`
  22560. PsnPay float64 `json:"psn_pay"`
  22561. OpterID string `json:"opter_id"`
  22562. Begndate string `json:"begndate"`
  22563. FlxempeFlag string `json:"flxempe_flag"`
  22564. HifmiPay float64 `json:"hifmi_pay"`
  22565. PsnNo string `json:"psn_no"`
  22566. ActPayDedc float64 `json:"act_pay_dedc"`
  22567. MedinsSetlID interface{} `json:"medins_setl_id"`
  22568. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22569. ClrWay string `json:"clr_way"`
  22570. OthPay float64 `json:"oth_pay"`
  22571. Gend string `json:"gend"`
  22572. MdtrtID string `json:"mdtrt_id"`
  22573. AcctPay float64 `json:"acct_pay"`
  22574. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22575. Insutype string `json:"insutype"`
  22576. Invono interface{} `json:"invono"`
  22577. Enddate string `json:"enddate"`
  22578. CashPayamt float64 `json:"cash_payamt"`
  22579. PsnType string `json:"psn_type"`
  22580. FixmedinsName string `json:"fixmedins_name"`
  22581. HifpPay float64 `json:"hifp_pay"`
  22582. NewFlag interface{} `json:"new_flag"`
  22583. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22584. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22585. PayLoc string `json:"pay_loc"`
  22586. ClrType string `json:"clr_type"`
  22587. RefdSetlFlag string `json:"refd_setl_flag"`
  22588. CvlservFlag string `json:"cvlserv_flag"`
  22589. EmpName string `json:"emp_name"`
  22590. Brdy string `json:"brdy"`
  22591. Naty string `json:"naty"`
  22592. Certno string `json:"certno"`
  22593. DiseCode string `json:"dise_code"`
  22594. FixmedinsCode string `json:"fixmedins_code"`
  22595. DedcHospLv string `json:"dedc_hosp_lv"`
  22596. OpterName string `json:"opter_name"`
  22597. Balc float64 `json:"balc"`
  22598. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22599. PsnCertType string `json:"psn_cert_type"`
  22600. HifobPay float64 `json:"hifob_pay"`
  22601. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22602. HifesPay float64 `json:"hifes_pay"`
  22603. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22604. OptTime string `json:"opt_time"`
  22605. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22606. SetlID string `json:"setl_id"`
  22607. MafPay float64 `json:"maf_pay"`
  22608. PsnName string `json:"psn_name"`
  22609. InsuOptins interface{} `json:"insu_optins"`
  22610. PrefFundPay interface{} `json:"pref_fund_pay"`
  22611. ClrOptins string `json:"clr_optins"`
  22612. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22613. DiseName string `json:"dise_name"`
  22614. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22615. Age float64 `json:"age"`
  22616. DtrtCertType string `json:"dtrt_cert_type"`
  22617. HospLv string `json:"hosp_lv"`
  22618. PsnCashPay float64 `json:"psn_cash_pay"`
  22619. } `json:"setlinfo"`
  22620. } `json:"output"`
  22621. RefmsgTime string `json:"refmsg_time"`
  22622. RespondTime string `json:"respond_time"`
  22623. Signtype interface{} `json:"signtype"`
  22624. WarnMsg interface{} `json:"warn_msg"`
  22625. }
  22626. type ResultTwelve struct {
  22627. Cainfo string `json:"cainfo"`
  22628. ErrMsg string `json:"err_msg"`
  22629. InfRefmsgid string `json:"inf_refmsgid"`
  22630. Infcode int64 `json:"infcode"`
  22631. Output struct {
  22632. MdtrtId string `json:"mdtrt_id"`
  22633. ChrgBchno string `json:"chrg_bchno"`
  22634. PsnNo string `json:"psn_no"`
  22635. } `json:"output"`
  22636. RefmsgTime string `json:"refmsg_time"`
  22637. RespondTime string `json:"respond_time"`
  22638. Signtype interface{} `json:"signtype"`
  22639. WarnMsg interface{} `json:"warn_msg"`
  22640. }
  22641. type ResultThirteen struct {
  22642. ErrMsg string `json:"err_msg"`
  22643. InfRefmsgid string `json:"inf_refmsgid"`
  22644. Infcode int64 `json:"infcode"`
  22645. Output struct {
  22646. Result struct {
  22647. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22648. } `json:"result"`
  22649. } `json:"output"`
  22650. RefmsgTime string `json:"refmsg_time"`
  22651. RespondTime string `json:"respond_time"`
  22652. Signtype interface{} `json:"signtype"`
  22653. WarnInfo interface{} `json:"warn_info"`
  22654. }
  22655. type ResultThirteen10265 struct {
  22656. ErrMsg string `json:"err_msg"`
  22657. InfRefmsgid string `json:"inf_refmsgid"`
  22658. Infcode string `json:"infcode"`
  22659. Output struct {
  22660. Result struct {
  22661. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22662. } `json:"result"`
  22663. } `json:"output"`
  22664. RefmsgTime string `json:"refmsg_time"`
  22665. RespondTime string `json:"respond_time"`
  22666. Signtype interface{} `json:"signtype"`
  22667. WarnInfo interface{} `json:"warn_info"`
  22668. }
  22669. type ResultFourteen struct {
  22670. ErrMsg string `json:"err_msg"`
  22671. InfRefmsgid string `json:"inf_refmsgid"`
  22672. Infcode int64 `json:"infcode"`
  22673. Output struct {
  22674. } `json:"output"`
  22675. RefmsgTime string `json:"refmsg_time"`
  22676. RespondTime string `json:"respond_time"`
  22677. Signtype interface{} `json:"signtype"`
  22678. WarnInfo interface{} `json:"warn_info"`
  22679. }
  22680. type ResultCFYLJG001 struct {
  22681. ErrMsg string `json:"err_msg"`
  22682. InfRefmsgid string `json:"inf_refmsgid"`
  22683. Infcode int64 `json:"infcode"`
  22684. Output struct {
  22685. RxTraceCode string `json:"rx_trace_code"`
  22686. HiRxno string `json:"hi_rxno"`
  22687. } `json:"output"`
  22688. RefmsgTime string `json:"refmsg_time"`
  22689. RespondTime string `json:"respond_time"`
  22690. Signtype interface{} `json:"signtype"`
  22691. WarnInfo interface{} `json:"warn_info"`
  22692. }
  22693. type ResultCFYLJG007 struct {
  22694. ErrMsg string `json:"err_msg"`
  22695. InfRefmsgid string `json:"inf_refmsgid"`
  22696. Infcode int64 `json:"infcode"`
  22697. Output struct {
  22698. HiRxno string `json:"hi_rxno"`
  22699. RxStasName string `json:"rx_stas_name"`
  22700. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22701. Seltdelts []interface{} `json:"seltdelts"`
  22702. RxUsedStasName string `json:"rx_used_stas_name"`
  22703. RxStasCodg string `json:"rx_stas_codg"`
  22704. } `json:"output"`
  22705. RefmsgTime string `json:"refmsg_time"`
  22706. RespondTime string `json:"respond_time"`
  22707. Signtype interface{} `json:"signtype"`
  22708. WarnInfo interface{} `json:"warn_info"`
  22709. }
  22710. type ResultCFYLJG002 struct {
  22711. ErrMsg string `json:"err_msg"`
  22712. InfRefmsgid string `json:"inf_refmsgid"`
  22713. Infcode int64 `json:"infcode"`
  22714. Output struct {
  22715. RxFile string `json:"rx_file"`
  22716. SignDigest string `json:"sign_digest"`
  22717. SignCertSn string `json:"sign_cert_sn"`
  22718. SignCertDn string `json:"sign_cert_dn"`
  22719. } `json:"output"`
  22720. RefmsgTime string `json:"refmsg_time"`
  22721. RespondTime string `json:"respond_time"`
  22722. Signtype interface{} `json:"signtype"`
  22723. WarnInfo interface{} `json:"warn_info"`
  22724. }
  22725. type ResultCFYLJG003 struct {
  22726. ErrMsg string `json:"err_msg"`
  22727. InfRefmsgid string `json:"inf_refmsgid"`
  22728. Infcode int64 `json:"infcode"`
  22729. Output struct {
  22730. HiRxno string `json:"hi_rxno"`
  22731. RxStasCodg string `json:"rx_stas_codg"`
  22732. RxStasName string `json:"rx_stas_name"`
  22733. } `json:"output"`
  22734. RefmsgTime string `json:"refmsg_time"`
  22735. RespondTime string `json:"respond_time"`
  22736. Signtype interface{} `json:"signtype"`
  22737. WarnInfo interface{} `json:"warn_info"`
  22738. }
  22739. type ResultCFYLJG004 struct {
  22740. ErrMsg string `json:"err_msg"`
  22741. InfRefmsgid string `json:"inf_refmsgid"`
  22742. Infcode int64 `json:"infcode"`
  22743. Output struct {
  22744. HiRxno string `json:"hi_rxno"`
  22745. RxStasCodg string `json:"rx_stas_codg"`
  22746. RxStasName string `json:"rx_stas_name"`
  22747. } `json:"output"`
  22748. RefmsgTime string `json:"refmsg_time"`
  22749. RespondTime string `json:"respond_time"`
  22750. Signtype interface{} `json:"signtype"`
  22751. WarnInfo interface{} `json:"warn_info"`
  22752. }
  22753. type ResultCFYLJG008 struct {
  22754. ErrMsg string `json:"err_msg"`
  22755. InfRefmsgid string `json:"inf_refmsgid"`
  22756. Infcode int64 `json:"infcode"`
  22757. Output struct {
  22758. PoolareaNo string `json:"poolareaNo"`
  22759. AdmdvsName string `json:"admdvsName"`
  22760. Count string `json:"count"`
  22761. } `json:"output"`
  22762. RefmsgTime string `json:"refmsg_time"`
  22763. RespondTime string `json:"respond_time"`
  22764. Signtype interface{} `json:"signtype"`
  22765. WarnInfo interface{} `json:"warn_info"`
  22766. }
  22767. type ResultCFYLJG005 struct {
  22768. ErrMsg string `json:"err_msg"`
  22769. InfRefmsgid string `json:"inf_refmsgid"`
  22770. Infcode int64 `json:"infcode"`
  22771. Output struct {
  22772. HiRxNo string `json:"hi_rxno"`
  22773. FixMedinsCode string `json:"fixmedins_code"`
  22774. FixMedinsName string `json:"fixmedins_name"`
  22775. RxStasCodg string `json:"rx_stas_codg"`
  22776. RxStasName string `json:"rx_stas_name"`
  22777. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22778. RxUserdStasName string `json:"rx_userd_stas_name"`
  22779. PrscTime string `json:"prsc_time"`
  22780. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22781. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22782. RxUsedWayName string `json:"rx_used_way_name"`
  22783. RxFrquCodg string `json:"rx_frqu_codg"`
  22784. RxFrquName string `json:"rx_frqu_name"`
  22785. RxDosunt string `json:"rx_dosunt"`
  22786. RxDoscnt float64 `json:"rx_doscnt"`
  22787. RxDrordDscr string `json:"rx_drord_dscr"`
  22788. ValiDays int64 `json:"vali_days"`
  22789. ValiEndTime string `json:"vali_end_time"`
  22790. ReptFlag string `json:"rept_flag"`
  22791. MaxReptCnt int64 `json:"max_rept_cnt"`
  22792. ReptdCnt int64 `json:"reptd_cnt"`
  22793. MinInrvDays int64 `json:"min_inrv_days"`
  22794. RxTypeCode string `json:"rx_type_code"`
  22795. RxTypeName string `json:"rx_type_name"`
  22796. LongRxFlag string `json:"long_rx_flag"`
  22797. RxDetlList []struct {
  22798. MedListCodg string `json:"med_list_codg"`
  22799. MedinsListCodg string `json:"medins_list_codg"`
  22800. HospPrepFlag string `json:"hosp_prep_flag"`
  22801. RxItemTypeCode string `json:"rx_item_type_code"`
  22802. RxItemTypeName string `json:"rx_item_type_name"`
  22803. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22804. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22805. TcmHerbFoote string `json:"tcmherb_foote"`
  22806. MednTypeCode string `json:"medn_type_code"`
  22807. MednTypeName string `json:"medn_type_name"`
  22808. MainMedcFlag string `json:"main_medc_flag"`
  22809. UrgtFlag string `json:"urgt_flag"`
  22810. BasMednFlag string `json:"bas_medn_flag"`
  22811. ImpDrugFlag string `json:"imp_drug_flag"`
  22812. ProdBarc string `json:"prod_barc"`
  22813. DrugProdname string `json:"drug_prodname"`
  22814. GennameCodg string `json:"genname_codg"`
  22815. DrugGenname string `json:"drug_genname"`
  22816. DrugDosform string `json:"drug_dosform"`
  22817. DrugSpec string `json:"drug_spec"`
  22818. PrdrName string `json:"prdr_name"`
  22819. MedcWayCodg string `json:"medc_way_codg"`
  22820. MedcWayDscr string `json:"medc_way_dscr"`
  22821. MedcBegntime string `json:"medc_begntime"`
  22822. MedcEndtime string `json:"medc_endtime"`
  22823. MedcDays float64 `json:"medc_days"`
  22824. DrugPric float64 `json:"drug_pric"`
  22825. DrugSumamt float64 `json:"drug_sumamt"`
  22826. DrugCnt float64 `json:"drug_cnt"`
  22827. DrugDosunt string `json:"drug_dosunt"`
  22828. SinDoscnt float64 `json:"sin_doscnt"`
  22829. SinDosunt string `json:"sin_dosunt"`
  22830. UsedFrquCodg string `json:"used_frqu_codg"`
  22831. UsedFrquName string `json:"used_frqu_name"`
  22832. DrugTotlcnt string `json:"drug_totlcnt"`
  22833. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22834. DiseCodg string `json:"dise_codg"`
  22835. HospApprFlag string `json:"hosp_appr_flag"`
  22836. } `json:"rx_detl_list"`
  22837. RxOtpinfo struct {
  22838. MedType string `json:"med_type"`
  22839. IptOtpNo string `json:"ipt_otp_no"`
  22840. OtpIptFlag string `json:"otp_ipt_flag"`
  22841. PatnName string `json:"patn_name"`
  22842. PatnAge float64 `json:"patn_age"`
  22843. PatnHgt float64 `json:"patn_hgt"`
  22844. PatnWt float64 `json:"patn_wt"`
  22845. Gend string `json:"gend"`
  22846. GesoVal float64 `json:"geso_val"`
  22847. NwbFlag string `json:"nwb_flag"`
  22848. NwbAge string `json:"nwb_age"`
  22849. SuckPrdFlag string `json:"suck_prd_flag"`
  22850. AlgsHis string `json:"algs_his"`
  22851. Insutype string `json:"insutype"`
  22852. PrscDeptName string `json:"prsc_dept_name"`
  22853. PrscDrName string `json:"prsc_dr_name"`
  22854. PharName string `json:"phar_name"`
  22855. PharChkTime string `json:"phar_chk_time"`
  22856. MdtrtTime string `json:"mdtrt_time"`
  22857. DiseCodg string `json:"dise_codg"`
  22858. DiseName string `json:"dise_name"`
  22859. SpDiseFlag string `json:"sp_dise_flag"`
  22860. MaindiagCode string `json:"maindiag_code"`
  22861. MaindiagName string `json:"maindiag_name"`
  22862. DiseCondDscr string `json:"dise_cond_dscr"`
  22863. FstdiagFlag string `json:"fstdiag_flag"`
  22864. } `json:"rx_otpinfo"`
  22865. RxDiseList []struct {
  22866. DiagType string `json:"diag_type"`
  22867. MaindiagFlag string `json:"maindiag_flag"`
  22868. DiagSrtNo string `json:"diag_srt_no"`
  22869. DiagCode string `json:"diag_code"`
  22870. DiagName string `json:"diag_name"`
  22871. DiagDept string `json:"diag_dept"`
  22872. DiagDrNo string `json:"diag_dr_no"`
  22873. DiagDrName string `json:"diag_dr_name"`
  22874. DiagTime string `json:"diag_time"`
  22875. TcmDiseCode string `json:"tcm_dise_code"`
  22876. TcmDiseName string `json:"tcm_dise_name"`
  22877. TcmSympCode string `json:"tcmsymp_code"`
  22878. TcmSymp string `json:"tcmsymp"`
  22879. } `json:"rx_dise_list"`
  22880. } `json:"output"`
  22881. RefmsgTime string `json:"refmsg_time"`
  22882. RespondTime string `json:"respond_time"`
  22883. Signtype interface{} `json:"signtype"`
  22884. WarnInfo interface{} `json:"warn_info"`
  22885. }
  22886. type ResultCFYLJG006 struct {
  22887. ErrMsg string `json:"err_msg"`
  22888. InfRefmsgid string `json:"inf_refmsgid"`
  22889. Infcode int64 `json:"infcode"`
  22890. Output struct {
  22891. HiRxNo string `json:"hi_rxno"`
  22892. PharCode string `json:"phar_code"`
  22893. PharName string `json:"phar_name"`
  22894. RxChkOpnn string `json:"rx_chk_opnn"`
  22895. RxChkTime string `json:"rx_chk_time"`
  22896. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22897. RxChkStasName string `json:"rx_chk_stas_name"`
  22898. RxStasCodg string `json:"rx_stas_codg"`
  22899. RxStasName string `json:"rx_stas_name"`
  22900. } `json:"output"`
  22901. RefmsgTime string `json:"refmsg_time"`
  22902. RespondTime string `json:"respond_time"`
  22903. Signtype interface{} `json:"signtype"`
  22904. WarnInfo interface{} `json:"warn_info"`
  22905. }
  22906. type ResultFourteen10265 struct {
  22907. ErrMsg string `json:"err_msg"`
  22908. InfRefmsgid string `json:"inf_refmsgid"`
  22909. Infcode string `json:"infcode"`
  22910. Output struct {
  22911. } `json:"output"`
  22912. RefmsgTime string `json:"refmsg_time"`
  22913. RespondTime string `json:"respond_time"`
  22914. Signtype interface{} `json:"signtype"`
  22915. WarnInfo interface{} `json:"warn_info"`
  22916. }
  22917. type ResultSixteen struct {
  22918. Cainfo string `json:"cainfo"`
  22919. ErrMsg string `json:"err_msg"`
  22920. InfRefmsgid string `json:"inf_refmsgid"`
  22921. Infcode int64 `json:"infcode"`
  22922. Output struct {
  22923. Setlinfo struct {
  22924. MdtrtID string `json:"mdtrt_id"`
  22925. SetlID string `json:"setl_id"`
  22926. ClrOptins string `json:"clr_optins"`
  22927. SetlTime string `json:"setl_time"`
  22928. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22929. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22930. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22931. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22932. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22933. ActPayDedc float64 `json:"act_pay_dedc"`
  22934. HifpPay float64 `json:"hifp_pay"`
  22935. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22936. Lfpay float64 `json:"selfpay"`
  22937. CvlservPay float64 `json:"cvlserv_pay"`
  22938. HifesPay float64 `json:"hifes_pay"`
  22939. HifmiPay float64 `json:"hifmi_pay"`
  22940. HifobPay float64 `json:"hifob_pay"`
  22941. MafPay float64 `json:"maf_pay"`
  22942. OthPay float64 `json:"oth_pay"`
  22943. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22944. PsnPartAmt float64 `json:"psn_part_amt"`
  22945. AcctPay float64 `json:"acct_pay"`
  22946. Balc float64 `json:"balc"`
  22947. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22948. HospPartAmt float64 `json:"hosp_part_amt"`
  22949. MedinsSetlID string `json:"medins_setl_id"`
  22950. PdnCashPay string `json:"pdn_cash_pay"`
  22951. } `json:"setlinfo"`
  22952. } `json:"output"`
  22953. RefmsgTime string `json:"refmsg_time"`
  22954. RespondTime string `json:"respond_time"`
  22955. Signtype interface{} `json:"signtype"`
  22956. WarnMsg interface{} `json:"warn_msg"`
  22957. }
  22958. type ResultSixteen10265 struct {
  22959. Cainfo string `json:"cainfo"`
  22960. ErrMsg string `json:"err_msg"`
  22961. InfRefmsgid string `json:"inf_refmsgid"`
  22962. Infcode string `json:"infcode"`
  22963. Output struct {
  22964. Setlinfo struct {
  22965. MdtrtID string `json:"mdtrt_id"`
  22966. SetlID string `json:"setl_id"`
  22967. ClrOptins string `json:"clr_optins"`
  22968. SetlTime string `json:"setl_time"`
  22969. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22970. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22971. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22972. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22973. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22974. ActPayDedc float64 `json:"act_pay_dedc"`
  22975. HifpPay float64 `json:"hifp_pay"`
  22976. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22977. Lfpay float64 `json:"selfpay"`
  22978. CvlservPay float64 `json:"cvlserv_pay"`
  22979. HifesPay float64 `json:"hifes_pay"`
  22980. HifmiPay float64 `json:"hifmi_pay"`
  22981. HifobPay float64 `json:"hifob_pay"`
  22982. MafPay float64 `json:"maf_pay"`
  22983. OthPay float64 `json:"oth_pay"`
  22984. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22985. PsnPartAmt float64 `json:"psn_part_amt"`
  22986. AcctPay float64 `json:"acct_pay"`
  22987. Balc float64 `json:"balc"`
  22988. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22989. HospPartAmt float64 `json:"hosp_part_amt"`
  22990. MedinsSetlID string `json:"medins_setl_id"`
  22991. PdnCashPay string `json:"pdn_cash_pay"`
  22992. } `json:"setlinfo"`
  22993. } `json:"output"`
  22994. RefmsgTime string `json:"refmsg_time"`
  22995. RespondTime string `json:"respond_time"`
  22996. Signtype interface{} `json:"signtype"`
  22997. WarnMsg interface{} `json:"warn_msg"`
  22998. }
  22999. type ResultSixteen10265Two struct {
  23000. Cainfo string `json:"cainfo"`
  23001. ErrMsg string `json:"err_msg"`
  23002. InfRefmsgid string `json:"inf_refmsgid"`
  23003. Infcode string `json:"infcode"`
  23004. Output struct {
  23005. Setlinfo interface{} `json:"setlinfo"`
  23006. } `json:"output"`
  23007. RefmsgTime string `json:"refmsg_time"`
  23008. RespondTime string `json:"respond_time"`
  23009. Signtype interface{} `json:"signtype"`
  23010. WarnMsg interface{} `json:"warn_msg"`
  23011. }
  23012. type ResultgzSixteen10265Two struct {
  23013. Cainfo string `json:"cainfo"`
  23014. ErrMsg string `json:"err_msg"`
  23015. InfRefmsgid string `json:"inf_refmsgid"`
  23016. Infcode int64 `json:"infcode"`
  23017. Output struct {
  23018. Setlinfo interface{} `json:"setlinfo"`
  23019. } `json:"output"`
  23020. RefmsgTime string `json:"refmsg_time"`
  23021. RespondTime string `json:"respond_time"`
  23022. Signtype interface{} `json:"signtype"`
  23023. WarnMsg interface{} `json:"warn_msg"`
  23024. }
  23025. type ResultSeventeen struct {
  23026. ErrMsg string `json:"err_msg"`
  23027. InfRefmsgid string `json:"inf_refmsgid"`
  23028. Infcode int64 `json:"infcode"`
  23029. Output struct {
  23030. SetlListId string `json:"setl_list_id"`
  23031. } `json:"output"`
  23032. RefmsgTime string `json:"refmsg_time"`
  23033. RespondTime string `json:"respond_time"`
  23034. Signtype string `json:"signtype"`
  23035. WarnInfo string `json:"warn_info"`
  23036. }
  23037. type ResultSeventeenOther struct {
  23038. ErrMsg string `json:"err_msg"`
  23039. InfRefmsgid string `json:"inf_refmsgid"`
  23040. Infcode string `json:"infcode"`
  23041. Output struct {
  23042. SetlListId string `json:"setl_list_id"`
  23043. } `json:"output"`
  23044. RefmsgTime string `json:"refmsg_time"`
  23045. RespondTime string `json:"respond_time"`
  23046. Signtype string `json:"signtype"`
  23047. WarnInfo string `json:"warn_info"`
  23048. }
  23049. type Result90991 struct {
  23050. ErrMsg string `json:"err_msg"`
  23051. InfRefmsgid string `json:"inf_refmsgid"`
  23052. Infcode int64 `json:"infcode"`
  23053. Output struct {
  23054. Result struct {
  23055. PsnNo string `json:"psn_no"`
  23056. CardStat string `json:"card_stat"`
  23057. Certno string `json:"certno"`
  23058. PsnName string `json:"psn_name"`
  23059. CheckStat string `json:"check_stat"`
  23060. SscnoCheckStat string `json:"sscno_check_stat"`
  23061. } `json:"result"`
  23062. } `json:"output"`
  23063. RefmsgTime string `json:"refmsg_time"`
  23064. RespondTime string `json:"respond_time"`
  23065. Signtype interface{} `json:"signtype"`
  23066. WarnInfo interface{} `json:"warn_info"`
  23067. }
  23068. type Result90100 struct {
  23069. ErrMsg string `json:"err_msg"`
  23070. InfRefmsgid string `json:"inf_refmsgid"`
  23071. Infcode int64 `json:"infcode"`
  23072. Output struct {
  23073. PoolareaNo string `json:"poolarea_no"`
  23074. PoolareaNoName string `json:"poolarea_no_name"`
  23075. Insutype string `json:"insutype"`
  23076. InsutypeName string `json:"insutype_name"`
  23077. ClctType string `json:"clct_type"`
  23078. ClctTypeName string `json:"clct_type_name"`
  23079. ClctFlag string `json:"clct_flag"`
  23080. ClctFlagName string `json:"clct_flag_name"`
  23081. AccrymBegn string `json:"accrym_begn"`
  23082. AccrymEnd string `json:"accrym_end"`
  23083. ClctTime string `json:"clct_time"`
  23084. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23085. } `json:"output"`
  23086. RefmsgTime string `json:"refmsg_time"`
  23087. RespondTime string `json:"respond_time"`
  23088. Signtype interface{} `json:"signtype"`
  23089. WarnInfo interface{} `json:"warn_info"`
  23090. }
  23091. type Custom struct {
  23092. DetItemFeeSumamt string
  23093. Cut string
  23094. FeedetlSn string
  23095. Price string
  23096. MedListCodg string
  23097. Type int64
  23098. AdviceId int64
  23099. ProjectId int64
  23100. ItemId int64
  23101. }
  23102. type Result5301 struct {
  23103. ErrMsg string `json:"err_msg"`
  23104. InfRefmsgid string `json:"inf_refmsgid"`
  23105. Infcode int64 `json:"infcode"`
  23106. Output struct {
  23107. Result []struct {
  23108. OpspDiseCode string `json:"opsp_dise_code"`
  23109. OpspDiseName string `json:"opsp_dise_name"`
  23110. Begndate string `json:"begndate"`
  23111. Enddate string `json:"enddate"`
  23112. } `json:"feedetail"`
  23113. } `json:"output"`
  23114. RefmsgTime string `json:"refmsg_time"`
  23115. RespondTime string `json:"respond_time"`
  23116. Signtype interface{} `json:"signtype"`
  23117. WarnInfo interface{} `json:"warn_info"`
  23118. }
  23119. type Result5301For10265 struct {
  23120. ErrMsg string `json:"err_msg"`
  23121. InfRefmsgid string `json:"inf_refmsgid"`
  23122. Infcode string `json:"infcode"`
  23123. Output struct {
  23124. Result []struct {
  23125. OpspDiseCode string `json:"opsp_dise_code"`
  23126. OpspDiseName string `json:"opsp_dise_name"`
  23127. Begndate string `json:"begndate"`
  23128. Enddate string `json:"enddate"`
  23129. } `json:"feedetail"`
  23130. } `json:"output"`
  23131. RefmsgTime string `json:"refmsg_time"`
  23132. RespondTime string `json:"respond_time"`
  23133. Signtype interface{} `json:"signtype"`
  23134. WarnInfo interface{} `json:"warn_info"`
  23135. }
  23136. //获取个人信息----挂号-----上传就诊信息
  23137. func (c *HisApiController) GetRegisterInfo() {
  23138. id, _ := c.GetInt64("id")
  23139. record_time := c.GetString("record_time")
  23140. settlementValue, _ := c.GetInt64("settlement_value")
  23141. medical_insurance_card := c.GetString("medical_insurance_card")
  23142. name := c.GetString("name")
  23143. id_card_type, _ := c.GetInt64("id_card_type")
  23144. certificates, _ := c.GetInt64("certificates")
  23145. medical_care, _ := c.GetInt64("medical_care")
  23146. birthday := c.GetString("birthday")
  23147. id_card := c.GetString("id_card")
  23148. register_type, _ := c.GetInt64("register")
  23149. doctor, _ := c.GetInt64("doctor")
  23150. department, _ := c.GetInt64("department")
  23151. gender, _ := c.GetInt64("sex")
  23152. registration_fee, _ := c.GetFloat("registration_fee")
  23153. medical_expenses, _ := c.GetFloat("medical_expenses")
  23154. social_type, _ := c.GetInt64("social_type")
  23155. admin_user_id, _ := c.GetInt64("admin_user_id")
  23156. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23157. mdtrt_type := c.GetString("mdtrt_type")
  23158. if id_card_type == 5 {
  23159. id_card_type = 4
  23160. }
  23161. timeLayout := "2006-01-02"
  23162. loc, _ := time.LoadLocation("Local")
  23163. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23164. birthUnix := birthdays.Unix()
  23165. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23166. if err != nil {
  23167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23168. return
  23169. }
  23170. recordDateTime := theTime.Unix()
  23171. adminInfo := c.GetAdminUserInfo()
  23172. var patient service.Patients
  23173. if id == 0 {
  23174. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23175. } else {
  23176. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23177. }
  23178. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23179. if patientPrescription.ID == 0 {
  23180. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23181. }
  23182. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23183. if patient.ID == 0 {
  23184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23185. return
  23186. }
  23187. if len(patient.IdCardNo) == 0 {
  23188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23189. return
  23190. }
  23191. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23192. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23193. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23194. //就诊结算未完成,不能进行二次挂号
  23195. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23196. if len(his) >= 1 {
  23197. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23198. if len(his) >= 1 && order.ID == 0 {
  23199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23200. return
  23201. }
  23202. }
  23203. //var register_log string
  23204. if config.IsOpen == 1 {
  23205. var res ResultTwo
  23206. var res10265 ResultTwo10265
  23207. var PsnNo string
  23208. var PsnCertType string
  23209. var Certno string
  23210. var PsnName string
  23211. var Gend string
  23212. var Naty string
  23213. var Brdy string
  23214. var Age float64
  23215. var infoStr string
  23216. var idetinfoStr string
  23217. var infocode int64
  23218. var verify_number string
  23219. fmt.Println(verify_number)
  23220. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23221. psn_info, _ := service.GetPsnByPatientId(id)
  23222. PsnNo = psn_info.PsnNo
  23223. PsnCertType = psn_info.PsnCertType
  23224. Certno = psn_info.Certno
  23225. PsnName = psn_info.PsnName
  23226. Gend = psn_info.Gend
  23227. Naty = psn_info.Naty
  23228. Brdy = psn_info.Brdy
  23229. Age = psn_info.Age
  23230. infoStr = psn_info.Insuinfo
  23231. idetinfoStr = psn_info.Idetinfo
  23232. infocode = 0
  23233. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23234. psn_info, _ := service.GetPsnByPatientId(id)
  23235. PsnNo = psn_info.PsnNo
  23236. PsnCertType = psn_info.PsnCertType
  23237. Certno = psn_info.Certno
  23238. PsnName = psn_info.PsnName
  23239. Gend = psn_info.Gend
  23240. Naty = psn_info.Naty
  23241. Brdy = psn_info.Brdy
  23242. Age = psn_info.Age
  23243. infoStr = psn_info.Insuinfo
  23244. idetinfoStr = psn_info.Idetinfo
  23245. infocode = 0
  23246. verify_number = psn_info.VerifyNumber
  23247. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23248. if id_card_type == 2 {
  23249. //请求内网数据
  23250. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23251. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23252. "&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
  23253. resp, requestErr := http.Get(api)
  23254. if requestErr != nil {
  23255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23256. return
  23257. }
  23258. body, ioErr := ioutil.ReadAll(resp.Body)
  23259. if ioErr != nil {
  23260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23262. return
  23263. }
  23264. var respJSON map[string]interface{}
  23265. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23268. return
  23269. }
  23270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23271. result_byte, _ := json.Marshal(respJSON)
  23272. result := string(result_byte)
  23273. var dat map[string]interface{}
  23274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23275. fmt.Println(dat)
  23276. } else {
  23277. fmt.Println(err)
  23278. }
  23279. userJSONBytes, _ := json.Marshal(dat)
  23280. var res ResultTwo
  23281. var resTwo10265 ResultTwo10265
  23282. if miConfig.Code == "H15049901371" {
  23283. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23284. utils.ErrorLog("解析失败:%v", err)
  23285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23286. return
  23287. }
  23288. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23289. res.Infcode = Infcode
  23290. res.ErrMsg = resTwo10265.ErrMsg
  23291. res.Output = resTwo10265.Output
  23292. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23293. res.RespondTime = resTwo10265.RespondTime
  23294. res.WarnInfo = resTwo10265.WarnInfo
  23295. } else {
  23296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23297. utils.ErrorLog("解析失败:%v", err)
  23298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23299. return
  23300. }
  23301. }
  23302. //var insutypes []string
  23303. //var insutype string
  23304. //var is390 int = 0
  23305. //var is310 int = 0
  23306. //for _, item := range res.Output.Iinfo {
  23307. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23308. // insutypes = append(insutypes, item.Insutype)
  23309. // }
  23310. //}
  23311. //if len(insutypes) == 1 {
  23312. // insutype = insutypes[0]
  23313. //} else {
  23314. // for _, i := range insutypes {
  23315. // if i == "390" {
  23316. // is390 = 1
  23317. // }
  23318. //
  23319. // if i == "310" {
  23320. // is310 = 1
  23321. // }
  23322. // }
  23323. //}
  23324. //if is390 == 1 {
  23325. // insutype = "390"
  23326. //}
  23327. //if is310 == 1 {
  23328. // insutype = "310"
  23329. //}
  23330. //if len(insutypes) == 0 {
  23331. // insutype = "310"
  23332. //}
  23333. PsnNo = res.Output.Baseinfo.PsnNo
  23334. PsnCertType = res.Output.Baseinfo.PsnCertType
  23335. Certno = res.Output.Baseinfo.Certno
  23336. PsnName = res.Output.Baseinfo.PsnName
  23337. Gend = res.Output.Baseinfo.Gend
  23338. Naty = res.Output.Baseinfo.Naty
  23339. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23340. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23341. infoStr = string(Iinfos)
  23342. idetinfoStr = string(Idetinfos)
  23343. infocode = res.Infcode
  23344. //infocode = 0
  23345. //verify_number = psn_info.VerifyNumber
  23346. } else {
  23347. psn_info, _ := service.GetPsnByPatientId(id)
  23348. PsnNo = psn_info.PsnNo
  23349. PsnCertType = psn_info.PsnCertType
  23350. Certno = psn_info.Certno
  23351. PsnName = psn_info.PsnName
  23352. Gend = psn_info.Gend
  23353. Naty = psn_info.Naty
  23354. Brdy = psn_info.Brdy
  23355. Age = psn_info.Age
  23356. infoStr = psn_info.Insuinfo
  23357. idetinfoStr = psn_info.Idetinfo
  23358. infocode = 0
  23359. verify_number = psn_info.VerifyNumber
  23360. }
  23361. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23362. if id_card_type == 1 {
  23363. psn_info, _ := service.GetPsnByPatientId(id)
  23364. PsnNo = psn_info.PsnNo
  23365. PsnCertType = psn_info.PsnCertType
  23366. Certno = psn_info.Certno
  23367. PsnName = psn_info.PsnName
  23368. Gend = psn_info.Gend
  23369. Naty = psn_info.Naty
  23370. Brdy = psn_info.Brdy
  23371. Age = psn_info.Age
  23372. infoStr = psn_info.Insuinfo
  23373. idetinfoStr = psn_info.Idetinfo
  23374. infocode = 0
  23375. verify_number = psn_info.VerifyNumber
  23376. } else if id_card_type == 2 {
  23377. 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)
  23378. fmt.Println(errMsgLog)
  23379. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23380. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23381. utils.ErrorLog("解析失败:%v", err)
  23382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23383. return
  23384. }
  23385. PsnNo = res.Output.Baseinfo.PsnNo
  23386. PsnCertType = res.Output.Baseinfo.PsnCertType
  23387. Certno = res.Output.Baseinfo.Certno
  23388. PsnName = res.Output.Baseinfo.PsnName
  23389. Gend = res.Output.Baseinfo.Gend
  23390. Naty = res.Output.Baseinfo.Naty
  23391. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23392. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23393. infoStr = string(Iinfos)
  23394. idetinfoStr = string(Idetinfos)
  23395. infocode = res.Infcode
  23396. }
  23397. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23398. if id_card_type == 1 {
  23399. psn_info, _ := service.GetPsnByPatientId(id)
  23400. PsnNo = psn_info.PsnNo
  23401. PsnCertType = psn_info.PsnCertType
  23402. Certno = psn_info.Certno
  23403. PsnName = psn_info.PsnName
  23404. Gend = psn_info.Gend
  23405. Naty = psn_info.Naty
  23406. Brdy = psn_info.Brdy
  23407. Age = psn_info.Age
  23408. infoStr = psn_info.Insuinfo
  23409. idetinfoStr = psn_info.Idetinfo
  23410. infocode = 0
  23411. verify_number = psn_info.VerifyNumber
  23412. } else if id_card_type == 2 {
  23413. 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, "")
  23414. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23415. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23416. utils.ErrorLog("解析失败:%v", err)
  23417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23418. return
  23419. }
  23420. PsnNo = res.Output.Baseinfo.PsnNo
  23421. PsnCertType = res.Output.Baseinfo.PsnCertType
  23422. Certno = res.Output.Baseinfo.Certno
  23423. PsnName = res.Output.Baseinfo.PsnName
  23424. Gend = res.Output.Baseinfo.Gend
  23425. Naty = res.Output.Baseinfo.Naty
  23426. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23427. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23428. infoStr = string(Iinfos)
  23429. idetinfoStr = string(Idetinfos)
  23430. infocode = res.Infcode
  23431. } else {
  23432. psn_info, _ := service.GetPsnByPatientId(id)
  23433. PsnNo = psn_info.PsnNo
  23434. PsnCertType = psn_info.PsnCertType
  23435. Certno = psn_info.Certno
  23436. PsnName = psn_info.PsnName
  23437. Gend = psn_info.Gend
  23438. Naty = psn_info.Naty
  23439. Brdy = psn_info.Brdy
  23440. Age = psn_info.Age
  23441. infoStr = psn_info.Insuinfo
  23442. idetinfoStr = psn_info.Idetinfo
  23443. infocode = 0
  23444. verify_number = psn_info.VerifyNumber
  23445. }
  23446. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23447. if id_card_type == 1 {
  23448. psn_info, _ := service.GetPsnByPatientId(id)
  23449. PsnNo = psn_info.PsnNo
  23450. PsnCertType = psn_info.PsnCertType
  23451. Certno = psn_info.Certno
  23452. PsnName = psn_info.PsnName
  23453. Gend = psn_info.Gend
  23454. Naty = psn_info.Naty
  23455. Brdy = psn_info.Brdy
  23456. Age = psn_info.Age
  23457. infoStr = psn_info.Insuinfo
  23458. idetinfoStr = psn_info.Idetinfo
  23459. infocode = 0
  23460. verify_number = psn_info.VerifyNumber
  23461. } else if id_card_type == 2 {
  23462. psn_info, _ := service.GetPsnByPatientId(id)
  23463. PsnNo = psn_info.PsnNo
  23464. PsnCertType = psn_info.PsnCertType
  23465. Certno = psn_info.Certno
  23466. PsnName = psn_info.PsnName
  23467. Gend = psn_info.Gend
  23468. Naty = psn_info.Naty
  23469. Brdy = psn_info.Brdy
  23470. Age = psn_info.Age
  23471. infoStr = psn_info.Insuinfo
  23472. idetinfoStr = psn_info.Idetinfo
  23473. infocode = 0
  23474. verify_number = psn_info.VerifyNumber
  23475. } else {
  23476. psn_info, _ := service.GetPsnByPatientId(id)
  23477. PsnNo = psn_info.PsnNo
  23478. PsnCertType = psn_info.PsnCertType
  23479. Certno = psn_info.Certno
  23480. PsnName = psn_info.PsnName
  23481. Gend = psn_info.Gend
  23482. Naty = psn_info.Naty
  23483. Brdy = psn_info.Brdy
  23484. Age = psn_info.Age
  23485. infoStr = psn_info.Insuinfo
  23486. idetinfoStr = psn_info.Idetinfo
  23487. infocode = 0
  23488. verify_number = psn_info.VerifyNumber
  23489. }
  23490. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23491. psn_info, _ := service.GetPsnByPatientId(id)
  23492. PsnNo = psn_info.PsnNo
  23493. PsnCertType = psn_info.PsnCertType
  23494. Certno = psn_info.Certno
  23495. PsnName = psn_info.PsnName
  23496. Gend = psn_info.Gend
  23497. Naty = psn_info.Naty
  23498. Brdy = psn_info.Brdy
  23499. Age = psn_info.Age
  23500. infoStr = psn_info.Insuinfo
  23501. idetinfoStr = psn_info.Idetinfo
  23502. infocode = 0
  23503. verify_number = psn_info.VerifyNumber
  23504. idetinfoStr = psn_info.Idetinfo
  23505. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23506. if id_card_type == 1 {
  23507. psn_info, _ := service.GetPsnByPatientId(id)
  23508. PsnNo = psn_info.PsnNo
  23509. PsnCertType = psn_info.PsnCertType
  23510. Certno = psn_info.Certno
  23511. PsnName = psn_info.PsnName
  23512. Gend = psn_info.Gend
  23513. Naty = psn_info.Naty
  23514. Brdy = psn_info.Brdy
  23515. Age = psn_info.Age
  23516. infoStr = psn_info.Insuinfo
  23517. idetinfoStr = psn_info.Idetinfo
  23518. infocode = 0
  23519. verify_number = psn_info.VerifyNumber
  23520. } else if id_card_type == 2 {
  23521. 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)
  23522. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23524. utils.ErrorLog("解析失败:%v", err)
  23525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23526. return
  23527. }
  23528. PsnNo = res.Output.Baseinfo.PsnNo
  23529. PsnCertType = res.Output.Baseinfo.PsnCertType
  23530. Certno = res.Output.Baseinfo.Certno
  23531. PsnName = res.Output.Baseinfo.PsnName
  23532. Gend = res.Output.Baseinfo.Gend
  23533. Naty = res.Output.Baseinfo.Naty
  23534. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23535. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23536. infoStr = string(Iinfos)
  23537. idetinfoStr = string(Idetinfos)
  23538. infocode = res.Infcode
  23539. } else if id_card_type == 4 {
  23540. psn_info, _ := service.GetPsnByPatientId(id)
  23541. PsnNo = psn_info.PsnNo
  23542. PsnCertType = psn_info.PsnCertType
  23543. Certno = psn_info.Certno
  23544. PsnName = psn_info.PsnName
  23545. Gend = psn_info.Gend
  23546. Naty = psn_info.Naty
  23547. Brdy = psn_info.Brdy
  23548. Age = psn_info.Age
  23549. infoStr = psn_info.Insuinfo
  23550. idetinfoStr = psn_info.Idetinfo
  23551. infocode = 0
  23552. verify_number = psn_info.VerifyNumber
  23553. }
  23554. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23555. var result string
  23556. var requestLog string
  23557. 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), "")
  23558. if id_card_type == 4 {
  23559. psn_info, _ := service.GetPsnByPatientId(id)
  23560. PsnNo = psn_info.PsnNo
  23561. PsnCertType = psn_info.PsnCertType
  23562. Certno = psn_info.Certno
  23563. PsnName = psn_info.PsnName
  23564. Gend = psn_info.Gend
  23565. Naty = psn_info.Naty
  23566. Brdy = psn_info.Brdy
  23567. Age = psn_info.Age
  23568. infoStr = psn_info.Insuinfo
  23569. idetinfoStr = psn_info.Idetinfo
  23570. infocode = 0
  23571. verify_number = psn_info.VerifyNumber
  23572. } else {
  23573. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23574. if miConfig.Code == "H15049901371" {
  23575. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23576. utils.ErrorLog("解析失败:%v", err)
  23577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23578. return
  23579. }
  23580. res.ErrMsg = res10265.ErrMsg
  23581. res.Output = res10265.Output
  23582. res.InfRefmsgid = res10265.InfRefmsgid
  23583. } else {
  23584. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23585. utils.ErrorLog("解析失败:%v", err)
  23586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23587. return
  23588. }
  23589. }
  23590. PsnNo = res.Output.Baseinfo.PsnNo
  23591. PsnCertType = res.Output.Baseinfo.PsnCertType
  23592. Certno = res.Output.Baseinfo.Certno
  23593. PsnName = res.Output.Baseinfo.PsnName
  23594. Gend = res.Output.Baseinfo.Gend
  23595. Naty = res.Output.Baseinfo.Naty
  23596. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23597. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23598. infoStr = string(Iinfos)
  23599. idetinfoStr = string(Idetinfos)
  23600. if miConfig.Code == "H15049901371" {
  23601. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23602. } else {
  23603. infocode = res.Infcode
  23604. }
  23605. }
  23606. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23607. psn_info, _ := service.GetPsnByPatientId(id)
  23608. PsnNo = psn_info.PsnNo
  23609. PsnCertType = psn_info.PsnCertType
  23610. Certno = psn_info.Certno
  23611. PsnName = psn_info.PsnName
  23612. Gend = psn_info.Gend
  23613. Naty = psn_info.Naty
  23614. Brdy = psn_info.Brdy
  23615. Age = psn_info.Age
  23616. infoStr = psn_info.Insuinfo
  23617. idetinfoStr = psn_info.Idetinfo
  23618. infocode = 0
  23619. verify_number = psn_info.VerifyNumber
  23620. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23621. psn_info, _ := service.GetPsnByPatientId(id)
  23622. PsnNo = psn_info.PsnNo
  23623. PsnCertType = psn_info.PsnCertType
  23624. Certno = psn_info.Certno
  23625. PsnName = psn_info.PsnName
  23626. Gend = psn_info.Gend
  23627. Naty = psn_info.Naty
  23628. Brdy = psn_info.Brdy
  23629. Age = psn_info.Age
  23630. infoStr = psn_info.Insuinfo
  23631. idetinfoStr = psn_info.Idetinfo
  23632. infocode = 0
  23633. verify_number = psn_info.VerifyNumber
  23634. } else {
  23635. var result string
  23636. var requestLog string
  23637. //if miConfig.UserOrgId == 10138 {
  23638. if id_card_type != 4 || id_card_type != 1 {
  23639. var insa string
  23640. if len(patient.InsuplcAdmdvs) > 0 {
  23641. insa = patient.InsuplcAdmdvs
  23642. } else {
  23643. insa = miConfig.InsuplcAdmdvs
  23644. }
  23645. //psn_info, _ := service.GetPsnByPatientId(id)
  23646. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23647. 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)
  23648. }
  23649. //}
  23650. //else {
  23651. // var insa string
  23652. // if len(patient.InsuplcAdmdvs) > 0 {
  23653. // insa = patient.InsuplcAdmdvs
  23654. // } else {
  23655. // insa = miConfig.InsuplcAdmdvs
  23656. // }
  23657. // 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)
  23658. //}
  23659. if id_card_type == 4 || id_card_type == 1 {
  23660. psn_info, _ := service.GetPsnByPatientId(id)
  23661. PsnNo = psn_info.PsnNo
  23662. PsnCertType = psn_info.PsnCertType
  23663. Certno = psn_info.Certno
  23664. PsnName = psn_info.PsnName
  23665. Gend = psn_info.Gend
  23666. Naty = psn_info.Naty
  23667. Brdy = psn_info.Brdy
  23668. Age = psn_info.Age
  23669. infoStr = psn_info.Insuinfo
  23670. idetinfoStr = psn_info.Idetinfo
  23671. infocode = 0
  23672. verify_number = psn_info.VerifyNumber
  23673. } else {
  23674. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23675. if miConfig.Code == "H15049901371" {
  23676. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23677. utils.ErrorLog("解析失败:%v", err)
  23678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23679. return
  23680. }
  23681. res.ErrMsg = res10265.ErrMsg
  23682. res.Output = res10265.Output
  23683. res.InfRefmsgid = res10265.InfRefmsgid
  23684. } else {
  23685. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23686. utils.ErrorLog("解析失败:%v", err)
  23687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23688. return
  23689. }
  23690. }
  23691. PsnNo = res.Output.Baseinfo.PsnNo
  23692. PsnCertType = res.Output.Baseinfo.PsnCertType
  23693. Certno = res.Output.Baseinfo.Certno
  23694. PsnName = res.Output.Baseinfo.PsnName
  23695. Gend = res.Output.Baseinfo.Gend
  23696. Naty = res.Output.Baseinfo.Naty
  23697. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23698. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23699. infoStr = string(Iinfos)
  23700. idetinfoStr = string(Idetinfos)
  23701. if miConfig.Code == "H15049901371" {
  23702. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23703. } else {
  23704. infocode = res.Infcode
  23705. }
  23706. }
  23707. }
  23708. if infocode == 0 {
  23709. his := models.VMHisPatient{
  23710. Name: name,
  23711. Gender: gender,
  23712. Birthday: birthUnix,
  23713. MedicalTreatmentType: medical_care,
  23714. IdType: certificates,
  23715. IdCardNo: id_card,
  23716. BalanceAccountsType: settlementValue,
  23717. SocialType: social_type,
  23718. MedicalInsuranceNumber: medical_insurance_card,
  23719. RegisterType: register_type,
  23720. RegisterCost: registration_fee,
  23721. TreatmentCost: medical_expenses,
  23722. Status: 1,
  23723. Ctime: time.Now().Unix(),
  23724. Mtime: time.Now().Unix(),
  23725. PsnNo: PsnNo,
  23726. PsnCertType: PsnCertType,
  23727. Certno: Certno,
  23728. PsnName: PsnName,
  23729. Gend: Gend,
  23730. Naty: Naty,
  23731. Brdy: Brdy,
  23732. Age: Age,
  23733. Iinfo: infoStr,
  23734. Idetinfo: idetinfoStr,
  23735. PatientId: patient.ID,
  23736. RecordDate: theTime.Unix(),
  23737. UserOrgId: adminInfo.CurrentOrgId,
  23738. AdminUserId: admin_user_id,
  23739. IsReturn: 1,
  23740. IdCardType: id_card_type,
  23741. Doctor: doctor,
  23742. Departments: department,
  23743. MdtrtGrpType: mdtrt_type,
  23744. }
  23745. timestamp := time.Now().Unix()
  23746. tempTime := time.Unix(timestamp, 0)
  23747. timeFormat := tempTime.Format("20060102150405")
  23748. chrgBchno := rand.Intn(100000) + 10000
  23749. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23750. his.Number = ipt_otp_no
  23751. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23752. department, _ := service.GetDepartMentDetail(department)
  23753. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23754. IdCardNo := ""
  23755. if id_card_type == 1 {
  23756. // IdCardNo = medical_insurance_card
  23757. IdCardNo = patient.IdCardNo
  23758. } else {
  23759. IdCardNo = patient.IdCardNo
  23760. }
  23761. var rf []*ResultFive
  23762. json.Unmarshal([]byte(his.Iinfo), &rf)
  23763. var insutypes []*ResultFive
  23764. var insutype string
  23765. var insuplc_admdvs_temp string
  23766. var is390 int = 0
  23767. var is310 int = 0
  23768. for _, item := range rf {
  23769. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23770. insutypes = append(insutypes, item)
  23771. }
  23772. }
  23773. if len(insutypes) == 1 {
  23774. insutype = insutypes[0].Insutype
  23775. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23776. if insutype == "390" {
  23777. is390 = 1
  23778. }
  23779. if insutype == "310" {
  23780. is310 = 1
  23781. }
  23782. } else {
  23783. for _, i := range insutypes {
  23784. if i.Insutype == "390" {
  23785. is390 = 1
  23786. }
  23787. if i.Insutype == "310" {
  23788. is310 = 1
  23789. }
  23790. }
  23791. }
  23792. if is390 == 1 {
  23793. insutype = "390"
  23794. }
  23795. if is310 == 1 {
  23796. insutype = "310"
  23797. }
  23798. fmt.Println(social_type)
  23799. if social_type > 0 {
  23800. insutype = strconv.FormatInt(social_type, 10)
  23801. }
  23802. var infocode int64
  23803. var resThree ResultThree
  23804. var resThree10265 ResultThree10265
  23805. if len(insuplc_admdvs) == 0 {
  23806. psn_info, _ := service.GetPsnByPatientId(id)
  23807. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23808. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23809. //}
  23810. } else {
  23811. insuplc_admdvs_temp = insuplc_admdvs
  23812. }
  23813. if miConfig.MdtrtareaAdmvs == "421300" {
  23814. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23815. psn_info, _ := service.GetPsnByPatientId(id)
  23816. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23817. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23818. "&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
  23819. resp, requestErr := http.Get(api)
  23820. if requestErr != nil {
  23821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23822. return
  23823. }
  23824. body, ioErr := ioutil.ReadAll(resp.Body)
  23825. if ioErr != nil {
  23826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23828. return
  23829. }
  23830. var respJSON map[string]interface{}
  23831. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23834. return
  23835. }
  23836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23837. result, _ := json.Marshal(respJSON)
  23838. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23839. utils.ErrorLog("解析失败:%v", err)
  23840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23841. return
  23842. }
  23843. infocode = resThree.Infcode
  23844. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23845. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23846. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23847. // insuplc_admdvs_temp =
  23848. //}
  23849. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23850. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23851. //}
  23852. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23853. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23854. "&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
  23855. resp, requestErr := http.Get(api)
  23856. if requestErr != nil {
  23857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23858. return
  23859. }
  23860. body, ioErr := ioutil.ReadAll(resp.Body)
  23861. if ioErr != nil {
  23862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23864. return
  23865. }
  23866. var respJSON map[string]interface{}
  23867. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23870. return
  23871. }
  23872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23873. result, _ := json.Marshal(respJSON)
  23874. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23875. utils.ErrorLog("解析失败:%v", err)
  23876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23877. return
  23878. }
  23879. infocode = resThree.Infcode
  23880. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23881. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23882. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23883. // insuplc_admdvs_temp =
  23884. //}
  23885. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23886. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23887. //}
  23888. utils.ErrorLog("解析失败:%v", insutype)
  23889. utils.ErrorLog("解析失败:%v", PsnNo)
  23890. utils.ErrorLog("解析失败:%v", Certno)
  23891. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23892. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23893. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23894. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23895. utils.ErrorLog("解析失败:%v", PsnNo)
  23896. utils.ErrorLog("解析失败:%v", department.Number)
  23897. utils.ErrorLog("解析失败:%v", department.Name)
  23898. utils.ErrorLog("解析失败:%v", roles.UserName)
  23899. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23900. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23901. "&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
  23902. resp, requestErr := http.Get(api)
  23903. if requestErr != nil {
  23904. utils.ErrorLog("解析失败:%v", requestErr)
  23905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23906. return
  23907. }
  23908. body, ioErr := ioutil.ReadAll(resp.Body)
  23909. if ioErr != nil {
  23910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23912. return
  23913. }
  23914. var respJSON map[string]interface{}
  23915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23918. return
  23919. }
  23920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23921. result, _ := json.Marshal(respJSON)
  23922. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23923. utils.ErrorLog("解析失败:%v", err)
  23924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23925. return
  23926. }
  23927. infocode = resThree.Infcode
  23928. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23929. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23930. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23931. // insuplc_admdvs_temp =
  23932. //}
  23933. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23934. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23935. //}
  23936. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23937. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23938. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  23939. resp, requestErr := http.Get(api)
  23940. if requestErr != nil {
  23941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23942. return
  23943. }
  23944. body, ioErr := ioutil.ReadAll(resp.Body)
  23945. if ioErr != nil {
  23946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23948. return
  23949. }
  23950. var respJSON map[string]interface{}
  23951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23954. return
  23955. }
  23956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23957. result, _ := json.Marshal(respJSON)
  23958. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23959. utils.ErrorLog("解析失败:%v", err)
  23960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23961. return
  23962. }
  23963. infocode = resThree.Infcode
  23964. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23965. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23966. psn_info, _ := service.GetPsnByPatientId(id)
  23967. var verify_number string
  23968. if id_card_type == 4 {
  23969. verify_number = psn_info.VerifyNumber
  23970. } else if id_card_type == 1 {
  23971. bas := strings.Split(psn_info.CardInfo, "|")
  23972. cardNumber := bas[2]
  23973. verify_number = cardNumber
  23974. }
  23975. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23976. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23977. "&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
  23978. resp, requestErr := http.Get(api)
  23979. if requestErr != nil {
  23980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23981. return
  23982. }
  23983. body, ioErr := ioutil.ReadAll(resp.Body)
  23984. if ioErr != nil {
  23985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23987. return
  23988. }
  23989. var respJSON map[string]interface{}
  23990. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23993. return
  23994. }
  23995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23996. result, _ := json.Marshal(respJSON)
  23997. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23998. // utils.ErrorLog("解析失败:%v", err)
  23999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. // return
  24001. //}
  24002. //infocode = resThree.Infcode
  24003. //result, _ := json.Marshal(respJSON)
  24004. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24005. utils.ErrorLog("解析失败:%v", err)
  24006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24007. return
  24008. }
  24009. resThree.ErrMsg = resThree10265.ErrMsg
  24010. resThree.Output = resThree10265.Output
  24011. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24012. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24013. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24014. psn_info, _ := service.GetPsnByPatientId(id)
  24015. his.PsnNo = psn_info.PsnNo
  24016. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24017. var cert_no string
  24018. if id_card_type == 3 {
  24019. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24020. cert_no = IdCardNo
  24021. } else if id_card_type == 4 {
  24022. cert_no = IdCardNo
  24023. psn_info.VerifyNumber = psn_info.VerifyNumber
  24024. } else {
  24025. bas := strings.Split(psn_info.CardInfo, "|")
  24026. cert_no = bas[2]
  24027. }
  24028. var hisPrescription []*models.HisPrescription
  24029. for _, item := range rf {
  24030. if item.Insutype == insutype {
  24031. //insuplc_admdvs = item.InsuplcAdmdvs
  24032. his.InsuplcAdmdvs = insuplc_admdvs
  24033. }
  24034. }
  24035. his.Insutype = insutype
  24036. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24037. fmt.Println(res3101)
  24038. fmt.Println(res3101.Infcode)
  24039. if res3101.Infcode == "0" {
  24040. fmt.Println("33333333")
  24041. if len(res3101.Output.Result) > 0 {
  24042. fmt.Println("222222")
  24043. for _, item := range res3101.Output.Result {
  24044. if len(res3101.ErrMsg) == 0 {
  24045. res3101.ErrMsg = item.VolaCont
  24046. } else {
  24047. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24048. }
  24049. }
  24050. c.ServeSuccessJSON(map[string]interface{}{
  24051. "failed_code": -10,
  24052. "msg": res3101.ErrMsg,
  24053. })
  24054. return
  24055. } else {
  24056. fmt.Println("11111")
  24057. var api string
  24058. if miConfig.MdtrtareaAdmvs == "320921" {
  24059. ipt_otp_no = timeFormat
  24060. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24061. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24062. "&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
  24063. } else {
  24064. ipt_otp_no = timeFormat
  24065. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24066. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24067. "&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
  24068. }
  24069. resp, requestErr := http.Get(api)
  24070. if requestErr != nil {
  24071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24072. return
  24073. }
  24074. body, ioErr := ioutil.ReadAll(resp.Body)
  24075. if ioErr != nil {
  24076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24078. return
  24079. }
  24080. var respJSON map[string]interface{}
  24081. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24084. return
  24085. }
  24086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24087. result, _ := json.Marshal(respJSON)
  24088. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24089. utils.ErrorLog("解析失败:%v", err)
  24090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24091. return
  24092. }
  24093. resThree.ErrMsg = resThree10265.ErrMsg
  24094. resThree.Output = resThree10265.Output
  24095. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24096. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24097. }
  24098. } else if res3101.Infcode != "0" {
  24099. c.ServeSuccessJSON(map[string]interface{}{
  24100. "failed_code": -10,
  24101. "msg": res3101.ErrMsg,
  24102. })
  24103. return
  24104. }
  24105. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24106. psn_info, _ := service.GetPsnByPatientId(id)
  24107. var cert_no string
  24108. if id_card_type == 1 {
  24109. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24110. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24111. } else if id_card_type == 4 {
  24112. cert_no = psn_info.VerifyNumber
  24113. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24114. } else {
  24115. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24116. cert_no = psn_info.VerifyNumber
  24117. }
  24118. 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)
  24119. saveLog(result, requestLog, "2201", "挂号")
  24120. if miConfig.Code == "H15049901371" {
  24121. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24122. utils.ErrorLog("解析失败:%v", err)
  24123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24124. return
  24125. }
  24126. resThree.ErrMsg = resThree10265.ErrMsg
  24127. resThree.Output = resThree10265.Output
  24128. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24129. } else {
  24130. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24131. utils.ErrorLog("解析失败:%v", err)
  24132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24133. return
  24134. }
  24135. }
  24136. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24137. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24138. psn_info, _ := service.GetPsnByPatientId(id)
  24139. var result string
  24140. var requestLog string
  24141. if id_card_type == 1 {
  24142. bas := strings.Split(psn_info.CardInfo, "|")
  24143. basNumber := bas[2]
  24144. card_sn := bas[3]
  24145. 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)
  24146. saveLog(result, requestLog, "2201A", "挂号")
  24147. } else if id_card_type == 2 {
  24148. 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, "", "", "", "", "", "")
  24149. saveLog(result, requestLog, "2201A", "挂号")
  24150. } else {
  24151. 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)
  24152. saveLog(result, requestLog, "2201A", "挂号")
  24153. }
  24154. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24155. utils.ErrorLog("解析失败:%v", err)
  24156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24157. return
  24158. }
  24159. infocode = resThree.Infcode
  24160. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24161. psn_info, _ := service.GetPsnByPatientId(id)
  24162. var result string
  24163. var requestLog string
  24164. if id_card_type == 1 {
  24165. bas := strings.Split(psn_info.CardInfo, "|")
  24166. basNumber := bas[2]
  24167. card_sn := ""
  24168. 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)
  24169. saveLog(result, requestLog, "2201A", "挂号")
  24170. } else if id_card_type == 2 {
  24171. 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, "", "", "", "", "", "")
  24172. saveLog(result, requestLog, "2201A", "挂号")
  24173. } else {
  24174. 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)
  24175. saveLog(result, requestLog, "2201A", "挂号")
  24176. }
  24177. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24178. utils.ErrorLog("解析失败:%v", err)
  24179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24180. return
  24181. }
  24182. infocode = resThree.Infcode
  24183. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24184. psn_info, _ := service.GetPsnByPatientId(id)
  24185. his.PsnNo = psn_info.PsnNo
  24186. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24187. var cert_no string
  24188. if id_card_type == 1 {
  24189. bas := strings.Split(psn_info.CardInfo, "|")
  24190. cert_no = bas[2]
  24191. } else if id_card_type == 4 {
  24192. cert_no = psn_info.VerifyNumber
  24193. psn_info.VerifyNumber = psn_info.VerifyNumber
  24194. IdCardNo = psn_info.VerifyNumber
  24195. } else {
  24196. cert_no = IdCardNo
  24197. psn_info.VerifyNumber = cert_no
  24198. }
  24199. for _, item := range rf {
  24200. if item.Insutype == insutype {
  24201. his.InsuplcAdmdvs = insuplc_admdvs
  24202. }
  24203. }
  24204. his.Insutype = insutype
  24205. var api string
  24206. ipt_otp_no = timeFormat
  24207. 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 +
  24208. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24209. "&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
  24210. resp, requestErr := http.Get(api)
  24211. if requestErr != nil {
  24212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24213. return
  24214. }
  24215. body, ioErr := ioutil.ReadAll(resp.Body)
  24216. if ioErr != nil {
  24217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24219. return
  24220. }
  24221. var respJSON map[string]interface{}
  24222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24225. return
  24226. }
  24227. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24228. if status == "0" {
  24229. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24230. c.ServeSuccessJSON(map[string]interface{}{
  24231. "failed_code": -10,
  24232. "msg": err_msg,
  24233. })
  24234. return
  24235. }
  24236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24237. result, _ := json.Marshal(respJSON)
  24238. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24239. utils.ErrorLog("解析失败:%v", err)
  24240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24241. return
  24242. }
  24243. infocode = resThree.Infcode
  24244. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24245. psn_info, _ := service.GetPsnByPatientId(id)
  24246. his.PsnNo = psn_info.PsnNo
  24247. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24248. var cert_no string
  24249. if id_card_type == 1 {
  24250. bas := strings.Split(psn_info.CardInfo, "|")
  24251. cert_no = bas[2]
  24252. } else if id_card_type == 4 {
  24253. cert_no = psn_info.VerifyNumber
  24254. psn_info.VerifyNumber = psn_info.VerifyNumber
  24255. IdCardNo = psn_info.VerifyNumber
  24256. } else {
  24257. cert_no = IdCardNo
  24258. psn_info.VerifyNumber = cert_no
  24259. }
  24260. for _, item := range rf {
  24261. if item.Insutype == insutype {
  24262. his.InsuplcAdmdvs = insuplc_admdvs
  24263. patient.InsuplcAdmdvs = insuplc_admdvs
  24264. }
  24265. }
  24266. his.Insutype = insutype
  24267. var api string
  24268. ipt_otp_no = timeFormat
  24269. 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 +
  24270. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24271. "&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
  24272. resp, requestErr := http.Get(api)
  24273. if requestErr != nil {
  24274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24275. return
  24276. }
  24277. body, ioErr := ioutil.ReadAll(resp.Body)
  24278. if ioErr != nil {
  24279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24281. return
  24282. }
  24283. var respJSON map[string]interface{}
  24284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24287. return
  24288. }
  24289. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24290. if status == "0" {
  24291. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24292. c.ServeSuccessJSON(map[string]interface{}{
  24293. "failed_code": -10,
  24294. "msg": err_msg,
  24295. })
  24296. return
  24297. }
  24298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24299. result, _ := json.Marshal(respJSON)
  24300. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24301. utils.ErrorLog("解析失败:%v", err)
  24302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24303. return
  24304. }
  24305. infocode = resThree.Infcode
  24306. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24307. psn_info, _ := service.GetPsnByPatientId(id)
  24308. var result string
  24309. var requestLog string
  24310. if id_card_type == 1 {
  24311. bas := strings.Split(psn_info.CardInfo, "|")
  24312. basNumber := bas[2]
  24313. card_sn := bas[3]
  24314. 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)
  24315. saveLog(result, requestLog, "2201A", "挂号")
  24316. } else if id_card_type == 2 {
  24317. 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, "", "")
  24318. saveLog(result, requestLog, "2201A", "挂号")
  24319. } else {
  24320. 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, "", "")
  24321. saveLog(result, requestLog, "2201A", "挂号")
  24322. }
  24323. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24324. utils.ErrorLog("解析失败:%v", err)
  24325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24326. return
  24327. }
  24328. infocode = resThree.Infcode
  24329. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24330. psn_info, _ := service.GetPsnByPatientId(id)
  24331. 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)
  24332. saveLog(result, requestLog, "2201A", "挂号")
  24333. if miConfig.Code == "H15049901371" {
  24334. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24335. utils.ErrorLog("解析失败:%v", err)
  24336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24337. return
  24338. }
  24339. resThree.ErrMsg = resThree10265.ErrMsg
  24340. resThree.Output = resThree10265.Output
  24341. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24342. } else {
  24343. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24344. utils.ErrorLog("解析失败:%v", err)
  24345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24346. return
  24347. }
  24348. }
  24349. if miConfig.Code == "H15049901371" {
  24350. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24351. } else {
  24352. infocode = resThree.Infcode
  24353. }
  24354. } else {
  24355. psn_info, _ := service.GetPsnByPatientId(id)
  24356. if id_card_type == 4 || id_card_type == 1 {
  24357. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24358. }
  24359. var rf []*ResultFive
  24360. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24361. var insutypes []*ResultFive
  24362. var insutype string
  24363. var is390 int = 0
  24364. var is310 int = 0
  24365. for _, item := range rf {
  24366. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24367. insutypes = append(insutypes, item)
  24368. }
  24369. }
  24370. if len(insutypes) == 1 {
  24371. insutype = insutypes[0].Insutype
  24372. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24373. } else {
  24374. for _, i := range insutypes {
  24375. if i.Insutype == "390" {
  24376. is390 = 1
  24377. }
  24378. if i.Insutype == "310" {
  24379. is310 = 1
  24380. }
  24381. }
  24382. }
  24383. if is390 == 1 {
  24384. insutype = "390"
  24385. }
  24386. if is310 == 1 {
  24387. insutype = "310"
  24388. }
  24389. fmt.Println(len(insutypes))
  24390. if len(insutypes) == 0 {
  24391. for index, item := range rf {
  24392. if index == 0 {
  24393. insutype = item.Insutype
  24394. insuplc_admdvs = item.InsuplcAdmdvs
  24395. }
  24396. }
  24397. fmt.Println(insutype)
  24398. fmt.Println(insuplc_admdvs)
  24399. }
  24400. if social_type > 0 {
  24401. insutype = strconv.FormatInt(social_type, 10)
  24402. }
  24403. fmt.Println("--------")
  24404. fmt.Println(psn_info)
  24405. fmt.Println(psn_info.PsnNo)
  24406. if miConfig.MdtrtareaAdmvs == "441202" {
  24407. var hisPrescription []*models.HisPrescription
  24408. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24409. if res3101.Infcode == 0 {
  24410. fmt.Println("33333333")
  24411. if len(res3101.Output.Result) > 0 {
  24412. fmt.Println("222222")
  24413. for _, item := range res3101.Output.Result {
  24414. if len(res3101.ErrMsg) == 0 {
  24415. res3101.ErrMsg = item.VolaCont
  24416. } else {
  24417. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24418. }
  24419. }
  24420. c.ServeSuccessJSON(map[string]interface{}{
  24421. "failed_code": -10,
  24422. "msg": res3101.ErrMsg,
  24423. })
  24424. return
  24425. } else {
  24426. hour := time.Now().Format("15")
  24427. min := time.Now().Format("04")
  24428. sec := time.Now().Format("05")
  24429. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24430. fmt.Println(record_time_two)
  24431. 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)
  24432. saveLog(result, requestLog, "2201A", "挂号")
  24433. if miConfig.Code == "H15049901371" {
  24434. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24435. utils.ErrorLog("解析失败:%v", err)
  24436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24437. return
  24438. }
  24439. resThree.ErrMsg = resThree10265.ErrMsg
  24440. resThree.Output = resThree10265.Output
  24441. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24442. } else {
  24443. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24444. utils.ErrorLog("解析失败:%v", err)
  24445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24446. return
  24447. }
  24448. }
  24449. if miConfig.Code == "H15049901371" {
  24450. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24451. } else {
  24452. infocode = resThree.Infcode
  24453. }
  24454. }
  24455. } else if res3101.Infcode != 0 {
  24456. c.ServeSuccessJSON(map[string]interface{}{
  24457. "failed_code": -10,
  24458. "msg": res3101.ErrMsg,
  24459. })
  24460. return
  24461. }
  24462. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24463. var hisPrescription []*models.HisPrescription
  24464. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24465. if res3101.Infcode == 0 {
  24466. fmt.Println("33333333")
  24467. if len(res3101.Output.Result) > 0 {
  24468. fmt.Println("222222")
  24469. for _, item := range res3101.Output.Result {
  24470. if len(res3101.ErrMsg) == 0 {
  24471. res3101.ErrMsg = item.VolaCont
  24472. } else {
  24473. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24474. }
  24475. }
  24476. c.ServeSuccessJSON(map[string]interface{}{
  24477. "failed_code": -10,
  24478. "msg": res3101.ErrMsg,
  24479. })
  24480. return
  24481. } else {
  24482. hour := time.Now().Format("15")
  24483. min := time.Now().Format("04")
  24484. sec := time.Now().Format("05")
  24485. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24486. fmt.Println(record_time_two)
  24487. 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)
  24488. saveLog(result, requestLog, "2201A", "挂号")
  24489. if miConfig.Code == "H15049901371" {
  24490. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24491. utils.ErrorLog("解析失败:%v", err)
  24492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24493. return
  24494. }
  24495. resThree.ErrMsg = resThree10265.ErrMsg
  24496. resThree.Output = resThree10265.Output
  24497. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24498. } else {
  24499. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24500. utils.ErrorLog("解析失败:%v", err)
  24501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24502. return
  24503. }
  24504. }
  24505. if miConfig.Code == "H15049901371" {
  24506. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24507. } else {
  24508. infocode = resThree.Infcode
  24509. }
  24510. }
  24511. } else if res3101.Infcode != 0 {
  24512. c.ServeSuccessJSON(map[string]interface{}{
  24513. "failed_code": -10,
  24514. "msg": res3101.ErrMsg,
  24515. })
  24516. return
  24517. }
  24518. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24519. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24520. psn_info, _ := service.GetPsnByPatientId(id)
  24521. var verify_number string
  24522. if id_card_type == 4 {
  24523. verify_number = psn_info.VerifyNumber
  24524. } else if id_card_type == 1 {
  24525. bas := strings.Split(psn_info.CardInfo, "|")
  24526. cardNumber := bas[2]
  24527. verify_number = cardNumber
  24528. } else {
  24529. verify_number = psn_info.Certno
  24530. }
  24531. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24532. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24533. "&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
  24534. resp, requestErr := http.Get(api)
  24535. if requestErr != nil {
  24536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24537. return
  24538. }
  24539. body, ioErr := ioutil.ReadAll(resp.Body)
  24540. if ioErr != nil {
  24541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24543. return
  24544. }
  24545. var respJSON map[string]interface{}
  24546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24549. return
  24550. }
  24551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24552. result, _ := json.Marshal(respJSON)
  24553. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24554. utils.ErrorLog("解析失败:%v", err)
  24555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24556. return
  24557. }
  24558. infocode = resThree.Infcode
  24559. } else {
  24560. hour := time.Now().Format("15")
  24561. min := time.Now().Format("04")
  24562. sec := time.Now().Format("05")
  24563. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24564. if id_card_type == 1 {
  24565. for _, item := range rf {
  24566. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24567. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24568. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24569. } else if strconv.FormatInt(social_type, 10) == "390" {
  24570. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24571. } else {
  24572. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24573. }
  24574. }
  24575. }
  24576. }
  24577. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24578. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24579. }
  24580. if id_card_type == 1 {
  24581. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24582. bas := strings.Split(psn_info.CardInfo, "|")
  24583. basNumber := bas[1]
  24584. IdCardNo = basNumber
  24585. }
  24586. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24587. IdCardNo = psn_info.VerifyNumber
  24588. }
  24589. if len(insuplc_admdvs_temp) == 0 {
  24590. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24591. }
  24592. var result string
  24593. var requestLog string
  24594. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  24595. var hisPrescription []*models.HisPrescription
  24596. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24597. if res3101.Infcode == 0 {
  24598. if len(res3101.Output.Result) > 0 {
  24599. if len(res3101.Output.Result) > 0 {
  24600. c.ServeSuccessJSON(map[string]interface{}{
  24601. "failed_code": -10,
  24602. "failed_type": 100,
  24603. "msg": res3101.Output.Result,
  24604. })
  24605. return
  24606. } else {
  24607. c.ServeSuccessJSON(map[string]interface{}{
  24608. "failed_code": -10,
  24609. "msg": res3101.ErrMsg,
  24610. })
  24611. return
  24612. }
  24613. } else {
  24614. hour := time.Now().Format("15")
  24615. min := time.Now().Format("04")
  24616. sec := time.Now().Format("05")
  24617. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24618. fmt.Println(record_time_two)
  24619. if his.IdCardType == 2 {
  24620. IdCardNo = psn_info.Certno
  24621. psn_info.VerifyNumber = psn_info.Certno
  24622. } else if his.IdCardType == 4 {
  24623. IdCardNo = psn_info.Certno
  24624. } else {
  24625. bas := strings.Split(psn_info.CardInfo, "|")
  24626. IdCardNo = bas[2]
  24627. }
  24628. 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)
  24629. saveLog(result, requestLog, "2201A", "挂号")
  24630. if miConfig.Code == "H15049901371" {
  24631. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24632. utils.ErrorLog("解析失败:%v", err)
  24633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24634. return
  24635. }
  24636. resThree.ErrMsg = resThree10265.ErrMsg
  24637. resThree.Output = resThree10265.Output
  24638. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24639. } else {
  24640. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24641. utils.ErrorLog("解析失败:%v", err)
  24642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24643. return
  24644. }
  24645. }
  24646. if miConfig.Code == "H15049901371" {
  24647. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24648. } else {
  24649. infocode = resThree.Infcode
  24650. }
  24651. }
  24652. } else if res3101.Infcode != 0 {
  24653. c.ServeSuccessJSON(map[string]interface{}{
  24654. "failed_code": -10,
  24655. "msg": res3101.ErrMsg,
  24656. })
  24657. return
  24658. }
  24659. } else {
  24660. psn_info, _ := service.GetPsnByPatientId(id)
  24661. var rf []*ResultFive
  24662. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24663. //var insutypes []*ResultFive
  24664. var insutype string
  24665. var insutypes []*ResultFive
  24666. var is390 int = 0
  24667. var is310 int = 0
  24668. for _, item := range rf {
  24669. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24670. insutypes = append(insutypes, item)
  24671. }
  24672. }
  24673. if len(insutypes) == 1 {
  24674. insutype = insutypes[0].Insutype
  24675. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24676. } else {
  24677. for _, i := range insutypes {
  24678. if i.Insutype == "390" {
  24679. is390 = 1
  24680. }
  24681. if i.Insutype == "310" {
  24682. is310 = 1
  24683. }
  24684. }
  24685. }
  24686. if is390 == 1 {
  24687. insutype = "390"
  24688. }
  24689. if is310 == 1 {
  24690. insutype = "310"
  24691. }
  24692. if len(insutypes) == 0 {
  24693. insutype = "310"
  24694. }
  24695. if social_type > 0 {
  24696. insutype = strconv.FormatInt(social_type, 10)
  24697. }
  24698. for _, item := range rf {
  24699. utils.ErrorLog("解析失败:%v", item.Insutype)
  24700. utils.ErrorLog("解析失败:%v", insutype)
  24701. if item.Insutype == insutype {
  24702. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24703. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24704. }
  24705. }
  24706. 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)
  24707. saveLog(result, requestLog, "2201A", "挂号")
  24708. }
  24709. if miConfig.Code == "H15049901371" {
  24710. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24711. utils.ErrorLog("解析失败:%v", err)
  24712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24713. return
  24714. }
  24715. resThree.ErrMsg = resThree10265.ErrMsg
  24716. resThree.Output = resThree10265.Output
  24717. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24718. } else {
  24719. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24720. utils.ErrorLog("解析失败:%v", err)
  24721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24722. return
  24723. }
  24724. }
  24725. if miConfig.Code == "H15049901371" {
  24726. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24727. } else {
  24728. infocode = resThree.Infcode
  24729. }
  24730. }
  24731. }
  24732. if infocode == -1 {
  24733. adminUser := c.GetAdminUserInfo()
  24734. errlog := &models.HisOrderError{
  24735. UserOrgId: adminUser.CurrentOrgId,
  24736. Ctime: time.Now().Unix(),
  24737. Mtime: time.Now().Unix(),
  24738. ErrMsg: resThree.ErrMsg,
  24739. Status: 1,
  24740. PatientId: id,
  24741. RecordTime: recordDateTime,
  24742. Stage: 2,
  24743. }
  24744. service.CreateErrMsgLog(errlog)
  24745. c.ServeSuccessJSON(map[string]interface{}{
  24746. "failed_code": -10,
  24747. "msg": resThree.ErrMsg,
  24748. })
  24749. return
  24750. }
  24751. his.Number = resThree.Output.Data.MdtrtID
  24752. his.PsnNo = resThree.Output.Data.PsnNo
  24753. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24754. his.IdCardNo = patient.IdCardNo
  24755. his.PhoneNumber = patient.Phone
  24756. his.UserOrgId = adminInfo.CurrentOrgId
  24757. his.Insutype = insutype
  24758. his.Ctime = time.Now().Unix()
  24759. his.Mtime = time.Now().Unix()
  24760. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24761. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24762. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24763. }
  24764. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24765. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24766. }
  24767. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24768. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24769. }
  24770. his.Status = 1
  24771. his.MdtrtGrpType = mdtrt_type
  24772. service.UpdateHisPatientStatus(&his)
  24773. service.UpdateHisPatient123(&patient)
  24774. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24775. c.ServeSuccessJSON(map[string]interface{}{
  24776. "his_info": his,
  24777. })
  24778. } else {
  24779. adminUser := c.GetAdminUserInfo()
  24780. errlog := &models.HisOrderError{
  24781. UserOrgId: adminUser.CurrentOrgId,
  24782. Ctime: time.Now().Unix(),
  24783. Mtime: time.Now().Unix(),
  24784. ErrMsg: res.ErrMsg,
  24785. Status: 1,
  24786. PatientId: id,
  24787. RecordTime: recordDateTime,
  24788. Stage: 1,
  24789. }
  24790. service.CreateErrMsgLog(errlog)
  24791. c.ServeSuccessJSON(map[string]interface{}{
  24792. "failed_code": -10,
  24793. "msg": res.ErrMsg,
  24794. })
  24795. return
  24796. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24797. }
  24798. }
  24799. }
  24800. func (c *HisApiController) GetUploadInfo() {
  24801. id, _ := c.GetInt64("id")
  24802. record_time := c.GetString("record_time")
  24803. his_patient_id, _ := c.GetInt64("his_patient_id")
  24804. order_id, _ := c.GetInt64("order_id")
  24805. pay_way, _ := c.GetInt64("pay_way")
  24806. pay_ways := c.GetString("pay_ways")
  24807. oth_desc := c.GetString("oth_desc")
  24808. pay_price, _ := c.GetFloat("pay_price")
  24809. pay_card_no := c.GetString("pay_card_no")
  24810. discount_price, _ := c.GetFloat("discount_price")
  24811. preferential_price, _ := c.GetFloat("preferential_price")
  24812. reality_price, _ := c.GetFloat("reality_price")
  24813. found_price, _ := c.GetFloat("found_price")
  24814. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24815. private_price, _ := c.GetFloat("private_price")
  24816. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24817. admin_user_id, _ := c.GetInt64("admin_user_id")
  24818. fapiao_code := c.GetString("fapiao_code")
  24819. fapiao_number := c.GetString("fapiao_number")
  24820. diagnosis_id := c.GetString("diagnosis")
  24821. sick_type, _ := c.GetInt64("sick_type")
  24822. reg_type, _ := c.GetInt64("p_type")
  24823. begin_time := c.GetString("begin_time")
  24824. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24825. cash_pay := c.GetString("cash_pay")
  24826. band_card_pay := c.GetString("band_card_pay")
  24827. wechat_pay := c.GetString("wechat_pay")
  24828. ali_pay := c.GetString("ali_pay")
  24829. jifen_pay := c.GetString("jifen_pay")
  24830. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24831. fmt.Println(acct_used_flag)
  24832. id_str := c.GetString("ids")
  24833. ids_arr := strings.Split(id_str, ",")
  24834. timeLayout := "2006-01-02"
  24835. loc, _ := time.LoadLocation("Local")
  24836. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24837. if err != nil {
  24838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24839. return
  24840. }
  24841. recordDateTime := theTime.Unix()
  24842. adminUser := c.GetAdminUserInfo()
  24843. var tempOrder models.HisOrder
  24844. tempOrder, _ = service.GetHisOrderByID(order_id)
  24845. var prescriptions []*models.HisPrescription
  24846. var start_time int64
  24847. var end_time int64
  24848. //押金模块
  24849. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24850. tmp_decimal := c.GetString("tmp_decimal")
  24851. var decimal float64 //本次使用的押金
  24852. var errmsg error
  24853. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24854. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24855. return
  24856. }
  24857. if len(tmp_decimal) > 0 {
  24858. if tmp_decimal[0] == 45 {
  24859. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24860. return
  24861. }
  24862. }
  24863. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24864. fmt.Println(errs)
  24865. decimal = tt
  24866. //if adminUser.CurrentOrgId == 10106{
  24867. // if len(fapiao_code) == 0{
  24868. // fapiao_code = "144072080589"
  24869. // }
  24870. // if len(fapiao_number) == 0{
  24871. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24872. // if order.ID == 0{
  24873. // fapiao_number = "00001520"
  24874. // }else{
  24875. // //fapiao_code = "00001520"
  24876. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24877. // var zero string
  24878. // if fpNumber >= 1000{
  24879. // zero = "0000" + strconv.Itoa(fpNumber)
  24880. // }else if fpNumber >= 10000{
  24881. // zero = "000" + strconv.Itoa(fpNumber)
  24882. // } else if fpNumber >= 100000{
  24883. // zero = "00" + strconv.Itoa(fpNumber)
  24884. // } else if fpNumber >= 1000000{
  24885. // zero = "0" + strconv.Itoa(fpNumber)
  24886. // }else {
  24887. // zero = strconv.Itoa(fpNumber)
  24888. // }
  24889. // fapiao_number = zero
  24890. // }
  24891. // }
  24892. //}
  24893. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24894. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24895. var patientPrescription models.HisPrescriptionInfo
  24896. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24897. if patientPrescription.ID == 0 {
  24898. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24899. }
  24900. //if patientPrescription.Do
  24901. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24902. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24903. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24904. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24905. var config []*models.HisXtDiagnoseConfig
  24906. for _, item := range diagnosis_ids {
  24907. id, _ := strconv.ParseInt(item, 10, 64)
  24908. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24909. config = append(config, &diagnosisConfig)
  24910. }
  24911. sickConfig, _ := service.FindSickById(sick_type)
  24912. //if tempOrder.ID == 0 {
  24913. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24914. //}
  24915. if tempOrder.ID == 0 {
  24916. var result string
  24917. var requestLog string
  24918. var res2 ResultSix
  24919. var res3 GZResultSix
  24920. var ressix10265 ResultSix10265
  24921. if miConfig.MdtrtareaAdmvs == "421300" {
  24922. data := make(map[string]interface{})
  24923. client := &http.Client{}
  24924. data["psn_no"] = his.PsnNo
  24925. data["mdtrt_id"] = his.Number
  24926. data["opter"] = roles.UserName
  24927. data["org_name"] = miConfig.OrgName
  24928. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24929. data["doctor_id"] = doctor_info.DoctorNumber
  24930. data["doctor_name"] = doctor_info.UserName
  24931. data["department"] = department.Name
  24932. data["fixmedins_code"] = miConfig.Code
  24933. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24934. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24935. data["secret_key"] = miConfig.SecretKey
  24936. data["sick_code"] = sickConfig.CountryCode
  24937. data["sick_name"] = sickConfig.ClassName
  24938. data["dept"] = strconv.FormatInt(department.ID, 10)
  24939. data["config"] = config
  24940. data["begin_time"] = begin_time
  24941. bytesData, _ := json.Marshal(data)
  24942. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24943. resp, _ := client.Do(req)
  24944. defer resp.Body.Close()
  24945. body, ioErr := ioutil.ReadAll(resp.Body)
  24946. if ioErr != nil {
  24947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24949. return
  24950. }
  24951. var respJSON map[string]interface{}
  24952. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24955. return
  24956. }
  24957. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24958. userJSONBytes, _ := json.Marshal(respJSON)
  24959. fmt.Println("log")
  24960. fmt.Println(string(userJSONBytes))
  24961. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24962. utils.ErrorLog("解析失败:%v", err)
  24963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24964. return
  24965. }
  24966. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24967. data := make(map[string]interface{})
  24968. client := &http.Client{}
  24969. data["psn_no"] = his.PsnNo
  24970. data["mdtrt_id"] = his.Number
  24971. data["opter"] = roles.UserName
  24972. data["org_name"] = miConfig.OrgName
  24973. if reg_type == 11 && his.Insutype == "390" {
  24974. data["med_type"] = "110104"
  24975. } else {
  24976. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24977. }
  24978. data["doctor_id"] = doctor_info.DoctorNumber
  24979. data["doctor_name"] = doctor_info.UserName
  24980. data["department"] = department.Name
  24981. data["fixmedins_code"] = miConfig.Code
  24982. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24983. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24984. data["secret_key"] = miConfig.SecretKey
  24985. data["sick_code"] = sickConfig.CountryCode
  24986. data["sick_name"] = sickConfig.ClassName
  24987. data["dept"] = strconv.FormatInt(department.ID, 10)
  24988. data["config"] = config
  24989. data["begin_time"] = begin_time
  24990. bytesData, _ := json.Marshal(data)
  24991. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24992. resp, _ := client.Do(req)
  24993. defer resp.Body.Close()
  24994. body, ioErr := ioutil.ReadAll(resp.Body)
  24995. if ioErr != nil {
  24996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24998. return
  24999. }
  25000. var respJSON map[string]interface{}
  25001. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25004. return
  25005. }
  25006. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25007. userJSONBytes, _ := json.Marshal(respJSON)
  25008. fmt.Println("log")
  25009. fmt.Println(string(userJSONBytes))
  25010. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25011. utils.ErrorLog("解析失败:%v", err)
  25012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25013. return
  25014. }
  25015. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25016. data := make(map[string]interface{})
  25017. client := &http.Client{}
  25018. data["psn_no"] = his.PsnNo
  25019. data["mdtrt_id"] = his.Number
  25020. data["opter"] = roles.UserName
  25021. data["org_name"] = miConfig.OrgName
  25022. if reg_type == 11 && his.Insutype == "390" {
  25023. data["med_type"] = "110104"
  25024. } else {
  25025. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25026. }
  25027. data["doctor_id"] = doctor_info.DoctorNumber
  25028. data["doctor_name"] = doctor_info.UserName
  25029. data["department"] = department.Name
  25030. data["fixmedins_code"] = miConfig.Code
  25031. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25032. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25033. data["secret_key"] = miConfig.SecretKey
  25034. data["sick_code"] = sickConfig.CountryCode
  25035. data["sick_name"] = sickConfig.ClassName
  25036. data["dept"] = strconv.FormatInt(department.ID, 10)
  25037. data["config"] = config
  25038. data["begin_time"] = begin_time
  25039. bytesData, _ := json.Marshal(data)
  25040. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25041. resp, _ := client.Do(req)
  25042. defer resp.Body.Close()
  25043. body, ioErr := ioutil.ReadAll(resp.Body)
  25044. if ioErr != nil {
  25045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25047. return
  25048. }
  25049. var respJSON map[string]interface{}
  25050. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25053. return
  25054. }
  25055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25056. userJSONBytes, _ := json.Marshal(respJSON)
  25057. fmt.Println("log")
  25058. fmt.Println(string(userJSONBytes))
  25059. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25060. utils.ErrorLog("解析失败:%v", err)
  25061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25062. return
  25063. }
  25064. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25065. data := make(map[string]interface{})
  25066. client := &http.Client{}
  25067. data["psn_no"] = his.PsnNo
  25068. data["mdtrt_id"] = his.Number
  25069. data["opter"] = roles.UserName
  25070. data["org_name"] = miConfig.OrgName
  25071. if reg_type == 11 && his.Insutype == "390" {
  25072. data["med_type"] = "110104"
  25073. } else {
  25074. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25075. }
  25076. data["doctor_id"] = doctor_info.DoctorNumber
  25077. data["doctor_name"] = doctor_info.UserName
  25078. data["department"] = department.Name
  25079. data["fixmedins_code"] = miConfig.Code
  25080. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25081. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25082. data["secret_key"] = miConfig.SecretKey
  25083. data["sick_code"] = sickConfig.CountryCode
  25084. data["sick_name"] = sickConfig.ClassName
  25085. data["dept"] = strconv.FormatInt(department.ID, 10)
  25086. data["config"] = config
  25087. data["begin_time"] = begin_time
  25088. bytesData, _ := json.Marshal(data)
  25089. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25090. resp, _ := client.Do(req)
  25091. defer resp.Body.Close()
  25092. body, ioErr := ioutil.ReadAll(resp.Body)
  25093. if ioErr != nil {
  25094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25096. return
  25097. }
  25098. var respJSON map[string]interface{}
  25099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25102. return
  25103. }
  25104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25105. userJSONBytes, _ := json.Marshal(respJSON)
  25106. fmt.Println("log")
  25107. fmt.Println(string(userJSONBytes))
  25108. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25109. utils.ErrorLog("解析失败:%v", err)
  25110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25111. return
  25112. }
  25113. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25114. data := make(map[string]interface{})
  25115. client := &http.Client{}
  25116. data["psn_no"] = his.PsnNo
  25117. data["mdtrt_id"] = his.Number
  25118. data["doctor"] = roles.UserName
  25119. data["department"] = department.Name
  25120. data["org_name"] = miConfig.OrgName
  25121. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25122. data["doctor_id"] = doctor_info.DoctorNumber
  25123. data["new_doctor_name"] = doctor_info.UserName
  25124. data["fixmedins_code"] = miConfig.Code
  25125. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25126. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25127. data["secret_key"] = miConfig.SecretKey
  25128. data["sick_code"] = sickConfig.CountryCode
  25129. data["sick_name"] = sickConfig.ClassName
  25130. data["url"] = miConfig.Url
  25131. data["ak"] = miConfig.AccessKey
  25132. data["begin_time"] = begin_time
  25133. data["cainfo"] = miConfig.Cainfo
  25134. data["dept"] = strconv.FormatInt(department.ID, 10)
  25135. data["config"] = config
  25136. bytesData, _ := json.Marshal(data)
  25137. var req *http.Request
  25138. if miConfig.MdtrtareaAdmvs == "320921" {
  25139. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25140. //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 +
  25141. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25142. } else {
  25143. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25144. }
  25145. resp, _ := client.Do(req)
  25146. defer resp.Body.Close()
  25147. body, ioErr := ioutil.ReadAll(resp.Body)
  25148. if ioErr != nil {
  25149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25151. return
  25152. }
  25153. var respJSON map[string]interface{}
  25154. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25157. return
  25158. }
  25159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25160. userJSONBytes, _ := json.Marshal(respJSON)
  25161. fmt.Println("log")
  25162. fmt.Println(string(userJSONBytes))
  25163. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25164. utils.ErrorLog("解析失败:%v", err)
  25165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25166. return
  25167. }
  25168. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25169. res2.Output = ressix10265.Output
  25170. res2.ErrMsg = ressix10265.ErrMsg
  25171. res2.Cainfo = ressix10265.Cainfo
  25172. res2.WarnMsg = ressix10265.WarnMsg
  25173. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25174. res2.Infcode = infocode
  25175. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25176. data := make(map[string]interface{})
  25177. client := &http.Client{}
  25178. data["psn_no"] = his.PsnNo
  25179. data["mdtrt_id"] = his.Number
  25180. data["doctor"] = roles.UserName
  25181. data["department"] = department.Name
  25182. data["org_name"] = miConfig.OrgName
  25183. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25184. data["doctor_id"] = doctor_info.DoctorNumber
  25185. data["new_doctor_name"] = doctor_info.UserName
  25186. data["fixmedins_code"] = miConfig.Code
  25187. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25188. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25189. data["secret_key"] = miConfig.SecretKey
  25190. data["sick_code"] = sickConfig.CountryCode
  25191. data["sick_name"] = sickConfig.ClassName
  25192. data["url"] = miConfig.Url
  25193. data["ak"] = miConfig.AccessKey
  25194. data["begin_time"] = begin_time
  25195. data["cainfo"] = miConfig.Cainfo
  25196. data["dept"] = strconv.FormatInt(department.ID, 10)
  25197. data["config"] = config
  25198. bytesData, _ := json.Marshal(data)
  25199. var req *http.Request
  25200. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25201. resp, _ := client.Do(req)
  25202. defer resp.Body.Close()
  25203. body, ioErr := ioutil.ReadAll(resp.Body)
  25204. if ioErr != nil {
  25205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25207. return
  25208. }
  25209. var respJSON map[string]interface{}
  25210. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25213. return
  25214. }
  25215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25216. userJSONBytes, _ := json.Marshal(respJSON)
  25217. fmt.Println("log")
  25218. fmt.Println(string(userJSONBytes))
  25219. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25220. utils.ErrorLog("解析失败:%v", err)
  25221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25222. return
  25223. }
  25224. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25225. res2.Output = ressix10265.Output
  25226. res2.ErrMsg = ressix10265.ErrMsg
  25227. res2.Cainfo = ressix10265.Cainfo
  25228. res2.WarnMsg = ressix10265.WarnMsg
  25229. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25230. res2.Infcode = infocode
  25231. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25232. 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)
  25233. saveLog(result, requestLog, "2203", "上传就诊信息")
  25234. var respJSON2 map[string]interface{}
  25235. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25238. return
  25239. }
  25240. userJSONBytes2, _ := json.Marshal(respJSON2)
  25241. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25242. utils.ErrorLog("解析失败:%v", err)
  25243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25244. return
  25245. }
  25246. 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)
  25247. fmt.Println(result2)
  25248. fmt.Println(src_request)
  25249. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25250. data := make(map[string]interface{})
  25251. client := &http.Client{}
  25252. data["psn_no"] = his.PsnNo
  25253. data["mdtrt_id"] = his.Number
  25254. data["doctor"] = roles.UserName
  25255. data["department"] = department.Name
  25256. data["org_name"] = miConfig.OrgName
  25257. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25258. data["doctor_id"] = doctor_info.DoctorNumber
  25259. data["new_doctor_name"] = doctor_info.UserName
  25260. data["fixmedins_code"] = miConfig.Code
  25261. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25262. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25263. data["secret_key"] = miConfig.SecretKey
  25264. data["sick_code"] = sickConfig.CountryCode
  25265. data["sick_name"] = sickConfig.ClassName
  25266. data["url"] = miConfig.Url
  25267. data["ak"] = miConfig.AccessKey
  25268. data["begin_time"] = begin_time
  25269. data["cainfo"] = miConfig.Cainfo
  25270. data["dept"] = strconv.FormatInt(department.ID, 10)
  25271. data["config"] = config
  25272. bytesData, _ := json.Marshal(data)
  25273. var req *http.Request
  25274. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25275. resp, _ := client.Do(req)
  25276. defer resp.Body.Close()
  25277. body, ioErr := ioutil.ReadAll(resp.Body)
  25278. if ioErr != nil {
  25279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25281. return
  25282. }
  25283. var respJSON map[string]interface{}
  25284. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25290. userJSONBytes, _ := json.Marshal(respJSON)
  25291. fmt.Println("log")
  25292. fmt.Println(string(userJSONBytes))
  25293. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25294. utils.ErrorLog("解析失败:%v", err)
  25295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25296. return
  25297. }
  25298. } else {
  25299. if miConfig.MdtrtareaAdmvs == "440781" { //
  25300. 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)
  25301. } else {
  25302. if miConfig.Code == "H15049901371" {
  25303. //赤峰地区国家医保医疗类别
  25304. //职工透析:医疗类别选特殊情况门诊990502
  25305. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25306. var med_type string
  25307. if his.Insutype == "390" {
  25308. if reg_type == 14 {
  25309. med_type = "9933"
  25310. } else if reg_type == 11 {
  25311. med_type = "11"
  25312. }
  25313. } else if his.Insutype == "310" {
  25314. if reg_type == 14 {
  25315. med_type = "990502"
  25316. } else if reg_type == 11 {
  25317. med_type = "11"
  25318. }
  25319. }
  25320. 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)
  25321. } else {
  25322. 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)
  25323. }
  25324. }
  25325. saveLog(result, requestLog, "2203", "上传就诊信息")
  25326. var respJSON2 map[string]interface{}
  25327. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25330. return
  25331. }
  25332. userJSONBytes2, _ := json.Marshal(respJSON2)
  25333. if miConfig.Code == "H15049901371" {
  25334. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25335. utils.ErrorLog("解析失败:%v", err)
  25336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25337. return
  25338. }
  25339. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25340. res2.Output = ressix10265.Output
  25341. res2.ErrMsg = ressix10265.ErrMsg
  25342. res2.Cainfo = ressix10265.Cainfo
  25343. res2.WarnMsg = ressix10265.WarnMsg
  25344. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25345. res2.Infcode = infocode
  25346. } else {
  25347. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25348. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25349. utils.ErrorLog("解析失败:%v", err)
  25350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25351. return
  25352. }
  25353. res2.Infcode = res3.Infcode
  25354. } else {
  25355. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25356. utils.ErrorLog("解析失败:%v", err)
  25357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25358. return
  25359. }
  25360. }
  25361. }
  25362. }
  25363. if res2.Infcode == -1 {
  25364. adminUser := c.GetAdminUserInfo()
  25365. errlog := &models.HisOrderError{
  25366. UserOrgId: adminUser.CurrentOrgId,
  25367. Ctime: time.Now().Unix(),
  25368. Mtime: time.Now().Unix(),
  25369. ErrMsg: res2.ErrMsg,
  25370. Status: 1,
  25371. PatientId: id,
  25372. RecordTime: recordDateTime,
  25373. Stage: 3,
  25374. }
  25375. service.CreateErrMsgLog(errlog)
  25376. c.ServeSuccessJSON(map[string]interface{}{
  25377. "failed_code": -10,
  25378. "msg": res2.ErrMsg,
  25379. })
  25380. return
  25381. } else {
  25382. his.Diagnosis = diagnosis_id
  25383. his.SickType = sickConfig.ID
  25384. //var p_type int64
  25385. //if reg_type == 1111 || reg_type == 1112 {
  25386. // p_type = 11
  25387. //
  25388. //}
  25389. his.PType = fmt.Sprintf("%d", reg_type)
  25390. service.UpdateHisPatientThree(&his)
  25391. data := make(map[string]interface{})
  25392. if settle_accounts_type == 1 { //日结
  25393. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25394. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25395. } else {
  25396. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25397. }
  25398. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25399. data["pre"] = prescriptions
  25400. } else { //月结
  25401. start_time_str := c.GetString("start_time")
  25402. end_time_str := c.GetString("end_time")
  25403. timeLayout := "2006-01-02"
  25404. loc, _ := time.LoadLocation("Local")
  25405. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25406. if err != nil {
  25407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25408. return
  25409. }
  25410. recordStartTime := theStartTime.Unix()
  25411. start_time = recordStartTime
  25412. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25413. if err != nil {
  25414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25415. return
  25416. }
  25417. recordEndTime := theEndTime.Unix()
  25418. end_time = recordEndTime
  25419. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25420. data["pre"] = prescriptions
  25421. }
  25422. timestamp := time.Now().Unix()
  25423. tempTime := time.Unix(timestamp, 0)
  25424. timeFormat := tempTime.Format("20060102150405")
  25425. chrgBchno := rand.Intn(100000) + 10000
  25426. new_chrg_bchno := ""
  25427. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25428. new_chrg_bchno = chrg_bchno
  25429. strconv.FormatInt(his.PatientId, 10)
  25430. client := &http.Client{}
  25431. if adminUser.CurrentOrgId == 10265 {
  25432. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25433. new_chrg_bchno = "0000"
  25434. }
  25435. }
  25436. data["psn_no"] = his.PsnNo
  25437. data["mdtrt_id"] = his.Number
  25438. data["chrg_bchno"] = new_chrg_bchno
  25439. data["org_name"] = miConfig.OrgName
  25440. data["doctor"] = doctor_info.UserName
  25441. data["doctor_id"] = doctor_info.DoctorNumber
  25442. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25443. data["fixmedins_code"] = miConfig.Code
  25444. data["dept_code"] = department.Number
  25445. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25446. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25447. data["secret_key"] = miConfig.SecretKey
  25448. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25449. data["url"] = miConfig.Url
  25450. data["ak"] = miConfig.AccessKey
  25451. data["new_doctor_name"] = patientPrescription.Doctor
  25452. data["diag_code"] = sickConfig.CountryCode
  25453. data["cainfo"] = miConfig.Cainfo
  25454. data["opter"] = roles.UserName
  25455. var ids []int64
  25456. for _, item := range prescriptions {
  25457. ids = append(ids, item.ID)
  25458. }
  25459. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25460. if config.IsOpen == 1 { //对接了医保,走医保流程
  25461. var res ResultFour
  25462. var resFour10265 ResultFour10265
  25463. if miConfig.MdtrtareaAdmvs == "421300" {
  25464. bytesData, _ := json.Marshal(data)
  25465. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25466. resp, _ := client.Do(req)
  25467. defer resp.Body.Close()
  25468. body, ioErr := ioutil.ReadAll(resp.Body)
  25469. if ioErr != nil {
  25470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25472. return
  25473. }
  25474. var respJSON map[string]interface{}
  25475. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25478. return
  25479. }
  25480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25481. userJSONBytes, _ := json.Marshal(respJSON)
  25482. fmt.Println("log")
  25483. fmt.Println(string(userJSONBytes))
  25484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25485. utils.ErrorLog("解析失败:%v", err)
  25486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25487. return
  25488. }
  25489. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25490. bytesData, _ := json.Marshal(data)
  25491. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25492. resp, _ := client.Do(req)
  25493. defer resp.Body.Close()
  25494. body, ioErr := ioutil.ReadAll(resp.Body)
  25495. if ioErr != nil {
  25496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25498. return
  25499. }
  25500. var respJSON map[string]interface{}
  25501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25504. return
  25505. }
  25506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25507. userJSONBytes, _ := json.Marshal(respJSON)
  25508. fmt.Println("log")
  25509. fmt.Println(string(userJSONBytes))
  25510. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25511. utils.ErrorLog("解析失败:%v", err)
  25512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25513. return
  25514. }
  25515. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25516. bytesData, _ := json.Marshal(data)
  25517. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25518. resp, _ := client.Do(req)
  25519. defer resp.Body.Close()
  25520. body, ioErr := ioutil.ReadAll(resp.Body)
  25521. if ioErr != nil {
  25522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25524. return
  25525. }
  25526. var respJSON map[string]interface{}
  25527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25530. return
  25531. }
  25532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25533. userJSONBytes, _ := json.Marshal(respJSON)
  25534. fmt.Println("log")
  25535. fmt.Println(string(userJSONBytes))
  25536. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25537. utils.ErrorLog("解析失败:%v", err)
  25538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25539. return
  25540. }
  25541. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25542. bytesData, _ := json.Marshal(data)
  25543. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25544. resp, _ := client.Do(req)
  25545. defer resp.Body.Close()
  25546. body, ioErr := ioutil.ReadAll(resp.Body)
  25547. if ioErr != nil {
  25548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. var respJSON map[string]interface{}
  25553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25556. return
  25557. }
  25558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25559. userJSONBytes, _ := json.Marshal(respJSON)
  25560. fmt.Println("log")
  25561. fmt.Println(string(userJSONBytes))
  25562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25563. utils.ErrorLog("解析失败:%v", err)
  25564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25565. return
  25566. }
  25567. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25568. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25569. if result3101.Infcode == "0" {
  25570. if len(result3101.Output.Result) > 0 {
  25571. var errMsgs []string
  25572. for _, item := range result3101.Output.Result {
  25573. errMsgs = append(errMsgs, item.VolaCont)
  25574. }
  25575. c.ServeSuccessJSON(map[string]interface{}{
  25576. "failed_code": -10,
  25577. "msg": errMsgs,
  25578. })
  25579. return
  25580. }
  25581. }
  25582. bytesData, _ := json.Marshal(data)
  25583. var req *http.Request
  25584. if miConfig.MdtrtareaAdmvs == "320921" {
  25585. data["diag_code"] = sickConfig.CountryCode
  25586. fmt.Println(data)
  25587. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25588. } else {
  25589. data["diag_code"] = sickConfig.CountryCode
  25590. fmt.Println(data)
  25591. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25592. }
  25593. resp, _ := client.Do(req)
  25594. defer resp.Body.Close()
  25595. body, ioErr := ioutil.ReadAll(resp.Body)
  25596. if ioErr != nil {
  25597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25599. return
  25600. }
  25601. var respJSON map[string]interface{}
  25602. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25605. return
  25606. }
  25607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25608. userJSONBytes, _ := json.Marshal(respJSON)
  25609. fmt.Println("log")
  25610. fmt.Println(string(userJSONBytes))
  25611. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25612. utils.ErrorLog("解析失败:%v", err)
  25613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25614. return
  25615. }
  25616. res.InfRefmsgid = resFour10265.InfRefmsgid
  25617. res.Output = resFour10265.Output
  25618. res.ErrMsg = resFour10265.ErrMsg
  25619. res.Cainfo = resFour10265.Cainfo
  25620. res.WarnMsg = resFour10265.WarnMsg
  25621. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25622. res.Infcode = infocode
  25623. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25624. var pagesize int = 2
  25625. var start int = 1
  25626. var stop int
  25627. var pagecount int
  25628. var curpage int
  25629. var isSuccess bool = true
  25630. data["doctor_id"] = doctor_info.DoctorNumber
  25631. //总页数,向上取整,注意除之前要先转换类型为float64
  25632. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25633. for curpage = 1; curpage <= pagecount; curpage++ {
  25634. if curpage == 1 {
  25635. start = 1
  25636. } else {
  25637. start = (curpage-1)*pagesize + 1
  25638. }
  25639. stop = curpage * pagesize
  25640. if stop > len(prescriptions) {
  25641. stop = len(prescriptions)
  25642. }
  25643. //var requestLog string
  25644. data["pre"] = prescriptions[start-1 : stop]
  25645. fmt.Println(data["pre"])
  25646. bytesData, _ := json.Marshal(data)
  25647. var req *http.Request
  25648. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25649. resp, _ := client.Do(req)
  25650. defer resp.Body.Close()
  25651. body, ioErr := ioutil.ReadAll(resp.Body)
  25652. if ioErr != nil {
  25653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25655. return
  25656. }
  25657. var respJSON map[string]interface{}
  25658. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25661. return
  25662. }
  25663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25664. userJSONBytes, _ := json.Marshal(respJSON)
  25665. fmt.Println("log")
  25666. fmt.Println(string(userJSONBytes))
  25667. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25668. utils.ErrorLog("解析失败:%v", err)
  25669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25670. return
  25671. }
  25672. res.InfRefmsgid = resFour10265.InfRefmsgid
  25673. res.Output = resFour10265.Output
  25674. res.ErrMsg = resFour10265.ErrMsg
  25675. res.Cainfo = resFour10265.Cainfo
  25676. res.WarnMsg = resFour10265.WarnMsg
  25677. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25678. res.Infcode = infocode
  25679. if infocode == 0 {
  25680. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25681. } else {
  25682. isSuccess = false
  25683. errlog := &models.HisOrderError{
  25684. UserOrgId: adminUser.CurrentOrgId,
  25685. Ctime: time.Now().Unix(),
  25686. Mtime: time.Now().Unix(),
  25687. Number: chrg_bchno,
  25688. ErrMsg: "",
  25689. Status: 1,
  25690. PatientId: id,
  25691. RecordTime: recordDateTime,
  25692. Stage: 4,
  25693. }
  25694. service.CreateErrMsgLog(errlog)
  25695. c.ServeSuccessJSON(map[string]interface{}{
  25696. "failed_code": -10,
  25697. "msg": res.ErrMsg,
  25698. })
  25699. return
  25700. }
  25701. }
  25702. if isSuccess {
  25703. res.Infcode = 0
  25704. }
  25705. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25706. 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)
  25707. var dat map[string]interface{}
  25708. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25709. fmt.Println(dat)
  25710. } else {
  25711. fmt.Println(err)
  25712. }
  25713. saveLog(result, request_log, "2204", "上传费用明细")
  25714. userJSONBytes, _ := json.Marshal(dat)
  25715. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25716. utils.ErrorLog("解析失败:%v", err)
  25717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25718. return
  25719. }
  25720. res.InfRefmsgid = resFour10265.InfRefmsgid
  25721. res.Output = resFour10265.Output
  25722. res.ErrMsg = resFour10265.ErrMsg
  25723. res.Cainfo = resFour10265.Cainfo
  25724. res.WarnMsg = resFour10265.WarnMsg
  25725. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25726. res.Infcode = infocode
  25727. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25728. bytesData, _ := json.Marshal(data)
  25729. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25730. resp, _ := client.Do(req)
  25731. defer resp.Body.Close()
  25732. body, ioErr := ioutil.ReadAll(resp.Body)
  25733. if ioErr != nil {
  25734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25736. return
  25737. }
  25738. var respJSON map[string]interface{}
  25739. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25742. return
  25743. }
  25744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25745. userJSONBytes, _ := json.Marshal(respJSON)
  25746. fmt.Println("log")
  25747. fmt.Println(string(userJSONBytes))
  25748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25749. utils.ErrorLog("解析失败:%v", err)
  25750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25751. return
  25752. }
  25753. } else {
  25754. if miConfig.Code == "H15049901371" {
  25755. 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)
  25756. var dat map[string]interface{}
  25757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25758. fmt.Println(dat)
  25759. } else {
  25760. fmt.Println(err)
  25761. }
  25762. saveLog(result, request_log, "2204", "上传费用明细")
  25763. userJSONBytes, _ := json.Marshal(dat)
  25764. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25765. utils.ErrorLog("解析失败:%v", err)
  25766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25767. return
  25768. }
  25769. res.InfRefmsgid = resFour10265.InfRefmsgid
  25770. res.Output = resFour10265.Output
  25771. res.ErrMsg = resFour10265.ErrMsg
  25772. res.Cainfo = resFour10265.Cainfo
  25773. res.WarnMsg = resFour10265.WarnMsg
  25774. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25775. res.Infcode = infocode
  25776. } else {
  25777. 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)
  25778. var dat map[string]interface{}
  25779. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25780. fmt.Println(dat)
  25781. } else {
  25782. fmt.Println(err)
  25783. }
  25784. saveLog(result, request_log, "2204", "上传费用明细")
  25785. userJSONBytes, _ := json.Marshal(dat)
  25786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25787. utils.ErrorLog("解析失败:%v", err)
  25788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25789. return
  25790. }
  25791. }
  25792. }
  25793. if res.Infcode == 0 {
  25794. order := &models.HisOrder{
  25795. UserOrgId: adminUser.CurrentOrgId,
  25796. HisPatientId: his.ID,
  25797. PatientId: his.PatientId,
  25798. SettleAccountsDate: recordDateTime,
  25799. MdtrtId: his.Number,
  25800. PsnNo: his.PsnNo,
  25801. MedType: strconv.FormatInt(reg_type, 10),
  25802. Ctime: time.Now().Unix(),
  25803. Mtime: time.Now().Unix(),
  25804. Status: 1,
  25805. Number: chrg_bchno,
  25806. Infcode: res.Infcode,
  25807. WarnMsg: res.WarnMsg,
  25808. Cainfo: res.Cainfo,
  25809. ErrMsg: res.ErrMsg,
  25810. RespondTime: res.RefmsgTime,
  25811. InfRefmsgid: res.InfRefmsgid,
  25812. OrderStatus: 1,
  25813. PayWay: pay_way,
  25814. PayWays: pay_ways,
  25815. OthDesc: oth_desc,
  25816. PayPrice: pay_price,
  25817. PayCardNo: pay_card_no,
  25818. DiscountPrice: discount_price,
  25819. PreferentialPrice: preferential_price,
  25820. RealityPrice: reality_price,
  25821. FoundPrice: found_price,
  25822. MedicalInsurancePrice: medical_insurance_price,
  25823. PrivatePrice: private_price,
  25824. IsMedicineInsurance: 1,
  25825. SettleType: settle_accounts_type,
  25826. SettleStartTime: start_time,
  25827. SettleEndTime: end_time,
  25828. Creator: roles.AdminUserId,
  25829. Modify: roles.AdminUserId,
  25830. FaPiaoNumber: fapiao_number,
  25831. FaPiaoCode: fapiao_code,
  25832. PType: 2,
  25833. Diagnosis: diagnosis_id,
  25834. CashPay: cash_pay,
  25835. WechatPay: wechat_pay,
  25836. AliPay: ali_pay,
  25837. JifenPay: jifen_pay,
  25838. BandCardPay: band_card_pay,
  25839. }
  25840. err = service.CreateOrder(order)
  25841. if err != nil {
  25842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25843. return
  25844. }
  25845. for _, item := range res.Output.Result {
  25846. temp := strings.Split(item.FeedetlSn, "-")
  25847. var advice_id int64 = 0
  25848. var project_id int64 = 0
  25849. var types int64 = 0
  25850. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25851. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25852. if temp[1] == "1" {
  25853. advice_id = id
  25854. project_id = 0
  25855. } else if temp[1] == "2" {
  25856. advice_id = 0
  25857. project_id = id
  25858. }
  25859. if item.MedChrgitmType == "9" {
  25860. item.MedChrgitmType = "09"
  25861. }
  25862. info := &models.HisOrderInfo{
  25863. OrderNumber: order.Number,
  25864. FeedetlSn: item.FeedetlSn,
  25865. UploadDate: time.Now().Unix(),
  25866. AdviceId: advice_id,
  25867. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25868. Cnt: item.Cnt,
  25869. Pric: float64(item.Pric),
  25870. PatientId: his.PatientId,
  25871. PricUplmtAmt: item.PricUplmtAmt,
  25872. SelfpayProp: item.SelfpayProp,
  25873. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25874. OverlmtAmt: item.OverlmtAmt,
  25875. PreselfpayAmt: item.PreselfpayAmt,
  25876. BasMednFlag: item.BasMednFlag,
  25877. MedChrgitmType: item.MedChrgitmType,
  25878. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25879. Status: 1,
  25880. Memo: item.Memo,
  25881. Mtime: time.Now().Unix(),
  25882. InscpScpAmt: item.InscpScpAmt,
  25883. DrtReimFlag: item.DrtReimFlag,
  25884. Ctime: time.Now().Unix(),
  25885. ListSpItemFlag: item.ListSpItemFlag,
  25886. ChldMedcFlag: item.ChldMedcFlag,
  25887. LmtUsedFlag: item.LmtUsedFlag,
  25888. ChrgitmLv: item.ChrgitmLv,
  25889. UserOrgId: adminUser.CurrentOrgId,
  25890. HisPatientId: his.ID,
  25891. OrderId: order.ID,
  25892. ProjectId: project_id,
  25893. Type: types,
  25894. }
  25895. service.CreateOrderInfo(info)
  25896. }
  25897. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25898. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25899. var total float64
  25900. for _, item := range prescriptions {
  25901. if item.Type == 1 { //药品
  25902. for _, subItem := range item.HisDoctorAdviceInfo {
  25903. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25904. total_one := price * subItem.PrescribingNumber
  25905. total = total + total_one
  25906. }
  25907. }
  25908. if item.Type == 2 { //项目
  25909. for _, subItem := range item.HisPrescriptionProject {
  25910. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25911. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25912. total_one := price * cnt
  25913. total = total + total_one
  25914. }
  25915. }
  25916. }
  25917. allTotal := fmt.Sprintf("%.2f", total)
  25918. //if adminUser.CurrentOrgId == 9919 {
  25919. //
  25920. // allTotal = fmt.Sprintf("%.2f", total)
  25921. //
  25922. //} else {
  25923. //
  25924. // allTotal = fmt.Sprintf("%.2f", total)
  25925. //
  25926. //}
  25927. if res.Infcode == 0 {
  25928. var rf []*ResultFive
  25929. json.Unmarshal([]byte(his.Iinfo), &rf)
  25930. chrg_bchno := chrg_bchno
  25931. cert_no := his.Certno
  25932. var insutypes []string
  25933. var insutype string
  25934. var is390 int = 0
  25935. var is310 int = 0
  25936. for _, item := range rf {
  25937. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25938. insutypes = append(insutypes, item.Insutype)
  25939. }
  25940. }
  25941. if len(insutypes) == 1 {
  25942. insutype = insutypes[0]
  25943. } else {
  25944. for _, i := range insutypes {
  25945. if i == "390" {
  25946. is390 = 1
  25947. }
  25948. if i == "310" {
  25949. is310 = 1
  25950. }
  25951. }
  25952. }
  25953. if is390 == 1 {
  25954. insutype = "390"
  25955. }
  25956. if is310 == 1 {
  25957. insutype = "310"
  25958. }
  25959. if len(insutypes) == 0 {
  25960. insutype = "310"
  25961. }
  25962. if len(insutypes) == 2 {
  25963. insutype = strconv.FormatInt(his.SocialType, 10)
  25964. }
  25965. insutype = strconv.FormatInt(his.SocialType, 10)
  25966. //insutype = "390"
  25967. if his.IdCardType == 1 {
  25968. // cert_no = his.MedicalInsuranceNumber
  25969. cert_no = his.Certno
  25970. } else {
  25971. cert_no = his.Certno
  25972. }
  25973. var res ResultSeven
  25974. var resSeven10265 ResultSeven10265
  25975. var gzresSeven10265Two GZResultSeven10265Two
  25976. var src_resquest string
  25977. var result2 string
  25978. if miConfig.MdtrtareaAdmvs == "421300" {
  25979. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25980. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25981. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25983. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25984. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25985. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25986. resp, requestErr := http.Get(api)
  25987. if requestErr != nil {
  25988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25989. return
  25990. }
  25991. body, ioErr := ioutil.ReadAll(resp.Body)
  25992. if ioErr != nil {
  25993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. var respJSON map[string]interface{}
  25998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26001. return
  26002. }
  26003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26004. result, _ := json.Marshal(respJSON)
  26005. if miConfig.Code == "H15049901371" {
  26006. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26007. utils.ErrorLog("解析失败:%v", err)
  26008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26009. return
  26010. }
  26011. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26012. res.Output = resSeven10265.Output
  26013. res.ErrMsg = resSeven10265.ErrMsg
  26014. res.Cainfo = resSeven10265.Cainfo
  26015. res.WarnMsg = resSeven10265.WarnMsg
  26016. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26017. res.Infcode = infocode
  26018. } else {
  26019. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26020. utils.ErrorLog("解析失败:%v", err)
  26021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26022. return
  26023. }
  26024. }
  26025. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26026. if reg_type == 11 && his.Insutype == "390" {
  26027. reg_type = 110104
  26028. }
  26029. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26030. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26031. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26033. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26034. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26035. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26036. resp, requestErr := http.Get(api)
  26037. if requestErr != nil {
  26038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26039. return
  26040. }
  26041. body, ioErr := ioutil.ReadAll(resp.Body)
  26042. if ioErr != nil {
  26043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26045. return
  26046. }
  26047. var respJSON map[string]interface{}
  26048. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26051. return
  26052. }
  26053. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26054. result, _ := json.Marshal(respJSON)
  26055. if miConfig.Code == "H15049901371" {
  26056. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26057. utils.ErrorLog("解析失败:%v", err)
  26058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26059. return
  26060. }
  26061. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26062. res.Output = resSeven10265.Output
  26063. res.ErrMsg = resSeven10265.ErrMsg
  26064. res.Cainfo = resSeven10265.Cainfo
  26065. res.WarnMsg = resSeven10265.WarnMsg
  26066. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26067. res.Infcode = infocode
  26068. } else {
  26069. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26070. utils.ErrorLog("解析失败:%v", err)
  26071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26072. return
  26073. }
  26074. }
  26075. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26076. if reg_type == 11 && his.Insutype == "390" {
  26077. reg_type = 110104
  26078. }
  26079. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26080. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26081. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26083. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26084. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26085. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26086. resp, requestErr := http.Get(api)
  26087. if requestErr != nil {
  26088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26089. return
  26090. }
  26091. body, ioErr := ioutil.ReadAll(resp.Body)
  26092. if ioErr != nil {
  26093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26095. return
  26096. }
  26097. var respJSON map[string]interface{}
  26098. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26101. return
  26102. }
  26103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26104. result, _ := json.Marshal(respJSON)
  26105. if miConfig.Code == "H15049901371" {
  26106. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26107. utils.ErrorLog("解析失败:%v", err)
  26108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26109. return
  26110. }
  26111. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26112. res.Output = resSeven10265.Output
  26113. res.ErrMsg = resSeven10265.ErrMsg
  26114. res.Cainfo = resSeven10265.Cainfo
  26115. res.WarnMsg = resSeven10265.WarnMsg
  26116. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26117. res.Infcode = infocode
  26118. } else {
  26119. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26120. utils.ErrorLog("解析失败:%v", err)
  26121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26122. return
  26123. }
  26124. }
  26125. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26126. if reg_type == 11 && his.Insutype == "390" {
  26127. reg_type = 110104
  26128. }
  26129. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26130. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26131. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26133. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26134. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26135. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26136. resp, requestErr := http.Get(api)
  26137. if requestErr != nil {
  26138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26139. return
  26140. }
  26141. body, ioErr := ioutil.ReadAll(resp.Body)
  26142. if ioErr != nil {
  26143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26145. return
  26146. }
  26147. var respJSON map[string]interface{}
  26148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26151. return
  26152. }
  26153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26154. result, _ := json.Marshal(respJSON)
  26155. if miConfig.Code == "H15049901371" {
  26156. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26157. utils.ErrorLog("解析失败:%v", err)
  26158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26159. return
  26160. }
  26161. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26162. res.Output = resSeven10265.Output
  26163. res.ErrMsg = resSeven10265.ErrMsg
  26164. res.Cainfo = resSeven10265.Cainfo
  26165. res.WarnMsg = resSeven10265.WarnMsg
  26166. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26167. res.Infcode = infocode
  26168. } else {
  26169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26170. utils.ErrorLog("解析失败:%v", err)
  26171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26172. return
  26173. }
  26174. }
  26175. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26176. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26177. if result3101.Infcode == "0" {
  26178. if len(result3101.Output.Result) > 0 {
  26179. var errMsgs []string
  26180. for _, item := range result3101.Output.Result {
  26181. errMsgs = append(errMsgs, item.VolaCont)
  26182. }
  26183. c.ServeSuccessJSON(map[string]interface{}{
  26184. "failed_code": -10,
  26185. "msg": errMsgs,
  26186. })
  26187. return
  26188. } else {
  26189. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26190. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26191. bas := strings.Split(psn_info.CardInfo, "|")
  26192. if his.IdCardType == 1 {
  26193. cert_no = bas[2]
  26194. } else if his.IdCardType == 3 {
  26195. cert_no = his.Certno
  26196. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26197. } else if his.IdCardType == 4 {
  26198. cert_no = his.Certno
  26199. psn_info.VerifyNumber = psn_info.VerifyNumber
  26200. }
  26201. var api string
  26202. if miConfig.MdtrtareaAdmvs == "320921" {
  26203. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26204. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26205. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26206. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26207. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26208. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26209. "&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
  26210. } else {
  26211. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26212. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26213. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26214. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26215. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26216. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26217. "&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
  26218. }
  26219. resp, requestErr := http.Get(api)
  26220. if requestErr != nil {
  26221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26222. return
  26223. }
  26224. body, ioErr := ioutil.ReadAll(resp.Body)
  26225. if ioErr != nil {
  26226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26228. return
  26229. }
  26230. var respJSON map[string]interface{}
  26231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26234. return
  26235. }
  26236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26237. result, _ := json.Marshal(respJSON)
  26238. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26239. utils.ErrorLog("解析失败:%v", err)
  26240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26241. return
  26242. }
  26243. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26244. res.Output = resSeven10265.Output
  26245. res.ErrMsg = resSeven10265.ErrMsg
  26246. res.Cainfo = resSeven10265.Cainfo
  26247. res.WarnMsg = resSeven10265.WarnMsg
  26248. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26249. res.Infcode = infocode
  26250. }
  26251. }
  26252. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26253. psn_info, _ := service.GetPsnByPatientId(id)
  26254. var verify_number string
  26255. if psn_info.IdCardType == 4 {
  26256. verify_number = psn_info.VerifyNumber
  26257. } else if psn_info.IdCardType == 1 {
  26258. bas := strings.Split(psn_info.CardInfo, "|")
  26259. cardNumber := bas[2]
  26260. verify_number = cardNumber
  26261. } else {
  26262. psn_info.IdCardType = 2
  26263. verify_number = psn_info.Certno
  26264. }
  26265. var api string
  26266. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26267. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26268. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26269. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26270. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26271. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26272. "&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
  26273. resp, requestErr := http.Get(api)
  26274. if requestErr != nil {
  26275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26276. return
  26277. }
  26278. body, ioErr := ioutil.ReadAll(resp.Body)
  26279. if ioErr != nil {
  26280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26282. return
  26283. }
  26284. var respJSON map[string]interface{}
  26285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26288. return
  26289. }
  26290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26291. result, _ := json.Marshal(respJSON)
  26292. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26293. utils.ErrorLog("解析失败:%v", err)
  26294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26295. return
  26296. }
  26297. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26298. res.Output = resSeven10265.Output
  26299. res.ErrMsg = resSeven10265.ErrMsg
  26300. res.Cainfo = resSeven10265.Cainfo
  26301. res.WarnMsg = resSeven10265.WarnMsg
  26302. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26303. res.Infcode = infocode
  26304. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26305. var cert_no string
  26306. if his.IdCardType == 4 {
  26307. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26308. cert_no = psn_info.VerifyNumber
  26309. 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)
  26310. } else if his.IdCardType == 1 {
  26311. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26312. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26313. 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)
  26314. }
  26315. //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)
  26316. var dat map[string]interface{}
  26317. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26318. fmt.Println(dat)
  26319. } else {
  26320. fmt.Println(err)
  26321. }
  26322. saveLog(result2, src_resquest, "2207", "结算")
  26323. userJSONBytes, _ := json.Marshal(dat)
  26324. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26325. utils.ErrorLog("解析失败:%v", err)
  26326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26327. return
  26328. }
  26329. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26330. res.Output = resSeven10265.Output
  26331. res.ErrMsg = resSeven10265.ErrMsg
  26332. res.Cainfo = resSeven10265.Cainfo
  26333. res.WarnMsg = resSeven10265.WarnMsg
  26334. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26335. res.Infcode = infocode
  26336. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26337. res2 := c.GetoleInfo()
  26338. if res2.Infcode == 0 {
  26339. var result string
  26340. var request_log string
  26341. var result_log string
  26342. if res2.Output.MdtrtCertType == "02" {
  26343. 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)
  26344. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26345. } else if res2.Output.MdtrtCertType == "01" {
  26346. 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)
  26347. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26348. } else {
  26349. 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)
  26350. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26351. }
  26352. var dat map[string]interface{}
  26353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26354. fmt.Println(dat)
  26355. } else {
  26356. fmt.Println(err)
  26357. }
  26358. userJSONBytes, _ := json.Marshal(dat)
  26359. var res5 ResultTwo
  26360. //var resTwo10265 ResultTwo10265
  26361. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26362. utils.ErrorLog("解析失败:%v", err)
  26363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26364. return
  26365. }
  26366. if res5.Infcode == -1 {
  26367. c.ServeSuccessJSON(map[string]interface{}{
  26368. "failed_code": -10,
  26369. "msg": res5.ErrMsg,
  26370. })
  26371. return
  26372. }
  26373. var insutypes []string
  26374. var insutype string
  26375. var is390 int = 0
  26376. var is310 int = 0
  26377. for _, item := range res5.Output.Iinfo {
  26378. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26379. insutypes = append(insutypes, item.Insutype)
  26380. }
  26381. }
  26382. if len(insutypes) == 1 {
  26383. insutype = insutypes[0]
  26384. } else {
  26385. for _, i := range insutypes {
  26386. if i == "390" {
  26387. is390 = 1
  26388. }
  26389. if i == "310" {
  26390. is310 = 1
  26391. }
  26392. }
  26393. }
  26394. if is390 == 1 {
  26395. insutype = "390"
  26396. }
  26397. if is310 == 1 {
  26398. insutype = "310"
  26399. }
  26400. if len(insutypes) == 0 {
  26401. insutype = "310"
  26402. }
  26403. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26404. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26405. infoStr := string(Iinfos)
  26406. idetinfoStr := string(Idetinfos)
  26407. psn := &models.HisPsn{
  26408. PsnNo: res5.Output.Baseinfo.PsnNo,
  26409. PatientId: id,
  26410. Certno: res5.Output.Baseinfo.Certno,
  26411. Gend: res5.Output.Baseinfo.Gend,
  26412. Naty: res5.Output.Baseinfo.Naty,
  26413. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26414. PsnName: res5.Output.Baseinfo.PsnName,
  26415. Idetinfo: idetinfoStr,
  26416. Insuinfo: infoStr,
  26417. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26418. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26419. VerifyNumber: res2.Output.EcToken,
  26420. }
  26421. if res2.Output.MdtrtCertType == "01" {
  26422. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26423. psn.VerifyNumber = res2.Output.EcToken
  26424. } else if res2.Output.MdtrtCertType == "02" {
  26425. psn.VerifyNumber = res2.Output.CardNo
  26426. } else {
  26427. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26428. }
  26429. service.CreateHisPsn(psn)
  26430. if res2.Output.MdtrtCertType == "01" {
  26431. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26432. token := res2.Output.EcToken
  26433. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  26434. } else if res2.Output.MdtrtCertType == "02" {
  26435. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  26436. } else {
  26437. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  26438. }
  26439. var dat2 map[string]interface{}
  26440. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26441. fmt.Println(dat2)
  26442. } else {
  26443. fmt.Println(err)
  26444. }
  26445. userJSONBytes3, _ := json.Marshal(dat2)
  26446. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26447. utils.ErrorLog("解析失败:%v", err)
  26448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26449. return
  26450. }
  26451. saveLog(result2, src_resquest, "2207", "结算")
  26452. } else {
  26453. c.ServeSuccessJSON(map[string]interface{}{
  26454. "failed_code": -10,
  26455. "msg": res2.ErrMsg,
  26456. })
  26457. return
  26458. }
  26459. } else {
  26460. if miConfig.Code == "H15049901371" {
  26461. //赤峰地区国家医保医疗类别
  26462. //职工透析:医疗类别选特殊情况门诊990502
  26463. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26464. var med_type string
  26465. if his.Insutype == "390" {
  26466. if reg_type == 14 {
  26467. med_type = "9933"
  26468. } else if reg_type == 11 {
  26469. med_type = "11"
  26470. }
  26471. } else if his.Insutype == "310" {
  26472. if reg_type == 14 {
  26473. med_type = "990502"
  26474. } else if reg_type == 11 {
  26475. med_type = "11"
  26476. }
  26477. }
  26478. 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)
  26479. } else {
  26480. if his.IdCardType == 4 {
  26481. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26482. var token string
  26483. token = psn_info.VerifyNumber
  26484. 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)
  26485. } else {
  26486. if his.IdCardType == 1 {
  26487. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26488. bas := strings.Split(psn_info.CardInfo, "|")
  26489. basNumber := bas[2]
  26490. cert_no = basNumber
  26491. }
  26492. 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)
  26493. }
  26494. }
  26495. //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)
  26496. var dat map[string]interface{}
  26497. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26498. fmt.Println(dat)
  26499. } else {
  26500. fmt.Println(err)
  26501. }
  26502. saveLog(result2, src_resquest, "2207", "结算")
  26503. userJSONBytes, _ := json.Marshal(dat)
  26504. if miConfig.Code == "H15049901371" {
  26505. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26506. utils.ErrorLog("解析失败:%v", err)
  26507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26508. return
  26509. }
  26510. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26511. res.Output = resSeven10265.Output
  26512. res.ErrMsg = resSeven10265.ErrMsg
  26513. res.Cainfo = resSeven10265.Cainfo
  26514. res.WarnMsg = resSeven10265.WarnMsg
  26515. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26516. res.Infcode = infocode
  26517. } else {
  26518. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26519. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26520. utils.ErrorLog("解析失败:%v", err)
  26521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26522. return
  26523. }
  26524. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26525. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26526. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26527. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26528. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26529. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26530. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26531. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26532. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26533. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26534. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26535. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26536. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26537. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26538. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26539. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26540. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26541. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26542. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26543. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26544. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26545. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26546. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26547. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26548. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26549. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26550. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26551. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26552. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26553. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26554. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26555. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26556. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26557. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26558. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26559. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26560. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26561. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26562. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26563. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26564. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26565. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26566. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26567. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26568. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26569. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26570. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26571. res.Cainfo = gzresSeven10265Two.Cainfo
  26572. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26573. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26574. //res.Infcode = infocode
  26575. } else {
  26576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26577. utils.ErrorLog("解析失败:%v", err)
  26578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26579. return
  26580. }
  26581. }
  26582. }
  26583. }
  26584. if res.Infcode == -1 {
  26585. errlog := &models.HisOrderError{
  26586. UserOrgId: adminUser.CurrentOrgId,
  26587. Ctime: time.Now().Unix(),
  26588. Mtime: time.Now().Unix(),
  26589. Number: chrg_bchno,
  26590. ErrMsg: res.ErrMsg,
  26591. Status: 1,
  26592. PatientId: id,
  26593. RecordTime: recordDateTime,
  26594. Stage: 6,
  26595. }
  26596. service.CreateErrMsgLog(errlog)
  26597. c.ServeSuccessJSON(map[string]interface{}{
  26598. "failed_code": -10,
  26599. "msg": res.ErrMsg,
  26600. })
  26601. return
  26602. } else {
  26603. sickConfig, _ := service.FindSickById(his.SickType)
  26604. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26605. order.OrderStatus = 2
  26606. order.Status = 1
  26607. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26608. order.SetlId = res.Output.Setlinfo.SetlID
  26609. order.PsnNo = res.Output.Setlinfo.PsnNo
  26610. order.PsnName = res.Output.Setlinfo.PsnName
  26611. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26612. order.Certno = res.Output.Setlinfo.Certno
  26613. order.Gend = res.Output.Setlinfo.Gend
  26614. order.Naty = res.Output.Setlinfo.Naty
  26615. order.Age = res.Output.Setlinfo.Age
  26616. order.Insutype = res.Output.Setlinfo.Insutype
  26617. order.PsnType = res.Output.Setlinfo.PsnType
  26618. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26619. order.SetlTime = res.Output.Setlinfo.SetlTime
  26620. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26621. if res.Output.Setlinfo.MedType == "140101" {
  26622. order.MedType = "14"
  26623. } else {
  26624. if res.Output.Setlinfo.MedType == "110104" {
  26625. order.MedType = "11"
  26626. } else {
  26627. order.MedType = res.Output.Setlinfo.MedType
  26628. }
  26629. }
  26630. if reg_type == 1112 {
  26631. order.MedType = "1112"
  26632. }
  26633. if reg_type == 1111 {
  26634. order.MedType = "1111"
  26635. }
  26636. order.ClrType = res.Output.Setlinfo.ClrType
  26637. if adminUser.CurrentOrgId == 10480 {
  26638. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26639. order.ClrType = "11"
  26640. } else {
  26641. order.ClrType = "9903"
  26642. }
  26643. }
  26644. if adminUser.CurrentOrgId == 10721 {
  26645. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26646. order.ClrType = "11"
  26647. } else {
  26648. order.ClrType = "9903"
  26649. }
  26650. }
  26651. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26652. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26653. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26654. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26655. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26656. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26657. order.HifpPay = res.Output.Setlinfo.HifpPay
  26658. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26659. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26660. order.HifesPay = res.Output.Setlinfo.HifesPay
  26661. order.HifobPay = res.Output.Setlinfo.HifobPay
  26662. order.MafPay = res.Output.Setlinfo.MafPay
  26663. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26664. order.OthPay = res.Output.Setlinfo.OthPay
  26665. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26666. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26667. order.AcctPay = res.Output.Setlinfo.AcctPay
  26668. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26669. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26670. order.Balc = res.Output.Setlinfo.Balc
  26671. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26672. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26673. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26674. //order.ClrType = res.Output.Setlinfo.ClrType
  26675. order.ClrWay = res.Output.Setlinfo.ClrWay
  26676. order.Creator = order.Creator
  26677. order.Modify = roles.AdminUserId
  26678. order.RequestLog = src_resquest
  26679. order.FaPiaoNumber = fapiao_number
  26680. order.FaPiaoCode = fapiao_code
  26681. order.SickName = sickConfig.ClassName
  26682. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26683. //detailStr := string(setlDetail)
  26684. //order.SetlDetail = detailStr
  26685. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26686. err = service.UpDateOrder(order)
  26687. if err == nil {
  26688. //判断是否使用了押金
  26689. if dec_way == "true" {
  26690. tmpstring := strconv.FormatInt(order.ID, 10)
  26691. order.Decimal = decimal
  26692. service.UpDateOrder(order)
  26693. //扣押金
  26694. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26695. if errmsg != nil {
  26696. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26697. return
  26698. }
  26699. }
  26700. c.ServeSuccessJSON(map[string]interface{}{
  26701. "msg": "结算成功",
  26702. })
  26703. } else {
  26704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26705. return
  26706. }
  26707. }
  26708. } else {
  26709. adminUser := c.GetAdminUserInfo()
  26710. errlog := &models.HisOrderError{
  26711. UserOrgId: adminUser.CurrentOrgId,
  26712. Ctime: time.Now().Unix(),
  26713. Mtime: time.Now().Unix(),
  26714. ErrMsg: res.ErrMsg,
  26715. Status: 1,
  26716. PatientId: id,
  26717. RecordTime: recordDateTime,
  26718. Stage: 4,
  26719. }
  26720. service.CreateErrMsgLog(errlog)
  26721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26722. return
  26723. }
  26724. } else {
  26725. adminUser := c.GetAdminUserInfo()
  26726. errlog := &models.HisOrderError{
  26727. UserOrgId: adminUser.CurrentOrgId,
  26728. Ctime: time.Now().Unix(),
  26729. Mtime: time.Now().Unix(),
  26730. ErrMsg: res.ErrMsg,
  26731. Status: 1,
  26732. PatientId: id,
  26733. RecordTime: recordDateTime,
  26734. Stage: 4,
  26735. }
  26736. service.CreateErrMsgLog(errlog)
  26737. c.ServeSuccessJSON(map[string]interface{}{
  26738. "failed_code": -10,
  26739. "msg": res.ErrMsg,
  26740. })
  26741. return
  26742. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26743. //return
  26744. }
  26745. }
  26746. }
  26747. } else if tempOrder.ID > 0 {
  26748. if tempOrder.IsPre == 1 {
  26749. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26750. var rf []*ResultFive
  26751. json.Unmarshal([]byte(his.Iinfo), &rf)
  26752. chrg_bchno := tempOrder.Number
  26753. cert_no := his.Certno
  26754. var insutypes []string
  26755. var insutype string
  26756. var is390 int = 0
  26757. var is310 int = 0
  26758. for _, item := range rf {
  26759. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26760. insutypes = append(insutypes, item.Insutype)
  26761. }
  26762. }
  26763. if len(insutypes) == 1 {
  26764. insutype = insutypes[0]
  26765. } else {
  26766. for _, i := range insutypes {
  26767. if i == "390" {
  26768. is390 = 1
  26769. }
  26770. if i == "310" {
  26771. is310 = 1
  26772. }
  26773. }
  26774. }
  26775. if is390 == 1 {
  26776. insutype = "390"
  26777. }
  26778. if is310 == 1 {
  26779. insutype = "310"
  26780. }
  26781. if len(insutypes) == 0 {
  26782. insutype = "310"
  26783. }
  26784. if len(insutypes) == 2 {
  26785. insutype = strconv.FormatInt(his.SocialType, 10)
  26786. }
  26787. //insutype = "390"
  26788. if his.IdCardType == 1 {
  26789. // cert_no = his.MedicalInsuranceNumber
  26790. cert_no = his.Certno
  26791. } else {
  26792. cert_no = his.Certno
  26793. }
  26794. var res ResultSeven
  26795. var ahres ResultSevenAH
  26796. var resSeven10265 ResultSeven10265
  26797. var gzresSeven10265Two GZResultSeven10265Two
  26798. var src_resquest string
  26799. var result2 string
  26800. if miConfig.MdtrtareaAdmvs == "450721" {
  26801. res2 := c.GetoleInfo()
  26802. if res2.Infcode == 0 {
  26803. var result string
  26804. var request_log string
  26805. var result_log string
  26806. if res2.Output.MdtrtCertType == "02" {
  26807. 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)
  26808. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26809. } else if res2.Output.MdtrtCertType == "01" {
  26810. 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)
  26811. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26812. } else {
  26813. 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)
  26814. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26815. }
  26816. var dat map[string]interface{}
  26817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26818. fmt.Println(dat)
  26819. } else {
  26820. fmt.Println(err)
  26821. }
  26822. userJSONBytes, _ := json.Marshal(dat)
  26823. var res5 ResultTwo
  26824. //var resTwo10265 ResultTwo10265
  26825. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26826. utils.ErrorLog("解析失败:%v", err)
  26827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26828. return
  26829. }
  26830. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26831. if res5.Infcode == -1 {
  26832. c.ServeSuccessJSON(map[string]interface{}{
  26833. "failed_code": -10,
  26834. "msg": res5.ErrMsg,
  26835. })
  26836. return
  26837. }
  26838. var insutypes []string
  26839. var insutype string
  26840. var is390 int = 0
  26841. var is310 int = 0
  26842. for _, item := range res5.Output.Iinfo {
  26843. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26844. insutypes = append(insutypes, item.Insutype)
  26845. }
  26846. }
  26847. if len(insutypes) == 1 {
  26848. insutype = insutypes[0]
  26849. } else {
  26850. for _, i := range insutypes {
  26851. if i == "390" {
  26852. is390 = 1
  26853. }
  26854. if i == "310" {
  26855. is310 = 1
  26856. }
  26857. }
  26858. }
  26859. if is390 == 1 {
  26860. insutype = "390"
  26861. }
  26862. if is310 == 1 {
  26863. insutype = "310"
  26864. }
  26865. if len(insutypes) == 0 {
  26866. insutype = "310"
  26867. }
  26868. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26869. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26870. infoStr := string(Iinfos)
  26871. idetinfoStr := string(Idetinfos)
  26872. psn := &models.HisPsn{
  26873. PsnNo: res5.Output.Baseinfo.PsnNo,
  26874. PatientId: id,
  26875. Certno: res5.Output.Baseinfo.Certno,
  26876. Gend: res5.Output.Baseinfo.Gend,
  26877. Naty: res5.Output.Baseinfo.Naty,
  26878. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26879. PsnName: res5.Output.Baseinfo.PsnName,
  26880. Idetinfo: idetinfoStr,
  26881. Insuinfo: infoStr,
  26882. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26883. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26884. VerifyNumber: res2.Output.EcToken,
  26885. }
  26886. service.CreateHisPsn(psn)
  26887. if res2.Output.MdtrtCertType == "01" {
  26888. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26889. token := res2.Output.EcToken
  26890. 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)
  26891. } else if res2.Output.MdtrtCertType == "02" {
  26892. 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)
  26893. } else {
  26894. 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)
  26895. }
  26896. var dat2 map[string]interface{}
  26897. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26898. fmt.Println(dat2)
  26899. } else {
  26900. fmt.Println(err)
  26901. }
  26902. userJSONBytes3, _ := json.Marshal(dat2)
  26903. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26904. utils.ErrorLog("解析失败:%v", err)
  26905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26906. return
  26907. }
  26908. saveLog(result2, src_resquest, "2207", "结算")
  26909. } else {
  26910. c.ServeSuccessJSON(map[string]interface{}{
  26911. "failed_code": -10,
  26912. "msg": res2.ErrMsg,
  26913. })
  26914. return
  26915. }
  26916. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26917. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26918. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26919. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26920. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26921. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26922. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26923. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26924. resp, requestErr := http.Get(api)
  26925. if requestErr != nil {
  26926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26927. return
  26928. }
  26929. body, ioErr := ioutil.ReadAll(resp.Body)
  26930. if ioErr != nil {
  26931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26933. return
  26934. }
  26935. var respJSON map[string]interface{}
  26936. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26939. return
  26940. }
  26941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26942. result, _ := json.Marshal(respJSON)
  26943. fmt.Println("log")
  26944. fmt.Println(string(result))
  26945. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26946. utils.ErrorLog("解析失败:%v", err)
  26947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26948. return
  26949. }
  26950. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26951. if reg_type == 11 && his.Insutype == "390" {
  26952. reg_type = 110104
  26953. }
  26954. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26955. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26956. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26958. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26959. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26960. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26961. resp, requestErr := http.Get(api)
  26962. if requestErr != nil {
  26963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26964. return
  26965. }
  26966. body, ioErr := ioutil.ReadAll(resp.Body)
  26967. if ioErr != nil {
  26968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26970. return
  26971. }
  26972. var respJSON map[string]interface{}
  26973. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26976. return
  26977. }
  26978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26979. result, _ := json.Marshal(respJSON)
  26980. fmt.Println("log")
  26981. fmt.Println(string(result))
  26982. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26983. utils.ErrorLog("解析失败:%v", err)
  26984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26985. return
  26986. }
  26987. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26988. if reg_type == 11 && his.Insutype == "390" {
  26989. reg_type = 110104
  26990. }
  26991. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26992. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26993. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26994. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26995. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26996. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26997. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26998. resp, requestErr := http.Get(api)
  26999. if requestErr != nil {
  27000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27001. return
  27002. }
  27003. body, ioErr := ioutil.ReadAll(resp.Body)
  27004. if ioErr != nil {
  27005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27007. return
  27008. }
  27009. var respJSON map[string]interface{}
  27010. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27013. return
  27014. }
  27015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27016. result, _ := json.Marshal(respJSON)
  27017. fmt.Println("log")
  27018. fmt.Println(string(result))
  27019. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27020. utils.ErrorLog("解析失败:%v", err)
  27021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27022. return
  27023. }
  27024. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27025. if reg_type == 11 && his.Insutype == "390" {
  27026. reg_type = 110104
  27027. }
  27028. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27029. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27030. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27031. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27032. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27033. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27034. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27035. resp, requestErr := http.Get(api)
  27036. if requestErr != nil {
  27037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27038. return
  27039. }
  27040. body, ioErr := ioutil.ReadAll(resp.Body)
  27041. if ioErr != nil {
  27042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27044. return
  27045. }
  27046. var respJSON map[string]interface{}
  27047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27050. return
  27051. }
  27052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27053. result, _ := json.Marshal(respJSON)
  27054. fmt.Println("log")
  27055. fmt.Println(string(result))
  27056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27057. utils.ErrorLog("解析失败:%v", err)
  27058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27059. return
  27060. }
  27061. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27062. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27063. if result3101.Infcode == "0" {
  27064. if len(result3101.Output.Result) > 0 {
  27065. var errMsgs []string
  27066. for _, item := range result3101.Output.Result {
  27067. errMsgs = append(errMsgs, item.VolaCont)
  27068. }
  27069. c.ServeSuccessJSON(map[string]interface{}{
  27070. "failed_code": -10,
  27071. "msg": errMsgs,
  27072. })
  27073. return
  27074. } else {
  27075. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27076. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27077. bas := strings.Split(psn_info.CardInfo, "|")
  27078. if his.IdCardType == 1 {
  27079. cert_no = bas[2]
  27080. } else if his.IdCardType == 3 {
  27081. cert_no = his.Certno
  27082. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27083. } else if his.IdCardType == 4 {
  27084. cert_no = his.Certno
  27085. psn_info.VerifyNumber = psn_info.VerifyNumber
  27086. }
  27087. //江苏地区国家医保医疗类别
  27088. //职工透析:医疗类别选特殊情况门诊9933
  27089. //居民血透门慢: 医疗类别选门诊慢病1402
  27090. //var med_type string
  27091. //if his.Insutype == "310" {
  27092. // if reg_type == 14 {
  27093. // med_type = "9933"
  27094. // } else if reg_type == 11 {
  27095. // med_type = "11"
  27096. //
  27097. // }
  27098. //} else if his.Insutype == "390" {
  27099. // if reg_type == 14 {
  27100. // med_type = "1402"
  27101. // } else if reg_type == 11 {
  27102. // med_type = "11"
  27103. // }
  27104. //}
  27105. var api string
  27106. if miConfig.MdtrtareaAdmvs == "320921" {
  27107. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27108. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27109. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27110. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27111. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27112. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27113. "&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
  27114. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27115. } else {
  27116. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27117. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27118. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27119. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27120. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27121. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27122. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27123. "&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
  27124. }
  27125. resp, requestErr := http.Get(api)
  27126. if requestErr != nil {
  27127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27128. return
  27129. }
  27130. body, ioErr := ioutil.ReadAll(resp.Body)
  27131. if ioErr != nil {
  27132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27134. return
  27135. }
  27136. var respJSON map[string]interface{}
  27137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27140. return
  27141. }
  27142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27143. result, _ := json.Marshal(respJSON)
  27144. fmt.Println("log")
  27145. fmt.Println(string(result))
  27146. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27147. utils.ErrorLog("解析失败:%v", err)
  27148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27149. return
  27150. }
  27151. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27152. res.Output = resSeven10265.Output
  27153. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27154. res.ErrMsg = resSeven10265.ErrMsg
  27155. res.Cainfo = resSeven10265.Cainfo
  27156. res.WarnMsg = resSeven10265.WarnMsg
  27157. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27158. res.Infcode = infocode
  27159. }
  27160. }
  27161. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27162. psn_info, _ := service.GetPsnByPatientId(id)
  27163. var verify_number string
  27164. if psn_info.IdCardType == 4 {
  27165. verify_number = psn_info.VerifyNumber
  27166. } else if psn_info.IdCardType == 1 {
  27167. bas := strings.Split(psn_info.CardInfo, "|")
  27168. cardNumber := bas[2]
  27169. verify_number = cardNumber
  27170. } else {
  27171. verify_number = psn_info.Certno
  27172. psn_info.IdCardType = 2
  27173. }
  27174. var api string
  27175. new_chrg_bchno := chrg_bchno
  27176. if adminUser.CurrentOrgId == 10265 {
  27177. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27178. new_chrg_bchno = "0000"
  27179. }
  27180. }
  27181. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27182. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27183. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27184. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27185. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27186. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27187. "&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
  27188. resp, requestErr := http.Get(api)
  27189. if requestErr != nil {
  27190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27191. return
  27192. }
  27193. body, ioErr := ioutil.ReadAll(resp.Body)
  27194. if ioErr != nil {
  27195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27197. return
  27198. }
  27199. var respJSON map[string]interface{}
  27200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27203. return
  27204. }
  27205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27206. result, _ := json.Marshal(respJSON)
  27207. fmt.Println("log")
  27208. fmt.Println(string(result))
  27209. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27210. utils.ErrorLog("解析失败:%v", err)
  27211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27212. return
  27213. }
  27214. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27215. res.Output = resSeven10265.Output
  27216. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27217. res.ErrMsg = resSeven10265.ErrMsg
  27218. res.Cainfo = resSeven10265.Cainfo
  27219. res.WarnMsg = resSeven10265.WarnMsg
  27220. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27221. res.Infcode = infocode
  27222. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27223. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27224. var cert_no string
  27225. if his.IdCardType == 1 {
  27226. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27227. } else {
  27228. cert_no = psn_info.VerifyNumber
  27229. }
  27230. 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)
  27231. var dat map[string]interface{}
  27232. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27233. fmt.Println(dat)
  27234. } else {
  27235. fmt.Println(err)
  27236. }
  27237. saveLog(result2, src_resquest, "2207", "结算")
  27238. userJSONBytes, _ := json.Marshal(dat)
  27239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27240. utils.ErrorLog("解析失败:%v", err)
  27241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27242. return
  27243. }
  27244. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27245. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27246. var cert_no string
  27247. var card_sn string
  27248. if his.IdCardType == 1 {
  27249. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27250. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27251. bas := strings.Split(psn_info.CardInfo, "|")
  27252. card_sn = bas[3]
  27253. } else if his.IdCardType == 2 {
  27254. cert_no = his.IdCardNo
  27255. } else {
  27256. cert_no = psn_info.VerifyNumber
  27257. }
  27258. var rf []*ResultFive
  27259. json.Unmarshal([]byte(his.Iinfo), &rf)
  27260. var psn_type string
  27261. for _, item := range rf {
  27262. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27263. psn_type = item.PsnType
  27264. }
  27265. }
  27266. 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)
  27267. var dat map[string]interface{}
  27268. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27269. fmt.Println(dat)
  27270. } else {
  27271. fmt.Println(err)
  27272. }
  27273. saveLog(result2, src_resquest, "2207", "结算")
  27274. userJSONBytes, _ := json.Marshal(dat)
  27275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27276. utils.ErrorLog("解析失败:%v", err)
  27277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27278. return
  27279. }
  27280. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27281. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27282. var cert_no string
  27283. var card_sn string
  27284. if his.IdCardType == 1 {
  27285. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27286. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27287. //bas := strings.Split(psn_info.CardInfo, "|")
  27288. card_sn = ""
  27289. } else if his.IdCardType == 2 {
  27290. cert_no = his.IdCardNo
  27291. } else {
  27292. cert_no = psn_info.VerifyNumber
  27293. }
  27294. var rf []*ResultFive
  27295. json.Unmarshal([]byte(his.Iinfo), &rf)
  27296. var psn_type string
  27297. for _, item := range rf {
  27298. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27299. psn_type = item.PsnType
  27300. }
  27301. }
  27302. 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)
  27303. var dat map[string]interface{}
  27304. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27305. fmt.Println(dat)
  27306. } else {
  27307. fmt.Println(err)
  27308. }
  27309. saveLog(result2, src_resquest, "2207", "结算")
  27310. userJSONBytes, _ := json.Marshal(dat)
  27311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27312. utils.ErrorLog("解析失败:%v", err)
  27313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27314. return
  27315. }
  27316. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27317. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27318. if his.IdCardType == 1 {
  27319. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27320. bas := strings.Split(psn_info.CardInfo, "|")
  27321. cert_no = bas[2]
  27322. } else if his.IdCardType == 3 {
  27323. cert_no = his.Certno
  27324. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27325. } else if his.IdCardType == 4 {
  27326. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27327. cert_no = psn_info.VerifyNumber
  27328. psn_info.VerifyNumber = psn_info.VerifyNumber
  27329. } else {
  27330. cert_no = his.Certno
  27331. psn_info.VerifyNumber = his.Certno
  27332. }
  27333. var api string
  27334. var med_type string
  27335. if his.Insutype == "390" {
  27336. if reg_type == 992102 {
  27337. med_type = "992102"
  27338. }
  27339. if reg_type == 140104 {
  27340. med_type = "140104"
  27341. }
  27342. if reg_type == 140201 {
  27343. med_type = "140201"
  27344. }
  27345. if reg_type == 14 {
  27346. med_type = "14"
  27347. }
  27348. } else if his.Insutype == "310" {
  27349. if reg_type == 992102 {
  27350. med_type = "992102"
  27351. }
  27352. if reg_type == 140104 {
  27353. med_type = "140104"
  27354. }
  27355. if reg_type == 140201 {
  27356. med_type = "140201"
  27357. }
  27358. if reg_type == 14 {
  27359. med_type = "14"
  27360. }
  27361. }
  27362. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27363. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27364. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27366. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27367. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27368. "&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
  27369. resp, requestErr := http.Get(api)
  27370. if requestErr != nil {
  27371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27372. return
  27373. }
  27374. body, ioErr := ioutil.ReadAll(resp.Body)
  27375. if ioErr != nil {
  27376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27378. return
  27379. }
  27380. var respJSON map[string]interface{}
  27381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27384. return
  27385. }
  27386. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27387. if status == "0" {
  27388. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27389. c.ServeSuccessJSON(map[string]interface{}{
  27390. "failed_code": -10,
  27391. "msg": err_msg,
  27392. })
  27393. return
  27394. }
  27395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27396. result, _ := json.Marshal(respJSON)
  27397. fmt.Println("log")
  27398. fmt.Println(string(result))
  27399. if err := json.Unmarshal(result, &ahres); err != nil {
  27400. utils.ErrorLog("解析失败:%v", err)
  27401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27402. return
  27403. }
  27404. res.InfRefmsgid = ahres.InfRefmsgid
  27405. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27406. // 创建对应的Time类型
  27407. t := time.UnixMilli(timestamp)
  27408. // 格式化成指定的日期字符串
  27409. str := t.Format("2006-01-02 15:04:05")
  27410. res.Output.Setlinfo.SetlTime = str
  27411. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27412. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27413. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27414. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27415. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27416. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27417. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27418. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27419. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27420. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27421. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27422. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27423. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27424. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27425. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27426. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27427. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27428. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27429. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27430. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27431. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27432. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27433. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27434. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27435. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27436. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27437. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27438. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27439. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27440. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27441. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27442. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27443. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27444. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27445. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27446. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27447. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27448. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27449. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27450. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27451. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27452. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27453. res.Output.Setldetail = ahres.Output.Setldetail
  27454. res.ErrMsg = ahres.ErrMsg
  27455. res.Cainfo = ahres.Cainfo
  27456. res.WarnMsg = ahres.WarnMsg
  27457. res.Infcode = ahres.Infcode
  27458. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27459. res.Output.Setlinfo.ClrType = "11"
  27460. } else {
  27461. res.Output.Setlinfo.ClrType = "9903"
  27462. }
  27463. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27464. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27465. if his.IdCardType == 1 {
  27466. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27467. bas := strings.Split(psn_info.CardInfo, "|")
  27468. cert_no = bas[2]
  27469. } else if his.IdCardType == 3 {
  27470. cert_no = his.Certno
  27471. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27472. } else if his.IdCardType == 4 {
  27473. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27474. cert_no = his.Certno
  27475. psn_info.VerifyNumber = psn_info.VerifyNumber
  27476. } else {
  27477. cert_no = his.Certno
  27478. psn_info.VerifyNumber = his.Certno
  27479. }
  27480. var api string
  27481. var med_type string
  27482. if his.Insutype == "390" {
  27483. if reg_type == 992102 {
  27484. med_type = "992102"
  27485. }
  27486. if reg_type == 140104 {
  27487. med_type = "140104"
  27488. }
  27489. if reg_type == 14 {
  27490. med_type = "14"
  27491. }
  27492. if reg_type == 140201 {
  27493. med_type = "140201"
  27494. }
  27495. } else if his.Insutype == "310" {
  27496. if reg_type == 992102 {
  27497. med_type = "992102"
  27498. }
  27499. if reg_type == 14 {
  27500. med_type = "14"
  27501. }
  27502. if reg_type == 140104 {
  27503. med_type = "140104"
  27504. }
  27505. if reg_type == 140201 {
  27506. med_type = "140201"
  27507. }
  27508. }
  27509. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27510. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27511. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27512. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27513. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27514. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27515. "&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
  27516. resp, requestErr := http.Get(api)
  27517. if requestErr != nil {
  27518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27519. return
  27520. }
  27521. body, ioErr := ioutil.ReadAll(resp.Body)
  27522. if ioErr != nil {
  27523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27525. return
  27526. }
  27527. var respJSON map[string]interface{}
  27528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27531. return
  27532. }
  27533. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27534. if status == "0" {
  27535. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27536. c.ServeSuccessJSON(map[string]interface{}{
  27537. "failed_code": -10,
  27538. "msg": err_msg,
  27539. })
  27540. return
  27541. }
  27542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27543. result, _ := json.Marshal(respJSON)
  27544. fmt.Println("log")
  27545. fmt.Println(string(result))
  27546. if err := json.Unmarshal(result, &ahres); err != nil {
  27547. utils.ErrorLog("解析失败:%v", err)
  27548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27549. return
  27550. }
  27551. res.InfRefmsgid = ahres.InfRefmsgid
  27552. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27553. // 创建对应的Time类型
  27554. t := time.UnixMilli(timestamp)
  27555. // 格式化成指定的日期字符串
  27556. str := t.Format("2006-01-02 15:04:05")
  27557. res.Output.Setlinfo.SetlTime = str
  27558. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27559. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27560. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27561. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27562. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27563. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27564. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27565. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27566. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27567. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27568. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27569. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27570. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27571. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27572. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27573. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27574. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27575. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27576. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27577. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27578. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27579. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27580. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27581. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27582. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27583. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27584. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27585. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27586. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27587. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27588. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27589. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27590. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27591. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27592. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27593. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27594. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27595. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27596. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27597. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27598. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27599. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27600. res.Output.Setldetail = ahres.Output.Setldetail
  27601. res.ErrMsg = ahres.ErrMsg
  27602. res.Cainfo = ahres.Cainfo
  27603. res.WarnMsg = ahres.WarnMsg
  27604. res.Infcode = ahres.Infcode
  27605. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27606. res.Output.Setlinfo.ClrType = "11"
  27607. } else {
  27608. res.Output.Setlinfo.ClrType = "9903"
  27609. }
  27610. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27611. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27612. var cert_no string
  27613. if his.IdCardType == 1 {
  27614. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27615. } else if his.IdCardType == 2 {
  27616. cert_no = his.IdCardNo
  27617. } else {
  27618. cert_no = psn_info.VerifyNumber
  27619. }
  27620. 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, "")
  27621. var dat map[string]interface{}
  27622. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27623. fmt.Println(dat)
  27624. } else {
  27625. fmt.Println(err)
  27626. }
  27627. saveLog(result2, src_resquest, "2207", "结算")
  27628. userJSONBytes, _ := json.Marshal(dat)
  27629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27630. utils.ErrorLog("解析失败:%v", err)
  27631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27632. return
  27633. }
  27634. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27635. psn_info, _ := service.GetPsnByPatientId(id)
  27636. var verify_number string
  27637. if psn_info.IdCardType == 4 {
  27638. verify_number = psn_info.VerifyNumber
  27639. } else if psn_info.IdCardType == 1 {
  27640. bas := strings.Split(psn_info.CardInfo, "|")
  27641. cardNumber := bas[2]
  27642. verify_number = cardNumber
  27643. } else {
  27644. verify_number = psn_info.Certno
  27645. psn_info.IdCardType = 2
  27646. }
  27647. var api string
  27648. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27649. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27650. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27651. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27652. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27653. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27654. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27655. resp, requestErr := http.Get(api)
  27656. if requestErr != nil {
  27657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27658. return
  27659. }
  27660. body, ioErr := ioutil.ReadAll(resp.Body)
  27661. if ioErr != nil {
  27662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27664. return
  27665. }
  27666. var respJSON map[string]interface{}
  27667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27670. return
  27671. }
  27672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27673. result, _ := json.Marshal(respJSON)
  27674. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27675. utils.ErrorLog("解析失败:%v", err)
  27676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27677. return
  27678. }
  27679. } else {
  27680. var src_resquest string
  27681. if miConfig.Code == "H15049901371" {
  27682. //赤峰地区国家医保医疗类别
  27683. //职工透析:医疗类别选特殊情况门诊990502
  27684. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27685. var med_type string
  27686. if his.Insutype == "390" {
  27687. if reg_type == 14 {
  27688. med_type = "9933"
  27689. } else if reg_type == 11 {
  27690. med_type = "11"
  27691. }
  27692. } else if his.Insutype == "310" {
  27693. if reg_type == 14 {
  27694. med_type = "990502"
  27695. } else if reg_type == 11 {
  27696. med_type = "11"
  27697. }
  27698. }
  27699. 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)
  27700. } else {
  27701. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  27702. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27703. if result3101.Infcode == 0 {
  27704. if len(result3101.Output.Result) > 0 {
  27705. c.ServeSuccessJSON(map[string]interface{}{
  27706. "failed_code": -10,
  27707. "failed_type": 100,
  27708. "msg": result3101.Output.Result,
  27709. })
  27710. return
  27711. }
  27712. } else {
  27713. c.ServeSuccessJSON(map[string]interface{}{
  27714. "failed_code": -10,
  27715. "msg": result3101.ErrMsg,
  27716. })
  27717. return
  27718. }
  27719. }
  27720. if his.IdCardType == 4 {
  27721. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27722. token := psn_info.VerifyNumber
  27723. 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)
  27724. } else {
  27725. 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)
  27726. }
  27727. }
  27728. var dat map[string]interface{}
  27729. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27730. fmt.Println(dat)
  27731. } else {
  27732. fmt.Println(err)
  27733. }
  27734. saveLog(result2, src_resquest, "2207", "结算")
  27735. userJSONBytes, _ := json.Marshal(dat)
  27736. if miConfig.Code == "H15049901371" {
  27737. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27738. utils.ErrorLog("解析失败:%v", err)
  27739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27740. return
  27741. }
  27742. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27743. res.Output = resSeven10265.Output
  27744. res.ErrMsg = resSeven10265.ErrMsg
  27745. res.Cainfo = resSeven10265.Cainfo
  27746. res.WarnMsg = resSeven10265.WarnMsg
  27747. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27748. res.Infcode = infocode
  27749. } else {
  27750. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27751. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27752. utils.ErrorLog("解析失败:%v", err)
  27753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27754. return
  27755. }
  27756. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27757. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27758. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27759. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27760. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27761. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27762. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27763. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27764. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27765. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27766. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27767. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27768. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27769. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27770. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27771. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27772. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27773. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27774. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27775. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27776. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27777. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27778. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27779. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27780. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27781. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27782. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27783. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27784. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27785. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27786. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27787. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27788. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27789. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27790. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27791. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27792. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27793. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27794. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27795. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27796. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27797. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27798. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27799. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27800. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27801. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27802. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27803. res.Cainfo = gzresSeven10265Two.Cainfo
  27804. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27805. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27806. //res.Infcode = infocode
  27807. } else {
  27808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27809. utils.ErrorLog("解析失败:%v", err)
  27810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27811. return
  27812. }
  27813. }
  27814. }
  27815. }
  27816. if res.Infcode == -1 {
  27817. errlog := &models.HisOrderError{
  27818. UserOrgId: adminUser.CurrentOrgId,
  27819. Ctime: time.Now().Unix(),
  27820. Mtime: time.Now().Unix(),
  27821. Number: chrg_bchno,
  27822. ErrMsg: res.ErrMsg,
  27823. Status: 1,
  27824. PatientId: id,
  27825. RecordTime: recordDateTime,
  27826. Stage: 6,
  27827. }
  27828. service.CreateErrMsgLog(errlog)
  27829. c.ServeSuccessJSON(map[string]interface{}{
  27830. "failed_code": -10,
  27831. "msg": res.ErrMsg,
  27832. })
  27833. return
  27834. } else {
  27835. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27836. order.OrderStatus = 2
  27837. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27838. order.SetlId = res.Output.Setlinfo.SetlID
  27839. order.PsnNo = res.Output.Setlinfo.PsnNo
  27840. order.PsnName = res.Output.Setlinfo.PsnName
  27841. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27842. order.Certno = res.Output.Setlinfo.Certno
  27843. order.Gend = res.Output.Setlinfo.Gend
  27844. order.Naty = res.Output.Setlinfo.Naty
  27845. order.Age = res.Output.Setlinfo.Age
  27846. order.Insutype = res.Output.Setlinfo.Insutype
  27847. order.PsnType = res.Output.Setlinfo.PsnType
  27848. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27849. order.SetlTime = res.Output.Setlinfo.SetlTime
  27850. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27851. order.PayWays = pay_ways
  27852. order.AcctUsedFlag = acct_used_flag
  27853. order.WechatPay = wechat_pay
  27854. order.AliPay = ali_pay
  27855. order.JifenPay = jifen_pay
  27856. order.BandCardPay = band_card_pay
  27857. order.CashPay = cash_pay
  27858. order.OthDesc = oth_desc
  27859. //order.MedType = res.Output.Setlinfo.MedType
  27860. if reg_type == 1112 {
  27861. order.MedType = "1112"
  27862. }
  27863. if reg_type == 1111 {
  27864. order.MedType = "1111"
  27865. }
  27866. order.ClrType = res.Output.Setlinfo.ClrType
  27867. if adminUser.CurrentOrgId == 10480 {
  27868. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27869. order.ClrType = "11"
  27870. } else {
  27871. order.ClrType = "9903"
  27872. }
  27873. }
  27874. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27875. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27876. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27877. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27878. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27879. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27880. order.HifpPay = res.Output.Setlinfo.HifpPay
  27881. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27882. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27883. order.HifesPay = res.Output.Setlinfo.HifesPay
  27884. order.HifobPay = res.Output.Setlinfo.HifobPay
  27885. order.MafPay = res.Output.Setlinfo.MafPay
  27886. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27887. order.OthPay = res.Output.Setlinfo.OthPay
  27888. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27889. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27890. order.AcctPay = res.Output.Setlinfo.AcctPay
  27891. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27892. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27893. order.Balc = res.Output.Setlinfo.Balc
  27894. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27895. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27896. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27897. order.ClrWay = res.Output.Setlinfo.ClrWay
  27898. order.Creator = order.Creator
  27899. order.Modify = roles.AdminUserId
  27900. order.RequestLog = src_resquest
  27901. order.Diagnosis = diagnosis_id
  27902. order.FaPiaoNumber = fapiao_number
  27903. order.FaPiaoCode = fapiao_code
  27904. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27905. detailStr := string(setlDetail)
  27906. order.SetlDetail = detailStr
  27907. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27908. err = service.UpDateOrder(order)
  27909. if err == nil {
  27910. //判断是否使用了押金
  27911. if dec_way == "true" {
  27912. tmpstring := strconv.FormatInt(order.ID, 10)
  27913. //扣押金
  27914. order.Decimal = decimal
  27915. service.UpDateOrder(order)
  27916. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27917. if errmsg != nil {
  27918. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27919. return
  27920. }
  27921. }
  27922. c.ServeSuccessJSON(map[string]interface{}{
  27923. "msg": "结算成功",
  27924. })
  27925. } else {
  27926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27927. return
  27928. }
  27929. }
  27930. }
  27931. }
  27932. }
  27933. // 上传明细-预结算-
  27934. func (c *HisApiController) GetPreUploadInfo() {
  27935. id, _ := c.GetInt64("id")
  27936. record_time := c.GetString("record_time")
  27937. his_patient_id, _ := c.GetInt64("his_patient_id")
  27938. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27939. admin_user_id, _ := c.GetInt64("admin_user_id")
  27940. diagnosis_id := c.GetString("diagnosis")
  27941. sick_type, _ := c.GetInt64("sick_type")
  27942. reg_type, _ := c.GetInt64("p_type")
  27943. begin_time := c.GetString("begin_time")
  27944. acct_used_flag := c.GetString("acct_used_flag")
  27945. id_str := c.GetString("ids")
  27946. ids_arr := strings.Split(id_str, ",")
  27947. timeLayout := "2006-01-02"
  27948. loc, _ := time.LoadLocation("Local")
  27949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27950. if err != nil {
  27951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27952. return
  27953. }
  27954. recordDateTime := theTime.Unix()
  27955. adminUser := c.GetAdminUserInfo()
  27956. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27957. var config []*models.HisXtDiagnoseConfig
  27958. for _, item := range diagnosis_ids {
  27959. id, _ := strconv.ParseInt(item, 10, 64)
  27960. if id > 0 {
  27961. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27962. config = append(config, &diagnosisConfig)
  27963. }
  27964. }
  27965. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27966. sickConfig, _ := service.FindSickById(sick_type)
  27967. var prescriptions []*models.HisPrescription
  27968. var start_time int64
  27969. var end_time int64
  27970. var isSuccess bool = true
  27971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27972. fmt.Println(his_patient_id)
  27973. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27974. timestamp := time.Now().Unix()
  27975. tempTime := time.Unix(timestamp, 0)
  27976. timeFormat := tempTime.Format("20060102150405")
  27977. chrgBchno := rand.Intn(100000) + 10000
  27978. new_chrg_bchno := ""
  27979. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27980. new_chrg_bchno = chrg_bchno
  27981. if adminUser.CurrentOrgId == 10265 {
  27982. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27983. new_chrg_bchno = "0000"
  27984. }
  27985. }
  27986. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27987. var patientPrescription models.HisPrescriptionInfo
  27988. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27989. if patientPrescription.ID == 0 {
  27990. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27991. }
  27992. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27993. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27994. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27995. strconv.FormatInt(his.PatientId, 10)
  27996. var res2406 Result2406
  27997. //安徽单病种处理
  27998. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27999. data := make(map[string]interface{})
  28000. client := &http.Client{}
  28001. data["psn_no"] = his.PsnNo
  28002. data["mdtrt_id"] = his.Number
  28003. data["operator"] = roles.UserName
  28004. data["cert_no"] = his.IdCardNo
  28005. data["org_name"] = miConfig.OrgName
  28006. data["psn_name"] = his.Name
  28007. data["ipt_otp_no"] = his.IptOtpNo
  28008. data["ipt_psn_sp_flag_type"] = "0901"
  28009. data["ipt_psn_sp_flag"] = "1"
  28010. data["fixmedins_code"] = miConfig.Code
  28011. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28012. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28013. data["url"] = miConfig.Url
  28014. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28015. bytesData, _ := json.Marshal(data)
  28016. var req *http.Request
  28017. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28018. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28019. resp, _ := client.Do(req)
  28020. defer resp.Body.Close()
  28021. body, ioErr := ioutil.ReadAll(resp.Body)
  28022. if ioErr != nil {
  28023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28025. return
  28026. }
  28027. var respJSON map[string]interface{}
  28028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28031. return
  28032. }
  28033. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28034. if status == "0" {
  28035. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28036. c.ServeSuccessJSON(map[string]interface{}{
  28037. "failed_code": -10,
  28038. "msg": err_msg,
  28039. })
  28040. return
  28041. }
  28042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28043. userJSONBytes, _ := json.Marshal(respJSON)
  28044. fmt.Println("log")
  28045. fmt.Println(string(userJSONBytes))
  28046. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28047. utils.ErrorLog("解析失败:%v", err)
  28048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28049. return
  28050. }
  28051. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28052. data := make(map[string]interface{})
  28053. client := &http.Client{}
  28054. data["psn_no"] = his.PsnNo
  28055. data["mdtrt_id"] = his.Number
  28056. data["operator"] = roles.UserName
  28057. data["cert_no"] = his.IdCardNo
  28058. data["org_name"] = miConfig.OrgName
  28059. data["psn_name"] = his.Name
  28060. data["ipt_otp_no"] = his.IptOtpNo
  28061. data["ipt_psn_sp_flag_type"] = "0901"
  28062. data["ipt_psn_sp_flag"] = "1"
  28063. data["fixmedins_code"] = miConfig.Code
  28064. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28065. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28066. data["url"] = miConfig.Url
  28067. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28068. bytesData, _ := json.Marshal(data)
  28069. var req *http.Request
  28070. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28071. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28072. resp, _ := client.Do(req)
  28073. defer resp.Body.Close()
  28074. body, ioErr := ioutil.ReadAll(resp.Body)
  28075. if ioErr != nil {
  28076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28078. return
  28079. }
  28080. var respJSON map[string]interface{}
  28081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28084. return
  28085. }
  28086. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28087. if status == "0" {
  28088. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28089. c.ServeSuccessJSON(map[string]interface{}{
  28090. "failed_code": -10,
  28091. "msg": err_msg,
  28092. })
  28093. return
  28094. }
  28095. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28096. userJSONBytes, _ := json.Marshal(respJSON)
  28097. fmt.Println("log")
  28098. fmt.Println(string(userJSONBytes))
  28099. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28100. utils.ErrorLog("解析失败:%v", err)
  28101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28102. return
  28103. }
  28104. }
  28105. if res2406.Infcode != 0 {
  28106. adminUser := c.GetAdminUserInfo()
  28107. errlog := &models.HisOrderError{
  28108. UserOrgId: adminUser.CurrentOrgId,
  28109. Ctime: time.Now().Unix(),
  28110. Mtime: time.Now().Unix(),
  28111. ErrMsg: res2406.ErrMsg,
  28112. Status: 1,
  28113. PatientId: id,
  28114. RecordTime: recordDateTime,
  28115. Stage: 3,
  28116. }
  28117. service.CreateErrMsgLog(errlog)
  28118. c.ServeSuccessJSON(map[string]interface{}{
  28119. "failed_code": -10,
  28120. "msg": res2406.ErrMsg,
  28121. })
  28122. return
  28123. }
  28124. var res2 ResultSix
  28125. var res3 GZResultSix
  28126. var resSix10265 ResultSix10265
  28127. //var time_stamp string
  28128. if miConfig.MdtrtareaAdmvs == "421300" {
  28129. data := make(map[string]interface{})
  28130. client := &http.Client{}
  28131. data["psn_no"] = his.PsnNo
  28132. data["mdtrt_id"] = his.Number
  28133. data["department"] = department.Name
  28134. data["org_name"] = miConfig.OrgName
  28135. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28136. data["doctor_id"] = doctor_info.DoctorNumber
  28137. data["doctor_name"] = roles.UserName
  28138. data["fixmedins_code"] = miConfig.Code
  28139. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28140. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28141. data["secret_key"] = miConfig.SecretKey
  28142. data["sick_code"] = sickConfig.CountryCode
  28143. data["sick_name"] = sickConfig.ClassName
  28144. data["begin_time"] = begin_time
  28145. data["dept"] = strconv.FormatInt(department.ID, 10)
  28146. data["config"] = config
  28147. data["opter"] = roles.UserName
  28148. fmt.Println(data)
  28149. bytesData, _ := json.Marshal(data)
  28150. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28151. resp, _ := client.Do(req)
  28152. defer resp.Body.Close()
  28153. body, ioErr := ioutil.ReadAll(resp.Body)
  28154. if ioErr != nil {
  28155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28157. return
  28158. }
  28159. var respJSON map[string]interface{}
  28160. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28163. return
  28164. }
  28165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28166. userJSONBytes, _ := json.Marshal(respJSON)
  28167. fmt.Println("log")
  28168. fmt.Println(string(userJSONBytes))
  28169. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28170. utils.ErrorLog("解析失败:%v", err)
  28171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28172. return
  28173. }
  28174. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28175. data := make(map[string]interface{})
  28176. client := &http.Client{}
  28177. data["psn_no"] = his.PsnNo
  28178. data["mdtrt_id"] = his.Number
  28179. data["department"] = department.Name
  28180. data["org_name"] = miConfig.OrgName
  28181. if reg_type == 11 && his.Insutype == "390" {
  28182. data["med_type"] = "110104"
  28183. } else {
  28184. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28185. }
  28186. data["doctor_id"] = doctor_info.DoctorNumber
  28187. data["doctor_name"] = roles.UserName
  28188. data["fixmedins_code"] = miConfig.Code
  28189. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28190. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28191. data["secret_key"] = miConfig.SecretKey
  28192. data["sick_code"] = sickConfig.CountryCode
  28193. data["sick_name"] = sickConfig.ClassName
  28194. data["begin_time"] = begin_time
  28195. data["dept"] = strconv.FormatInt(department.ID, 10)
  28196. data["config"] = config
  28197. data["opter"] = roles.UserName
  28198. fmt.Println(data)
  28199. bytesData, _ := json.Marshal(data)
  28200. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28201. resp, _ := client.Do(req)
  28202. defer resp.Body.Close()
  28203. body, ioErr := ioutil.ReadAll(resp.Body)
  28204. if ioErr != nil {
  28205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28207. return
  28208. }
  28209. var respJSON map[string]interface{}
  28210. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28213. return
  28214. }
  28215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28216. userJSONBytes, _ := json.Marshal(respJSON)
  28217. fmt.Println("log")
  28218. fmt.Println(string(userJSONBytes))
  28219. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28220. utils.ErrorLog("解析失败:%v", err)
  28221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28222. return
  28223. }
  28224. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28225. data := make(map[string]interface{})
  28226. client := &http.Client{}
  28227. data["psn_no"] = his.PsnNo
  28228. data["mdtrt_id"] = his.Number
  28229. data["department"] = department.Name
  28230. data["org_name"] = miConfig.OrgName
  28231. if reg_type == 11 && his.Insutype == "390" {
  28232. data["med_type"] = "110104"
  28233. } else {
  28234. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28235. }
  28236. data["doctor_id"] = doctor_info.DoctorNumber
  28237. data["doctor_name"] = roles.UserName
  28238. data["fixmedins_code"] = miConfig.Code
  28239. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28240. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28241. data["secret_key"] = miConfig.SecretKey
  28242. data["sick_code"] = sickConfig.CountryCode
  28243. data["sick_name"] = sickConfig.ClassName
  28244. data["begin_time"] = begin_time
  28245. data["dept"] = strconv.FormatInt(department.ID, 10)
  28246. data["config"] = config
  28247. data["opter"] = roles.UserName
  28248. fmt.Println(data)
  28249. bytesData, _ := json.Marshal(data)
  28250. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28251. resp, _ := client.Do(req)
  28252. defer resp.Body.Close()
  28253. body, ioErr := ioutil.ReadAll(resp.Body)
  28254. if ioErr != nil {
  28255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28257. return
  28258. }
  28259. var respJSON map[string]interface{}
  28260. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28263. return
  28264. }
  28265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28266. userJSONBytes, _ := json.Marshal(respJSON)
  28267. fmt.Println("log")
  28268. fmt.Println(string(userJSONBytes))
  28269. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28270. utils.ErrorLog("解析失败:%v", err)
  28271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28272. return
  28273. }
  28274. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28275. data := make(map[string]interface{})
  28276. client := &http.Client{}
  28277. data["psn_no"] = his.PsnNo
  28278. data["mdtrt_id"] = his.Number
  28279. data["department"] = department.Name
  28280. data["org_name"] = miConfig.OrgName
  28281. if reg_type == 11 && his.Insutype == "390" {
  28282. data["med_type"] = "110104"
  28283. } else {
  28284. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28285. }
  28286. data["doctor_id"] = doctor_info.DoctorNumber
  28287. data["doctor_name"] = roles.UserName
  28288. data["fixmedins_code"] = miConfig.Code
  28289. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28290. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28291. data["secret_key"] = miConfig.SecretKey
  28292. data["sick_code"] = sickConfig.CountryCode
  28293. data["sick_name"] = sickConfig.ClassName
  28294. data["begin_time"] = begin_time
  28295. data["dept"] = strconv.FormatInt(department.ID, 10)
  28296. data["config"] = config
  28297. data["opter"] = roles.UserName
  28298. fmt.Println(data)
  28299. bytesData, _ := json.Marshal(data)
  28300. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28301. resp, _ := client.Do(req)
  28302. defer resp.Body.Close()
  28303. body, ioErr := ioutil.ReadAll(resp.Body)
  28304. if ioErr != nil {
  28305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28307. return
  28308. }
  28309. var respJSON map[string]interface{}
  28310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28313. return
  28314. }
  28315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28316. userJSONBytes, _ := json.Marshal(respJSON)
  28317. fmt.Println("log")
  28318. fmt.Println(string(userJSONBytes))
  28319. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28320. utils.ErrorLog("解析失败:%v", err)
  28321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28322. return
  28323. }
  28324. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28325. data := make(map[string]interface{})
  28326. client := &http.Client{}
  28327. data["psn_no"] = his.PsnNo
  28328. data["mdtrt_id"] = his.Number
  28329. data["doctor"] = roles.UserName
  28330. data["department"] = department.Name
  28331. data["org_name"] = miConfig.OrgName
  28332. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28333. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28334. data["fixmedins_code"] = miConfig.Code
  28335. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28336. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28337. data["secret_key"] = miConfig.SecretKey
  28338. data["sick_code"] = sickConfig.CountryCode
  28339. data["sick_name"] = sickConfig.ClassName
  28340. data["begin_time"] = begin_time
  28341. data["dept"] = strconv.FormatInt(department.ID, 10)
  28342. data["config"] = config
  28343. data["url"] = miConfig.Url
  28344. data["ak"] = miConfig.AccessKey
  28345. data["cainfo"] = miConfig.Cainfo
  28346. bytesData, _ := json.Marshal(data)
  28347. var req *http.Request
  28348. if miConfig.MdtrtareaAdmvs == "320921" {
  28349. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28350. } else {
  28351. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28352. }
  28353. resp, _ := client.Do(req)
  28354. defer resp.Body.Close()
  28355. body, ioErr := ioutil.ReadAll(resp.Body)
  28356. if ioErr != nil {
  28357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28359. return
  28360. }
  28361. var respJSON map[string]interface{}
  28362. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28365. return
  28366. }
  28367. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28368. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28369. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28371. userJSONBytes, _ := json.Marshal(respJSON)
  28372. fmt.Println("log")
  28373. fmt.Println(string(userJSONBytes))
  28374. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28375. utils.ErrorLog("解析失败:%v", err)
  28376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28377. return
  28378. }
  28379. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28380. res2.Output = resSix10265.Output
  28381. res2.ErrMsg = resSix10265.ErrMsg
  28382. res2.Cainfo = resSix10265.Cainfo
  28383. res2.WarnMsg = resSix10265.WarnMsg
  28384. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28385. res2.Infcode = infocode
  28386. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28387. data := make(map[string]interface{})
  28388. client := &http.Client{}
  28389. data["psn_no"] = his.PsnNo
  28390. data["mdtrt_id"] = his.Number
  28391. data["doctor"] = roles.UserName
  28392. data["department"] = department.Name
  28393. data["org_name"] = miConfig.OrgName
  28394. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28395. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28396. data["fixmedins_code"] = miConfig.Code
  28397. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28398. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28399. data["secret_key"] = miConfig.SecretKey
  28400. data["sick_code"] = sickConfig.CountryCode
  28401. data["sick_name"] = sickConfig.ClassName
  28402. data["begin_time"] = begin_time
  28403. data["dept"] = strconv.FormatInt(department.ID, 10)
  28404. data["config"] = config
  28405. //data["url"] = miConfig.Url
  28406. //data["ak"] = miConfig.AccessKey
  28407. data["cainfo"] = miConfig.Cainfo
  28408. fmt.Println(data)
  28409. bytesData, _ := json.Marshal(data)
  28410. var req *http.Request
  28411. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28412. resp, _ := client.Do(req)
  28413. defer resp.Body.Close()
  28414. body, ioErr := ioutil.ReadAll(resp.Body)
  28415. if ioErr != nil {
  28416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28418. return
  28419. }
  28420. var respJSON map[string]interface{}
  28421. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28424. return
  28425. }
  28426. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28427. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28428. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28430. userJSONBytes, _ := json.Marshal(respJSON)
  28431. fmt.Println("log")
  28432. fmt.Println(string(userJSONBytes))
  28433. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28434. utils.ErrorLog("解析失败:%v", err)
  28435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28436. return
  28437. }
  28438. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28439. res2.Output = resSix10265.Output
  28440. res2.ErrMsg = resSix10265.ErrMsg
  28441. res2.Cainfo = resSix10265.Cainfo
  28442. res2.WarnMsg = resSix10265.WarnMsg
  28443. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28444. res2.Infcode = infocode
  28445. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28446. 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)
  28447. saveLog(result, requestLog, "2203", "上传就诊信息")
  28448. var respJSON2 map[string]interface{}
  28449. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28452. return
  28453. }
  28454. userJSONBytes2, _ := json.Marshal(respJSON2)
  28455. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28456. utils.ErrorLog("解析失败:%v", err)
  28457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28458. return
  28459. }
  28460. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28461. var result string
  28462. var requestLog string
  28463. 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, "")
  28464. saveLog(result, requestLog, "2203", "上传就诊信息")
  28465. var respJSON2 map[string]interface{}
  28466. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28469. return
  28470. }
  28471. userJSONBytes2, _ := json.Marshal(respJSON2)
  28472. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28473. utils.ErrorLog("解析失败:%v", err)
  28474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28475. return
  28476. }
  28477. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28478. var result string
  28479. var requestLog string
  28480. 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, "")
  28481. saveLog(result, requestLog, "2203", "上传就诊信息")
  28482. var respJSON2 map[string]interface{}
  28483. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28486. return
  28487. }
  28488. userJSONBytes2, _ := json.Marshal(respJSON2)
  28489. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28490. utils.ErrorLog("解析失败:%v", err)
  28491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28492. return
  28493. }
  28494. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28495. data := make(map[string]interface{})
  28496. client := &http.Client{}
  28497. data["psn_no"] = his.PsnNo
  28498. data["mdtrt_id"] = his.Number
  28499. data["operator"] = roles.UserName
  28500. data["department"] = department.Name
  28501. data["org_name"] = miConfig.OrgName
  28502. var med_type string
  28503. if his.Insutype == "390" {
  28504. if reg_type == 992102 {
  28505. med_type = "992102"
  28506. data["sick_code"] = "ZDZ940"
  28507. data["sick_name"] = "慢性肾衰竭"
  28508. }
  28509. if reg_type == 140104 {
  28510. med_type = "140104"
  28511. data["sick_code"] = sickConfig.CountryCode
  28512. data["sick_name"] = sickConfig.ClassName
  28513. }
  28514. if reg_type == 14 {
  28515. med_type = "140104"
  28516. data["sick_code"] = sickConfig.CountryCode
  28517. data["sick_name"] = sickConfig.ClassName
  28518. }
  28519. } else if his.Insutype == "310" {
  28520. if reg_type == 992102 {
  28521. med_type = "992102"
  28522. data["sick_code"] = "ZDZ940"
  28523. data["sick_name"] = "慢性肾衰竭"
  28524. }
  28525. if reg_type == 140104 {
  28526. med_type = "140104"
  28527. data["sick_code"] = sickConfig.CountryCode
  28528. data["sick_name"] = sickConfig.ClassName
  28529. }
  28530. if reg_type == 14 {
  28531. med_type = "14"
  28532. data["sick_code"] = sickConfig.CountryCode
  28533. data["sick_name"] = sickConfig.ClassName
  28534. }
  28535. }
  28536. data["med_type"] = med_type
  28537. data["doctor_number"] = doctor_info.DoctorNumber
  28538. data["doctor_name"] = doctor_info.UserName
  28539. data["fixmedins_code"] = miConfig.Code
  28540. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28541. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28542. data["secret_key"] = miConfig.SecretKey
  28543. data["begin_time"] = begin_time
  28544. data["dept"] = strconv.FormatInt(department.ID, 10)
  28545. data["config"] = config
  28546. data["url"] = miConfig.Url
  28547. data["ak"] = miConfig.AccessKey
  28548. data["cainfo"] = miConfig.Cainfo
  28549. bytesData, _ := json.Marshal(data)
  28550. var req *http.Request
  28551. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28552. resp, _ := client.Do(req)
  28553. defer resp.Body.Close()
  28554. body, ioErr := ioutil.ReadAll(resp.Body)
  28555. if ioErr != nil {
  28556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28558. return
  28559. }
  28560. var respJSON map[string]interface{}
  28561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28564. return
  28565. }
  28566. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28567. if status == "0" {
  28568. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28569. c.ServeSuccessJSON(map[string]interface{}{
  28570. "failed_code": -10,
  28571. "msg": err_msg,
  28572. })
  28573. return
  28574. }
  28575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28576. userJSONBytes, _ := json.Marshal(respJSON)
  28577. fmt.Println("log")
  28578. fmt.Println(string(userJSONBytes))
  28579. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28580. utils.ErrorLog("解析失败:%v", err)
  28581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28582. return
  28583. }
  28584. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28585. data := make(map[string]interface{})
  28586. client := &http.Client{}
  28587. data["psn_no"] = his.PsnNo
  28588. data["mdtrt_id"] = his.Number
  28589. data["operator"] = roles.UserName
  28590. data["department"] = department.Name
  28591. data["org_name"] = miConfig.OrgName
  28592. var med_type string
  28593. if his.Insutype == "390" {
  28594. if reg_type == 992102 {
  28595. med_type = "992102"
  28596. data["sick_code"] = sickConfig.CountryCode
  28597. data["sick_name"] = sickConfig.ClassName
  28598. }
  28599. if reg_type == 140104 {
  28600. med_type = "140104"
  28601. data["sick_code"] = sickConfig.CountryCode
  28602. data["sick_name"] = sickConfig.ClassName
  28603. }
  28604. if reg_type == 140201 {
  28605. med_type = "140201"
  28606. data["sick_code"] = sickConfig.CountryCode
  28607. data["sick_name"] = sickConfig.ClassName
  28608. }
  28609. if reg_type == 14 {
  28610. med_type = "14"
  28611. data["sick_code"] = sickConfig.CountryCode
  28612. data["sick_name"] = sickConfig.ClassName
  28613. }
  28614. } else if his.Insutype == "310" {
  28615. if reg_type == 992102 {
  28616. med_type = "992102"
  28617. data["sick_code"] = sickConfig.CountryCode
  28618. data["sick_name"] = sickConfig.ClassName
  28619. }
  28620. if reg_type == 140104 {
  28621. med_type = "140104"
  28622. data["sick_code"] = sickConfig.CountryCode
  28623. data["sick_name"] = sickConfig.ClassName
  28624. }
  28625. if reg_type == 140201 {
  28626. med_type = "140201"
  28627. data["sick_code"] = sickConfig.CountryCode
  28628. data["sick_name"] = sickConfig.ClassName
  28629. }
  28630. if reg_type == 14 {
  28631. med_type = "14"
  28632. data["sick_code"] = sickConfig.CountryCode
  28633. data["sick_name"] = sickConfig.ClassName
  28634. }
  28635. }
  28636. data["med_type"] = med_type
  28637. data["doctor_number"] = doctor_info.DoctorNumber
  28638. data["doctor_name"] = doctor_info.UserName
  28639. data["fixmedins_code"] = miConfig.Code
  28640. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28641. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28642. data["secret_key"] = miConfig.SecretKey
  28643. data["begin_time"] = begin_time
  28644. data["dept"] = strconv.FormatInt(department.ID, 10)
  28645. data["config"] = config
  28646. data["url"] = miConfig.Url
  28647. data["ak"] = miConfig.AccessKey
  28648. data["cainfo"] = miConfig.Cainfo
  28649. bytesData, _ := json.Marshal(data)
  28650. var req *http.Request
  28651. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28652. resp, _ := client.Do(req)
  28653. defer resp.Body.Close()
  28654. body, ioErr := ioutil.ReadAll(resp.Body)
  28655. if ioErr != nil {
  28656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28658. return
  28659. }
  28660. var respJSON map[string]interface{}
  28661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28664. return
  28665. }
  28666. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28667. if status == "0" {
  28668. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28669. c.ServeSuccessJSON(map[string]interface{}{
  28670. "failed_code": -10,
  28671. "msg": err_msg,
  28672. })
  28673. return
  28674. }
  28675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28676. userJSONBytes, _ := json.Marshal(respJSON)
  28677. fmt.Println("log")
  28678. fmt.Println(string(userJSONBytes))
  28679. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28680. utils.ErrorLog("解析失败:%v", err)
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28682. return
  28683. }
  28684. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28685. var result string
  28686. var requestLog string
  28687. 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, "")
  28688. saveLog(result, requestLog, "2203", "上传就诊信息")
  28689. var respJSON2 map[string]interface{}
  28690. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28693. return
  28694. }
  28695. userJSONBytes2, _ := json.Marshal(respJSON2)
  28696. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28697. utils.ErrorLog("解析失败:%v", err)
  28698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28699. return
  28700. }
  28701. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28702. data := make(map[string]interface{})
  28703. client := &http.Client{}
  28704. data["psn_no"] = his.PsnNo
  28705. data["mdtrt_id"] = his.Number
  28706. data["doctor"] = roles.UserName
  28707. data["department"] = department.Name
  28708. data["org_name"] = miConfig.OrgName
  28709. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28710. data["doctor_id"] = doctor_info.DoctorNumber
  28711. data["fixmedins_code"] = miConfig.Code
  28712. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28713. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28714. data["secret_key"] = miConfig.SecretKey
  28715. data["sick_code"] = sickConfig.CountryCode
  28716. data["sick_name"] = sickConfig.ClassName
  28717. data["begin_time"] = begin_time
  28718. data["new_doctor_name"] = doctor_info.UserName
  28719. data["dept"] = strconv.FormatInt(department.ID, 10)
  28720. data["config"] = config
  28721. bytesData, _ := json.Marshal(data)
  28722. var req *http.Request
  28723. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28724. resp, _ := client.Do(req)
  28725. defer resp.Body.Close()
  28726. body, ioErr := ioutil.ReadAll(resp.Body)
  28727. if ioErr != nil {
  28728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28730. return
  28731. }
  28732. var respJSON map[string]interface{}
  28733. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28736. return
  28737. }
  28738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28739. userJSONBytes, _ := json.Marshal(respJSON)
  28740. fmt.Println("log")
  28741. fmt.Println(string(userJSONBytes))
  28742. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28743. utils.ErrorLog("解析失败:%v", err)
  28744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28745. return
  28746. }
  28747. } else {
  28748. var result string
  28749. var requestLog string
  28750. if miConfig.MdtrtareaAdmvs == "440781" { //
  28751. 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)
  28752. } else {
  28753. if miConfig.Code == "H15049901371" {
  28754. //赤峰地区国家医保医疗类别
  28755. //职工透析:医疗类别选特殊情况门诊990502
  28756. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28757. var med_type string
  28758. if his.Insutype == "390" {
  28759. if reg_type == 14 {
  28760. med_type = "9933"
  28761. } else if reg_type == 11 {
  28762. med_type = "11"
  28763. }
  28764. } else if his.Insutype == "310" {
  28765. if reg_type == 14 {
  28766. med_type = "990502"
  28767. } else if reg_type == 11 {
  28768. med_type = "11"
  28769. }
  28770. }
  28771. 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)
  28772. } else {
  28773. 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)
  28774. }
  28775. saveLog(result, requestLog, "2203", "上传就诊信息")
  28776. var respJSON2 map[string]interface{}
  28777. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28780. return
  28781. }
  28782. userJSONBytes2, _ := json.Marshal(respJSON2)
  28783. if miConfig.Code == "H15049901371" {
  28784. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28785. utils.ErrorLog("解析失败:%v", err)
  28786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28787. return
  28788. }
  28789. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28790. res2.Output = resSix10265.Output
  28791. res2.ErrMsg = resSix10265.ErrMsg
  28792. res2.Cainfo = resSix10265.Cainfo
  28793. res2.WarnMsg = resSix10265.WarnMsg
  28794. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28795. res2.Infcode = infocode
  28796. } else {
  28797. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28798. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28799. utils.ErrorLog("解析失败:%v", err)
  28800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28801. return
  28802. }
  28803. res2.Infcode = res3.Infcode
  28804. } else {
  28805. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28806. utils.ErrorLog("解析失败:%v", err)
  28807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28808. return
  28809. }
  28810. }
  28811. }
  28812. }
  28813. }
  28814. if res2.Infcode == -1 {
  28815. adminUser := c.GetAdminUserInfo()
  28816. errlog := &models.HisOrderError{
  28817. UserOrgId: adminUser.CurrentOrgId,
  28818. Ctime: time.Now().Unix(),
  28819. Mtime: time.Now().Unix(),
  28820. ErrMsg: res2.ErrMsg,
  28821. Status: 1,
  28822. PatientId: id,
  28823. RecordTime: recordDateTime,
  28824. Stage: 3,
  28825. }
  28826. service.CreateErrMsgLog(errlog)
  28827. c.ServeSuccessJSON(map[string]interface{}{
  28828. "failed_code": -10,
  28829. "msg": res2.ErrMsg,
  28830. })
  28831. return
  28832. }
  28833. if res2.Infcode != 0 {
  28834. adminUser := c.GetAdminUserInfo()
  28835. errlog := &models.HisOrderError{
  28836. UserOrgId: adminUser.CurrentOrgId,
  28837. Ctime: time.Now().Unix(),
  28838. Mtime: time.Now().Unix(),
  28839. ErrMsg: res2.ErrMsg,
  28840. Status: 1,
  28841. PatientId: id,
  28842. RecordTime: recordDateTime,
  28843. Stage: 3,
  28844. }
  28845. service.CreateErrMsgLog(errlog)
  28846. c.ServeSuccessJSON(map[string]interface{}{
  28847. "failed_code": -10,
  28848. "msg": res2.ErrMsg,
  28849. })
  28850. return
  28851. } else {
  28852. his.Diagnosis = diagnosis_id
  28853. his.SickType = sickConfig.ID
  28854. his.PType = fmt.Sprintf("%d", reg_type)
  28855. service.UpdateHisPatientThree(&his)
  28856. data := make(map[string]interface{})
  28857. if settle_accounts_type == 1 { //日结
  28858. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28859. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28860. } else {
  28861. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28862. }
  28863. data["pre"] = prescriptions
  28864. } else { //月结
  28865. start_time_str := c.GetString("start_time")
  28866. end_time_str := c.GetString("end_time")
  28867. timeLayout := "2006-01-02"
  28868. loc, _ := time.LoadLocation("Local")
  28869. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28870. if err != nil {
  28871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28872. return
  28873. }
  28874. recordStartTime := theStartTime.Unix()
  28875. start_time = recordStartTime
  28876. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28877. if err != nil {
  28878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28879. return
  28880. }
  28881. recordEndTime := theEndTime.Unix()
  28882. end_time = recordEndTime
  28883. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28884. data["pre"] = prescriptions
  28885. }
  28886. client := &http.Client{}
  28887. data["psn_no"] = his.PsnNo
  28888. data["mdtrt_id"] = his.Number
  28889. data["chrg_bchno"] = new_chrg_bchno
  28890. data["org_name"] = miConfig.OrgName
  28891. data["doctor"] = doctor_info.UserName
  28892. data["doctor_id"] = doctor_info.DoctorNumber
  28893. data["dept"] = department.Name
  28894. data["fixmedins_code"] = miConfig.Code
  28895. data["opter"] = roles.UserName
  28896. data["dept_code"] = department.Number
  28897. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28899. data["secret_key"] = miConfig.SecretKey
  28900. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28901. data["url"] = miConfig.Url
  28902. data["ak"] = miConfig.AccessKey
  28903. data["new_doctor_name"] = patientPrescription.Doctor
  28904. if his.Insutype == "390" {
  28905. if reg_type == 992102 {
  28906. data["diag_code"] = "ZDZ940"
  28907. }
  28908. if reg_type == 140104 {
  28909. data["diag_code"] = sickConfig.CountryCode
  28910. }
  28911. if reg_type == 140201 {
  28912. data["diag_code"] = sickConfig.CountryCode
  28913. }
  28914. if reg_type == 14 {
  28915. data["diag_code"] = sickConfig.CountryCode
  28916. }
  28917. } else if his.Insutype == "310" {
  28918. if miConfig.MdtrtareaAdmvs == "341203" {
  28919. if reg_type == 992102 {
  28920. data["diag_code"] = "ZDZ940"
  28921. }
  28922. if reg_type != 992102 {
  28923. data["diag_code"] = sickConfig.CountryCode
  28924. }
  28925. } else {
  28926. data["diag_code"] = sickConfig.CountryCode
  28927. }
  28928. }
  28929. data["cainfo"] = miConfig.Cainfo
  28930. data["opter"] = roles.UserName
  28931. var ids []int64
  28932. for _, item := range prescriptions {
  28933. ids = append(ids, item.ID)
  28934. }
  28935. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28936. if config.IsOpen == 1 { //对接了医保,走医保流程
  28937. var res ResultFour
  28938. var resFour10265 ResultFour10265
  28939. if miConfig.MdtrtareaAdmvs == "421300" {
  28940. bytesData, _ := json.Marshal(data)
  28941. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28942. resp, _ := client.Do(req)
  28943. defer resp.Body.Close()
  28944. body, ioErr := ioutil.ReadAll(resp.Body)
  28945. if ioErr != nil {
  28946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28948. return
  28949. }
  28950. var respJSON map[string]interface{}
  28951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28954. return
  28955. }
  28956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28957. userJSONBytes, _ := json.Marshal(respJSON)
  28958. fmt.Println("log")
  28959. fmt.Println(string(userJSONBytes))
  28960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28961. utils.ErrorLog("解析失败:%v", err)
  28962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28963. return
  28964. }
  28965. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28966. bytesData, _ := json.Marshal(data)
  28967. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28968. resp, _ := client.Do(req)
  28969. defer resp.Body.Close()
  28970. body, ioErr := ioutil.ReadAll(resp.Body)
  28971. if ioErr != nil {
  28972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28974. return
  28975. }
  28976. var respJSON map[string]interface{}
  28977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28980. return
  28981. }
  28982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28983. userJSONBytes, _ := json.Marshal(respJSON)
  28984. fmt.Println("log")
  28985. fmt.Println(string(userJSONBytes))
  28986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28987. utils.ErrorLog("解析失败:%v", err)
  28988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28989. return
  28990. }
  28991. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28992. bytesData, _ := json.Marshal(data)
  28993. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28994. resp, _ := client.Do(req)
  28995. defer resp.Body.Close()
  28996. body, ioErr := ioutil.ReadAll(resp.Body)
  28997. if ioErr != nil {
  28998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29000. return
  29001. }
  29002. var respJSON map[string]interface{}
  29003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29006. return
  29007. }
  29008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29009. userJSONBytes, _ := json.Marshal(respJSON)
  29010. fmt.Println("log")
  29011. fmt.Println(string(userJSONBytes))
  29012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29013. utils.ErrorLog("解析失败:%v", err)
  29014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29015. return
  29016. }
  29017. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29018. bytesData, _ := json.Marshal(data)
  29019. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29020. resp, _ := client.Do(req)
  29021. defer resp.Body.Close()
  29022. body, ioErr := ioutil.ReadAll(resp.Body)
  29023. if ioErr != nil {
  29024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29026. return
  29027. }
  29028. var respJSON map[string]interface{}
  29029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29032. return
  29033. }
  29034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29035. userJSONBytes, _ := json.Marshal(respJSON)
  29036. fmt.Println("log")
  29037. fmt.Println(string(userJSONBytes))
  29038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29039. utils.ErrorLog("解析失败:%v", err)
  29040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29041. return
  29042. }
  29043. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29044. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29045. if result3101.Infcode == "0" {
  29046. if len(result3101.Output.Result) > 0 {
  29047. var errMsgs []string
  29048. for _, item := range result3101.Output.Result {
  29049. errMsgs = append(errMsgs, item.VolaCont)
  29050. }
  29051. c.ServeSuccessJSON(map[string]interface{}{
  29052. "failed_code": -10,
  29053. "msg": errMsgs,
  29054. })
  29055. return
  29056. } else {
  29057. if miConfig.MdtrtareaAdmvs == "320921" {
  29058. data["doctor_id"] = "D320923012139"
  29059. } else {
  29060. data["doctor_id"] = "D371621008686"
  29061. }
  29062. bytesData, _ := json.Marshal(data)
  29063. var req *http.Request
  29064. if miConfig.MdtrtareaAdmvs == "320921" {
  29065. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29066. } else {
  29067. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29068. }
  29069. resp, _ := client.Do(req)
  29070. defer resp.Body.Close()
  29071. body, ioErr := ioutil.ReadAll(resp.Body)
  29072. if ioErr != nil {
  29073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29075. return
  29076. }
  29077. var respJSON map[string]interface{}
  29078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29081. return
  29082. }
  29083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29084. userJSONBytes, _ := json.Marshal(respJSON)
  29085. fmt.Println("log")
  29086. fmt.Println(string(userJSONBytes))
  29087. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29088. utils.ErrorLog("解析失败:%v", err)
  29089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29090. return
  29091. }
  29092. res.InfRefmsgid = resFour10265.InfRefmsgid
  29093. res.Output = resFour10265.Output
  29094. res.ErrMsg = resFour10265.ErrMsg
  29095. res.Cainfo = resFour10265.Cainfo
  29096. res.WarnMsg = resFour10265.WarnMsg
  29097. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29098. res.Infcode = infocode
  29099. }
  29100. }
  29101. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29102. var pagesize int = 5
  29103. var start int = 1
  29104. var stop int
  29105. var pagecount int
  29106. var curpage int
  29107. data["doctor_id"] = doctor_info.DoctorNumber
  29108. var res2 ResultFour
  29109. //var result res.
  29110. //总页数,向上取整,注意除之前要先转换类型为float64
  29111. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29112. for curpage = 1; curpage <= pagecount; curpage++ {
  29113. if curpage == 1 {
  29114. start = 1
  29115. } else {
  29116. start = (curpage-1)*pagesize + 1
  29117. }
  29118. stop = curpage * pagesize
  29119. if stop > len(prescriptions) {
  29120. stop = len(prescriptions)
  29121. }
  29122. //var requestLog string
  29123. data["pre"] = prescriptions[start-1 : stop]
  29124. fmt.Println(data["pre"])
  29125. bytesData, _ := json.Marshal(data)
  29126. var req *http.Request
  29127. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29128. resp, _ := client.Do(req)
  29129. defer resp.Body.Close()
  29130. body, ioErr := ioutil.ReadAll(resp.Body)
  29131. if ioErr != nil {
  29132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29134. return
  29135. }
  29136. var respJSON map[string]interface{}
  29137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29140. return
  29141. }
  29142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29143. userJSONBytes, _ := json.Marshal(respJSON)
  29144. fmt.Println("log")
  29145. fmt.Println(string(userJSONBytes))
  29146. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29147. utils.ErrorLog("解析失败:%v", err)
  29148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29149. return
  29150. }
  29151. res.InfRefmsgid = resFour10265.InfRefmsgid
  29152. res.Output = resFour10265.Output
  29153. res.ErrMsg = resFour10265.ErrMsg
  29154. res.Cainfo = resFour10265.Cainfo
  29155. res.WarnMsg = resFour10265.WarnMsg
  29156. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29157. res.Infcode = infocode
  29158. if infocode == 0 {
  29159. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29160. } else {
  29161. isSuccess = false
  29162. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29163. res.Infcode = -1
  29164. res.ErrMsg = resFour10265.ErrMsg
  29165. errlog := &models.HisOrderError{
  29166. UserOrgId: adminUser.CurrentOrgId,
  29167. Ctime: time.Now().Unix(),
  29168. Mtime: time.Now().Unix(),
  29169. Number: chrg_bchno,
  29170. ErrMsg: "",
  29171. Status: 1,
  29172. PatientId: id,
  29173. RecordTime: recordDateTime,
  29174. Stage: 4,
  29175. }
  29176. service.CreateErrMsgLog(errlog)
  29177. }
  29178. }
  29179. if isSuccess {
  29180. res.Infcode = 0
  29181. res.Output.Result = res2.Output.Result
  29182. } else {
  29183. order := &models.HisOrder{
  29184. UserOrgId: adminUser.CurrentOrgId,
  29185. HisPatientId: his.ID,
  29186. PatientId: his.PatientId,
  29187. SettleAccountsDate: recordDateTime,
  29188. Ctime: time.Now().Unix(),
  29189. Mtime: time.Now().Unix(),
  29190. MdtrtId: his.Number,
  29191. PsnNo: his.PsnNo,
  29192. MedType: strconv.FormatInt(reg_type, 10),
  29193. Status: 1,
  29194. Number: chrg_bchno,
  29195. Infcode: res.Infcode,
  29196. WarnMsg: res.WarnMsg,
  29197. Cainfo: res.Cainfo,
  29198. ErrMsg: res.ErrMsg,
  29199. RespondTime: res.RefmsgTime,
  29200. InfRefmsgid: res.InfRefmsgid,
  29201. OrderStatus: 1,
  29202. IsMedicineInsurance: 1,
  29203. SettleType: settle_accounts_type,
  29204. SettleStartTime: start_time,
  29205. SettleEndTime: end_time,
  29206. Creator: roles.AdminUserId,
  29207. Modify: roles.AdminUserId,
  29208. PType: 2,
  29209. Diagnosis: diagnosis_id,
  29210. }
  29211. err = service.CreateOrder(order)
  29212. if err != nil {
  29213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29214. return
  29215. }
  29216. c.ServeSuccessJSON(map[string]interface{}{
  29217. "failed_code": -10,
  29218. "msg": res2.ErrMsg,
  29219. })
  29220. return
  29221. }
  29222. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29223. 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)
  29224. var dat map[string]interface{}
  29225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29226. fmt.Println(dat)
  29227. } else {
  29228. fmt.Println(err)
  29229. }
  29230. saveLog(result, request_log, "2204", "上传费用明细")
  29231. userJSONBytes, _ := json.Marshal(dat)
  29232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29233. utils.ErrorLog("解析失败:%v", err)
  29234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29235. return
  29236. }
  29237. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29238. 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, "", "")
  29239. var dat map[string]interface{}
  29240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29241. fmt.Println(dat)
  29242. } else {
  29243. fmt.Println(err)
  29244. }
  29245. saveLog(result, request_log, "2204", "上传费用明细")
  29246. userJSONBytes, _ := json.Marshal(dat)
  29247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29248. utils.ErrorLog("解析失败:%v", err)
  29249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29250. return
  29251. }
  29252. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29253. 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, "", "")
  29254. var dat map[string]interface{}
  29255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29256. fmt.Println(dat)
  29257. } else {
  29258. fmt.Println(err)
  29259. }
  29260. saveLog(result, request_log, "2204", "上传费用明细")
  29261. userJSONBytes, _ := json.Marshal(dat)
  29262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29263. utils.ErrorLog("解析失败:%v", err)
  29264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29265. return
  29266. }
  29267. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29268. bytesData, _ := json.Marshal(data)
  29269. var req *http.Request
  29270. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29271. resp, _ := client.Do(req)
  29272. defer resp.Body.Close()
  29273. body, ioErr := ioutil.ReadAll(resp.Body)
  29274. if ioErr != nil {
  29275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29277. return
  29278. }
  29279. var respJSON map[string]interface{}
  29280. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29283. return
  29284. }
  29285. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29286. if status == "0" {
  29287. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29288. c.ServeSuccessJSON(map[string]interface{}{
  29289. "failed_code": -10,
  29290. "msg": err_msg,
  29291. })
  29292. return
  29293. }
  29294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29295. userJSONBytes, _ := json.Marshal(respJSON)
  29296. fmt.Println("log")
  29297. fmt.Println(string(userJSONBytes))
  29298. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29299. utils.ErrorLog("解析失败:%v", err)
  29300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29301. return
  29302. }
  29303. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29304. bytesData, _ := json.Marshal(data)
  29305. var req *http.Request
  29306. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29307. resp, _ := client.Do(req)
  29308. defer resp.Body.Close()
  29309. body, ioErr := ioutil.ReadAll(resp.Body)
  29310. if ioErr != nil {
  29311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29313. return
  29314. }
  29315. var respJSON map[string]interface{}
  29316. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29319. return
  29320. }
  29321. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29322. if status == "0" {
  29323. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29324. c.ServeSuccessJSON(map[string]interface{}{
  29325. "failed_code": -10,
  29326. "msg": err_msg,
  29327. })
  29328. return
  29329. }
  29330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29331. userJSONBytes, _ := json.Marshal(respJSON)
  29332. fmt.Println("log")
  29333. fmt.Println(string(userJSONBytes))
  29334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29335. utils.ErrorLog("解析失败:%v", err)
  29336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29337. return
  29338. }
  29339. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29340. 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, "", "")
  29341. var dat map[string]interface{}
  29342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29343. fmt.Println(dat)
  29344. } else {
  29345. fmt.Println(err)
  29346. }
  29347. saveLog(result, request_log, "2204", "上传费用明细")
  29348. userJSONBytes, _ := json.Marshal(dat)
  29349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29350. utils.ErrorLog("解析失败:%v", err)
  29351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29352. return
  29353. }
  29354. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29355. bytesData, _ := json.Marshal(data)
  29356. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29357. resp, _ := client.Do(req)
  29358. defer resp.Body.Close()
  29359. body, ioErr := ioutil.ReadAll(resp.Body)
  29360. if ioErr != nil {
  29361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29363. return
  29364. }
  29365. var respJSON map[string]interface{}
  29366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29369. return
  29370. }
  29371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29372. userJSONBytes, _ := json.Marshal(respJSON)
  29373. fmt.Println("log")
  29374. fmt.Println(string(userJSONBytes))
  29375. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29376. utils.ErrorLog("解析失败:%v", err)
  29377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29378. return
  29379. }
  29380. } else {
  29381. if miConfig.MdtrtareaAdmvs == "441202" {
  29382. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29383. if result3101.Infcode == 0 {
  29384. if len(result3101.Output.Result) > 0 {
  29385. var errMsgs []string
  29386. for _, item := range result3101.Output.Result {
  29387. errMsgs = append(errMsgs, item.VolaCont)
  29388. }
  29389. c.ServeSuccessJSON(map[string]interface{}{
  29390. "failed_code": -10,
  29391. "msg": errMsgs,
  29392. })
  29393. return
  29394. } else {
  29395. 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)
  29396. var dat map[string]interface{}
  29397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29398. fmt.Println(dat)
  29399. } else {
  29400. fmt.Println(err)
  29401. }
  29402. saveLog(result, request_log, "2204", "上传费用明细")
  29403. userJSONBytes, _ := json.Marshal(dat)
  29404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29405. utils.ErrorLog("解析失败:%v", err)
  29406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29407. return
  29408. }
  29409. }
  29410. } else {
  29411. c.ServeSuccessJSON(map[string]interface{}{
  29412. "failed_code": -10,
  29413. "msg": result3101.ErrMsg,
  29414. })
  29415. return
  29416. }
  29417. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29418. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29419. if result3101.Infcode == 0 {
  29420. if len(result3101.Output.Result) > 0 {
  29421. var errMsgs []string
  29422. for _, item := range result3101.Output.Result {
  29423. errMsgs = append(errMsgs, item.VolaCont)
  29424. }
  29425. c.ServeSuccessJSON(map[string]interface{}{
  29426. "failed_code": -10,
  29427. "msg": errMsgs,
  29428. })
  29429. return
  29430. } else {
  29431. 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)
  29432. var dat map[string]interface{}
  29433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29434. fmt.Println(dat)
  29435. } else {
  29436. fmt.Println(err)
  29437. }
  29438. saveLog(result, request_log, "2204", "上传费用明细")
  29439. userJSONBytes, _ := json.Marshal(dat)
  29440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29441. utils.ErrorLog("解析失败:%v", err)
  29442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29443. return
  29444. }
  29445. }
  29446. } else {
  29447. c.ServeSuccessJSON(map[string]interface{}{
  29448. "failed_code": -10,
  29449. "msg": result3101.ErrMsg,
  29450. })
  29451. return
  29452. }
  29453. } else {
  29454. if miConfig.Code == "H15049901371" {
  29455. 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)
  29456. var dat map[string]interface{}
  29457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29458. fmt.Println(dat)
  29459. } else {
  29460. fmt.Println(err)
  29461. }
  29462. saveLog(result, request_log, "2204", "上传费用明细")
  29463. userJSONBytes, _ := json.Marshal(dat)
  29464. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29465. utils.ErrorLog("解析失败:%v", err)
  29466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29467. return
  29468. }
  29469. res.InfRefmsgid = resFour10265.InfRefmsgid
  29470. res.Output = resFour10265.Output
  29471. res.ErrMsg = resFour10265.ErrMsg
  29472. res.Cainfo = resFour10265.Cainfo
  29473. res.WarnMsg = resFour10265.WarnMsg
  29474. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29475. res.Infcode = infocode
  29476. } else {
  29477. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" {
  29478. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29479. if result3101.Infcode == 0 {
  29480. if len(result3101.Output.Result) > 0 {
  29481. c.ServeSuccessJSON(map[string]interface{}{
  29482. "failed_code": -10,
  29483. "failed_type": 100,
  29484. "msg": result3101.Output.Result,
  29485. })
  29486. return
  29487. } else {
  29488. 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)
  29489. var dat map[string]interface{}
  29490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29491. fmt.Println(dat)
  29492. } else {
  29493. fmt.Println(err)
  29494. }
  29495. saveLog(result, request_log, "2204", "上传费用明细")
  29496. userJSONBytes, _ := json.Marshal(dat)
  29497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29498. utils.ErrorLog("解析失败:%v", err)
  29499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29500. return
  29501. }
  29502. }
  29503. } else {
  29504. c.ServeSuccessJSON(map[string]interface{}{
  29505. "failed_code": -10,
  29506. "msg": result3101.ErrMsg,
  29507. })
  29508. return
  29509. }
  29510. } else {
  29511. 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)
  29512. var dat map[string]interface{}
  29513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29514. fmt.Println(dat)
  29515. } else {
  29516. fmt.Println(err)
  29517. }
  29518. saveLog(result, request_log, "2204", "上传费用明细")
  29519. userJSONBytes, _ := json.Marshal(dat)
  29520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29521. utils.ErrorLog("解析失败:%v", err)
  29522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29523. return
  29524. }
  29525. }
  29526. }
  29527. }
  29528. }
  29529. var total_two float64
  29530. if res.Infcode == -1 {
  29531. errlog := &models.HisOrderError{
  29532. UserOrgId: adminUser.CurrentOrgId,
  29533. Ctime: time.Now().Unix(),
  29534. Mtime: time.Now().Unix(),
  29535. Number: chrg_bchno,
  29536. ErrMsg: res.ErrMsg,
  29537. Status: 1,
  29538. PatientId: id,
  29539. RecordTime: recordDateTime,
  29540. Stage: 4,
  29541. }
  29542. service.CreateErrMsgLog(errlog)
  29543. c.ServeSuccessJSON(map[string]interface{}{
  29544. "failed_code": -10,
  29545. "msg": res.ErrMsg,
  29546. })
  29547. return
  29548. }
  29549. if res.Infcode == 0 {
  29550. order := &models.HisOrder{
  29551. UserOrgId: adminUser.CurrentOrgId,
  29552. HisPatientId: his.ID,
  29553. PatientId: his.PatientId,
  29554. SettleAccountsDate: recordDateTime,
  29555. Ctime: time.Now().Unix(),
  29556. Mtime: time.Now().Unix(),
  29557. MdtrtId: his.Number,
  29558. PsnNo: his.PsnNo,
  29559. MedType: strconv.FormatInt(reg_type, 10),
  29560. Status: 1,
  29561. Number: chrg_bchno,
  29562. Infcode: res.Infcode,
  29563. WarnMsg: res.WarnMsg,
  29564. Cainfo: res.Cainfo,
  29565. ErrMsg: res.ErrMsg,
  29566. RespondTime: res.RefmsgTime,
  29567. InfRefmsgid: res.InfRefmsgid,
  29568. OrderStatus: 1,
  29569. IsMedicineInsurance: 1,
  29570. SettleType: settle_accounts_type,
  29571. SettleStartTime: start_time,
  29572. SettleEndTime: end_time,
  29573. Creator: roles.AdminUserId,
  29574. Modify: roles.AdminUserId,
  29575. PType: 2,
  29576. Diagnosis: diagnosis_id,
  29577. }
  29578. err = service.CreateOrder(order)
  29579. if err != nil {
  29580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29581. return
  29582. }
  29583. for _, item := range res.Output.Result {
  29584. temp := strings.Split(item.FeedetlSn, "-")
  29585. var advice_id int64 = 0
  29586. var project_id int64 = 0
  29587. var types int64 = 0
  29588. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29589. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29590. if temp[1] == "1" {
  29591. advice_id = id
  29592. project_id = 0
  29593. } else if temp[1] == "2" {
  29594. advice_id = 0
  29595. project_id = id
  29596. }
  29597. total_two = total_two + item.DetItemFeeSumamt
  29598. info := &models.HisOrderInfo{
  29599. OrderNumber: order.Number,
  29600. FeedetlSn: item.FeedetlSn,
  29601. UploadDate: time.Now().Unix(),
  29602. AdviceId: advice_id,
  29603. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29604. Cnt: item.Cnt,
  29605. Pric: float64(item.Pric),
  29606. PatientId: his.PatientId,
  29607. PricUplmtAmt: item.PricUplmtAmt,
  29608. SelfpayProp: item.SelfpayProp,
  29609. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29610. OverlmtAmt: item.OverlmtAmt,
  29611. PreselfpayAmt: item.PreselfpayAmt,
  29612. BasMednFlag: item.BasMednFlag,
  29613. MedChrgitmType: item.MedChrgitmType,
  29614. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29615. Status: 1,
  29616. Memo: item.Memo,
  29617. Mtime: time.Now().Unix(),
  29618. InscpScpAmt: item.InscpScpAmt,
  29619. DrtReimFlag: item.DrtReimFlag,
  29620. Ctime: time.Now().Unix(),
  29621. ListSpItemFlag: item.ListSpItemFlag,
  29622. ChldMedcFlag: item.ChldMedcFlag,
  29623. LmtUsedFlag: item.LmtUsedFlag,
  29624. ChrgitmLv: item.ChrgitmLv,
  29625. UserOrgId: adminUser.CurrentOrgId,
  29626. HisPatientId: his.ID,
  29627. OrderId: order.ID,
  29628. ProjectId: project_id,
  29629. Type: types,
  29630. }
  29631. service.CreateOrderInfo(info)
  29632. }
  29633. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29634. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29635. var total float64
  29636. for _, item := range prescriptions {
  29637. if item.Type == 1 { //药品
  29638. for _, subItem := range item.HisDoctorAdviceInfo {
  29639. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29640. total_one := price * subItem.PrescribingNumber
  29641. fmt.Println("subItem")
  29642. fmt.Println(subItem.Price)
  29643. fmt.Println("price")
  29644. fmt.Println(price)
  29645. fmt.Println("total_one")
  29646. fmt.Println(total_one)
  29647. total = total + total_one
  29648. fmt.Println(total)
  29649. }
  29650. }
  29651. if item.Type == 2 { //项目
  29652. for _, subItem := range item.HisPrescriptionProject {
  29653. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29654. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29655. total_one := price * cnt
  29656. total = total + total_one
  29657. }
  29658. }
  29659. }
  29660. allTotal := fmt.Sprintf("%.2f", total)
  29661. if res.Infcode == 0 {
  29662. var rf []*ResultFive
  29663. json.Unmarshal([]byte(his.Iinfo), &rf)
  29664. chrg_bchno := chrg_bchno
  29665. cert_no := his.Certno
  29666. var insutypes []string
  29667. var insutype string
  29668. var is390 int = 0
  29669. var is310 int = 0
  29670. for _, item := range rf {
  29671. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29672. insutypes = append(insutypes, item.Insutype)
  29673. }
  29674. }
  29675. if len(insutypes) == 1 {
  29676. insutype = insutypes[0]
  29677. } else {
  29678. for _, i := range insutypes {
  29679. if i == "390" {
  29680. is390 = 1
  29681. }
  29682. if i == "310" {
  29683. is310 = 1
  29684. }
  29685. }
  29686. }
  29687. if is390 == 1 {
  29688. insutype = "390"
  29689. }
  29690. if is310 == 1 {
  29691. insutype = "310"
  29692. }
  29693. if len(insutypes) == 0 {
  29694. insutype = "390"
  29695. }
  29696. if len(insutypes) == 2 {
  29697. insutype = strconv.FormatInt(his.SocialType, 10)
  29698. }
  29699. //insutype = "390"
  29700. if his.IdCardType == 1 {
  29701. cert_no = his.MedicalInsuranceNumber
  29702. } else {
  29703. cert_no = his.Certno
  29704. }
  29705. var res ResultSeven
  29706. var ahres ResultSevenAH
  29707. var resSeven10265 ResultSeven10265
  29708. var resSeven10265Two ResultSeven10265Two
  29709. var gzresSeven10265Two GZResultSeven10265Two
  29710. if miConfig.MdtrtareaAdmvs == "421300" {
  29711. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29712. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29713. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29714. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29715. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29716. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29717. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29718. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29719. resp, requestErr := http.Get(api)
  29720. if requestErr != nil {
  29721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29722. return
  29723. }
  29724. body, ioErr := ioutil.ReadAll(resp.Body)
  29725. if ioErr != nil {
  29726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29728. return
  29729. }
  29730. var respJSON map[string]interface{}
  29731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29734. return
  29735. }
  29736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29737. result, _ := json.Marshal(respJSON)
  29738. fmt.Println("log")
  29739. fmt.Println(string(result))
  29740. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29741. utils.ErrorLog("解析失败:%v", err)
  29742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29743. return
  29744. }
  29745. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29746. if reg_type == 11 && his.Insutype == "390" {
  29747. reg_type = 110104
  29748. }
  29749. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29750. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29751. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29752. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29753. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29754. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29755. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29756. resp, requestErr := http.Get(api)
  29757. if requestErr != nil {
  29758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29759. return
  29760. }
  29761. body, ioErr := ioutil.ReadAll(resp.Body)
  29762. if ioErr != nil {
  29763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29765. return
  29766. }
  29767. var respJSON map[string]interface{}
  29768. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29771. return
  29772. }
  29773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29774. result, _ := json.Marshal(respJSON)
  29775. fmt.Println("log")
  29776. fmt.Println(string(result))
  29777. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29778. utils.ErrorLog("解析失败:%v", err)
  29779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29780. return
  29781. }
  29782. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29783. if reg_type == 11 && his.Insutype == "390" {
  29784. reg_type = 110104
  29785. }
  29786. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29787. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29788. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29790. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29791. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29792. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29793. resp, requestErr := http.Get(api)
  29794. if requestErr != nil {
  29795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29796. return
  29797. }
  29798. body, ioErr := ioutil.ReadAll(resp.Body)
  29799. if ioErr != nil {
  29800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29802. return
  29803. }
  29804. var respJSON map[string]interface{}
  29805. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29808. return
  29809. }
  29810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29811. result, _ := json.Marshal(respJSON)
  29812. fmt.Println("log")
  29813. fmt.Println(string(result))
  29814. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29815. utils.ErrorLog("解析失败:%v", err)
  29816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29817. return
  29818. }
  29819. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29820. if reg_type == 11 && his.Insutype == "390" {
  29821. reg_type = 110104
  29822. }
  29823. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29824. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29825. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29826. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29827. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29828. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29829. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29830. resp, requestErr := http.Get(api)
  29831. if requestErr != nil {
  29832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29833. return
  29834. }
  29835. body, ioErr := ioutil.ReadAll(resp.Body)
  29836. if ioErr != nil {
  29837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29839. return
  29840. }
  29841. var respJSON map[string]interface{}
  29842. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29845. return
  29846. }
  29847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29848. result, _ := json.Marshal(respJSON)
  29849. fmt.Println("log")
  29850. fmt.Println(string(result))
  29851. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29852. utils.ErrorLog("解析失败:%v", err)
  29853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29854. return
  29855. }
  29856. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29857. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29858. if result3101.Infcode == "0" {
  29859. if len(result3101.Output.Result) > 0 {
  29860. var errMsgs []string
  29861. for _, item := range result3101.Output.Result {
  29862. errMsgs = append(errMsgs, item.VolaCont)
  29863. }
  29864. c.ServeSuccessJSON(map[string]interface{}{
  29865. "failed_code": -10,
  29866. "msg": errMsgs,
  29867. })
  29868. return
  29869. } else {
  29870. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29871. if his.IdCardType != 4 {
  29872. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29873. bas := strings.Split(psn_info.CardInfo, "|")
  29874. if his.IdCardType == 1 {
  29875. cert_no = bas[2]
  29876. } else {
  29877. cert_no = bas[1]
  29878. }
  29879. } else {
  29880. cert_no = his.Certno
  29881. }
  29882. //江苏地区国家医保医疗类别
  29883. //职工透析:医疗类别选特殊情况门诊9933
  29884. //居民血透门慢: 医疗类别选门诊慢病1402
  29885. //var med_type string
  29886. //if his.Insutype == "310" {
  29887. // if reg_type == 14 {
  29888. // med_type = "9933"
  29889. // } else if reg_type == 11 {
  29890. // med_type = "11"
  29891. //
  29892. // }
  29893. //} else if his.Insutype == "390" {
  29894. // if reg_type == 14 {
  29895. // med_type = "1402"
  29896. // } else if reg_type == 11 {
  29897. // med_type = "11"
  29898. // }
  29899. //}
  29900. var api string
  29901. if miConfig.MdtrtareaAdmvs == "320921" {
  29902. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29903. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29904. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29905. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29906. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29907. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29908. "&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
  29909. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29910. } else {
  29911. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29912. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29913. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29914. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29915. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29916. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29917. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29918. "&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
  29919. }
  29920. resp, requestErr := http.Get(api)
  29921. if requestErr != nil {
  29922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29923. return
  29924. }
  29925. body, ioErr := ioutil.ReadAll(resp.Body)
  29926. if ioErr != nil {
  29927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29929. return
  29930. }
  29931. var respJSON map[string]interface{}
  29932. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29935. return
  29936. }
  29937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29938. result, _ := json.Marshal(respJSON)
  29939. fmt.Println("log")
  29940. fmt.Println(string(result))
  29941. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29942. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29943. utils.ErrorLog("解析失败:%v", err)
  29944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29945. return
  29946. }
  29947. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29948. res.Output = resSeven10265.Output
  29949. res.ErrMsg = resSeven10265.ErrMsg
  29950. res.Cainfo = resSeven10265.Cainfo
  29951. res.WarnMsg = resSeven10265.WarnMsg
  29952. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29953. res.Infcode = infocode
  29954. } else {
  29955. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29956. utils.ErrorLog("解析失败:%v", err)
  29957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29958. return
  29959. }
  29960. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29961. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29962. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29963. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29964. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29965. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29966. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29967. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29968. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29969. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29970. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29971. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29972. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29973. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29974. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29975. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29976. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29977. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29978. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29979. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29980. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29981. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29982. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29983. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29984. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29985. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29986. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29987. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29988. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29989. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29990. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29991. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29992. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29993. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29994. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29995. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29996. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29997. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29998. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29999. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30000. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30001. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30002. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30003. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30004. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30005. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30006. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30007. res.ErrMsg = resSeven10265Two.ErrMsg
  30008. res.Cainfo = resSeven10265Two.Cainfo
  30009. res.WarnMsg = resSeven10265Two.WarnMsg
  30010. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30011. res.Infcode = infocode
  30012. }
  30013. }
  30014. }
  30015. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30016. psn_info, _ := service.GetPsnByPatientId(id)
  30017. var verify_number string
  30018. if psn_info.IdCardType == 4 {
  30019. verify_number = psn_info.VerifyNumber
  30020. } else if psn_info.IdCardType == 1 {
  30021. bas := strings.Split(psn_info.CardInfo, "|")
  30022. cardNumber := bas[2]
  30023. verify_number = cardNumber
  30024. } else {
  30025. psn_info.IdCardType = 2
  30026. verify_number = psn_info.Certno
  30027. }
  30028. var api string
  30029. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30030. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30031. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30033. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30034. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30035. "&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
  30036. resp, requestErr := http.Get(api)
  30037. if requestErr != nil {
  30038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30039. return
  30040. }
  30041. body, ioErr := ioutil.ReadAll(resp.Body)
  30042. if ioErr != nil {
  30043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30045. return
  30046. }
  30047. var respJSON map[string]interface{}
  30048. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30051. return
  30052. }
  30053. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30054. result, _ := json.Marshal(respJSON)
  30055. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30056. utils.ErrorLog("解析失败:%v", err)
  30057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30058. return
  30059. }
  30060. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30061. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30062. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30063. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30064. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30065. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30066. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30067. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30068. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30069. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30070. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30071. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30072. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30073. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30074. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30075. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30076. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30077. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30078. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30079. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30080. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30081. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30082. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30083. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30084. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30085. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30086. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30087. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30088. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30089. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30090. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30091. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30092. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30093. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30094. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30095. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30096. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30097. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30098. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30099. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30100. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30101. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30102. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30103. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30104. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30105. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30106. res.ErrMsg = resSeven10265.ErrMsg
  30107. res.Cainfo = resSeven10265.Cainfo
  30108. res.WarnMsg = resSeven10265.WarnMsg
  30109. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30110. res.Infcode = infocode
  30111. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30112. acct_used_flag := "1"
  30113. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30114. var result string
  30115. var request_log string
  30116. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30117. 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)
  30118. } else {
  30119. 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)
  30120. }
  30121. var dat map[string]interface{}
  30122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30123. fmt.Println(dat)
  30124. } else {
  30125. fmt.Println(err)
  30126. }
  30127. saveLog(result, request_log, "2206", "预结算")
  30128. userJSONBytes, _ := json.Marshal(dat)
  30129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30130. utils.ErrorLog("解析失败:%v", err)
  30131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30132. return
  30133. }
  30134. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30135. var result string
  30136. var request_log string
  30137. if his.IdCardType == 2 {
  30138. insutype = strconv.FormatInt(his.SocialType, 10)
  30139. 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, "")
  30140. } else if his.IdCardType == 1 {
  30141. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30142. bas := strings.Split(psn_info.CardInfo, "|")
  30143. basNumber := bas[2]
  30144. card_sn := bas[3]
  30145. var rf []*ResultFive
  30146. json.Unmarshal([]byte(his.Iinfo), &rf)
  30147. var psn_type string
  30148. for _, item := range rf {
  30149. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30150. psn_type = item.PsnType
  30151. }
  30152. }
  30153. insutype = strconv.FormatInt(his.SocialType, 10)
  30154. 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)
  30155. } else {
  30156. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30157. //bas := strings.Split(psn_info.CardInfo, "|")
  30158. //basNumber := bas[2]
  30159. //card_sn := bas[3]
  30160. var rf []*ResultFive
  30161. json.Unmarshal([]byte(his.Iinfo), &rf)
  30162. var psn_type string
  30163. for _, item := range rf {
  30164. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30165. psn_type = item.PsnType
  30166. }
  30167. }
  30168. insutype = strconv.FormatInt(his.SocialType, 10)
  30169. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30170. 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)
  30171. }
  30172. var dat map[string]interface{}
  30173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30174. fmt.Println(dat)
  30175. } else {
  30176. fmt.Println(err)
  30177. }
  30178. saveLog(result, request_log, "2206", "预结算")
  30179. userJSONBytes, _ := json.Marshal(dat)
  30180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30181. utils.ErrorLog("解析失败:%v", err)
  30182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30183. return
  30184. }
  30185. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30186. var result string
  30187. var request_log string
  30188. if his.IdCardType == 2 {
  30189. insutype = strconv.FormatInt(his.SocialType, 10)
  30190. 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, "")
  30191. } else if his.IdCardType == 1 {
  30192. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30193. bas := strings.Split(psn_info.CardInfo, "|")
  30194. basNumber := bas[0]
  30195. card_sn := ""
  30196. var rf []*ResultFive
  30197. json.Unmarshal([]byte(his.Iinfo), &rf)
  30198. var psn_type string
  30199. for _, item := range rf {
  30200. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30201. psn_type = item.PsnType
  30202. }
  30203. }
  30204. insutype = strconv.FormatInt(his.SocialType, 10)
  30205. 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)
  30206. } else {
  30207. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30208. //bas := strings.Split(psn_info.CardInfo, "|")
  30209. //basNumber := bas[2]
  30210. //card_sn := bas[3]
  30211. var rf []*ResultFive
  30212. json.Unmarshal([]byte(his.Iinfo), &rf)
  30213. var psn_type string
  30214. for _, item := range rf {
  30215. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30216. psn_type = item.PsnType
  30217. }
  30218. }
  30219. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30220. 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)
  30221. }
  30222. var dat map[string]interface{}
  30223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30224. fmt.Println(dat)
  30225. } else {
  30226. fmt.Println(err)
  30227. }
  30228. saveLog(result, request_log, "2206", "预结算")
  30229. userJSONBytes, _ := json.Marshal(dat)
  30230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30231. utils.ErrorLog("解析失败:%v", err)
  30232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30233. return
  30234. }
  30235. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30236. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30237. if his.IdCardType == 4 {
  30238. psn_info.VerifyNumber = psn_info.VerifyNumber
  30239. cert_no = psn_info.VerifyNumber
  30240. } else if his.IdCardType == 2 {
  30241. cert_no = psn_info.Certno
  30242. psn_info.VerifyNumber = psn_info.Certno
  30243. } else {
  30244. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30245. bas := strings.Split(psn_info.CardInfo, "|")
  30246. if his.IdCardType == 1 {
  30247. cert_no = bas[2]
  30248. } else {
  30249. cert_no = bas[1]
  30250. }
  30251. }
  30252. var api string
  30253. var med_type string
  30254. if his.Insutype == "390" {
  30255. if reg_type == 992102 {
  30256. med_type = "992102"
  30257. }
  30258. if reg_type == 140104 {
  30259. med_type = "140104"
  30260. }
  30261. if reg_type == 140201 {
  30262. med_type = "140201"
  30263. }
  30264. if reg_type == 14 {
  30265. med_type = "140104"
  30266. }
  30267. } else if his.Insutype == "310" {
  30268. if reg_type == 992102 {
  30269. med_type = "992102"
  30270. }
  30271. if reg_type == 140104 {
  30272. med_type = "140104"
  30273. }
  30274. if reg_type == 140201 {
  30275. med_type = "140201"
  30276. }
  30277. if reg_type == 14 {
  30278. med_type = "140104"
  30279. }
  30280. }
  30281. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30282. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30283. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30284. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30285. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30286. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30287. "&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
  30288. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30289. resp, requestErr := http.Get(api)
  30290. if requestErr != nil {
  30291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30292. return
  30293. }
  30294. body, ioErr := ioutil.ReadAll(resp.Body)
  30295. if ioErr != nil {
  30296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30298. return
  30299. }
  30300. var respJSON map[string]interface{}
  30301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30304. return
  30305. }
  30306. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30307. if status == "0" {
  30308. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30309. c.ServeSuccessJSON(map[string]interface{}{
  30310. "failed_code": -10,
  30311. "msg": err_msg,
  30312. })
  30313. return
  30314. }
  30315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30316. result, _ := json.Marshal(respJSON)
  30317. fmt.Println("log")
  30318. fmt.Println(string(result))
  30319. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30320. utils.ErrorLog("解析失败:%v", err)
  30321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30322. return
  30323. }
  30324. res.InfRefmsgid = ahres.InfRefmsgid
  30325. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30326. // 创建对应的Time类型
  30327. t := time.UnixMilli(timestamp)
  30328. // 格式化成指定的日期字符串
  30329. str := t.Format("2006-01-02 15:04:05")
  30330. res.Output.Setlinfo.SetlTime = str
  30331. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30332. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30333. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30334. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30335. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30336. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30337. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30338. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30339. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30340. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30341. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30342. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30343. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30344. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30345. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30346. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30347. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30348. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30349. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30350. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30351. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30352. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30353. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30354. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30355. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30356. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30357. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30358. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30359. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30360. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30361. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30362. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30363. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30364. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30365. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30366. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30367. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30368. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30369. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30370. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30371. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30372. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30373. //res.Output.Setldetail = ahres.Output.Setldetail
  30374. res.ErrMsg = ahres.ErrMsg
  30375. res.Cainfo = ahres.Cainfo
  30376. res.WarnMsg = ahres.WarnMsg
  30377. res.Infcode = ahres.Infcode
  30378. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30379. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30380. if his.IdCardType == 4 {
  30381. psn_info.VerifyNumber = psn_info.VerifyNumber
  30382. cert_no = psn_info.Certno
  30383. } else if his.IdCardType == 2 {
  30384. cert_no = psn_info.Certno
  30385. psn_info.VerifyNumber = psn_info.Certno
  30386. } else {
  30387. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30388. bas := strings.Split(psn_info.CardInfo, "|")
  30389. if his.IdCardType == 1 {
  30390. cert_no = bas[2]
  30391. } else {
  30392. cert_no = bas[1]
  30393. }
  30394. }
  30395. var api string
  30396. var med_type string
  30397. if his.Insutype == "390" {
  30398. if reg_type == 992102 {
  30399. med_type = "992102"
  30400. }
  30401. if reg_type == 140104 {
  30402. med_type = "140104"
  30403. }
  30404. if reg_type == 140201 {
  30405. med_type = "140201"
  30406. }
  30407. if reg_type == 14 {
  30408. med_type = "14"
  30409. }
  30410. } else if his.Insutype == "310" {
  30411. if reg_type == 992102 {
  30412. med_type = "992102"
  30413. }
  30414. if reg_type == 140104 {
  30415. med_type = "140104"
  30416. }
  30417. if reg_type == 140201 {
  30418. med_type = "140201"
  30419. }
  30420. if reg_type == 14 {
  30421. med_type = "14"
  30422. }
  30423. }
  30424. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30425. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30426. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30427. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30428. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30429. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30430. "&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
  30431. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30432. resp, requestErr := http.Get(api)
  30433. if requestErr != nil {
  30434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30435. return
  30436. }
  30437. body, ioErr := ioutil.ReadAll(resp.Body)
  30438. if ioErr != nil {
  30439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30441. return
  30442. }
  30443. var respJSON map[string]interface{}
  30444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30447. return
  30448. }
  30449. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30450. if status == "0" {
  30451. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30452. c.ServeSuccessJSON(map[string]interface{}{
  30453. "failed_code": -10,
  30454. "msg": err_msg,
  30455. })
  30456. return
  30457. }
  30458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30459. result, _ := json.Marshal(respJSON)
  30460. fmt.Println("log")
  30461. fmt.Println(string(result))
  30462. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30463. utils.ErrorLog("解析失败:%v", err)
  30464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30465. return
  30466. }
  30467. res.InfRefmsgid = ahres.InfRefmsgid
  30468. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30469. // 创建对应的Time类型
  30470. t := time.UnixMilli(timestamp)
  30471. // 格式化成指定的日期字符串
  30472. str := t.Format("2006-01-02 15:04:05")
  30473. res.Output.Setlinfo.SetlTime = str
  30474. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30475. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30476. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30477. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30478. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30479. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30480. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30481. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30482. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30483. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30484. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30485. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30486. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30487. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30488. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30489. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30490. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30491. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30492. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30493. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30494. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30495. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30496. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30497. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30498. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30499. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30500. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30501. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30502. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30503. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30504. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30505. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30506. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30507. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30508. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30509. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30510. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30511. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30512. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30513. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30514. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30515. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30516. //res.Output.Setldetail = ahres.Output.Setldetail
  30517. res.ErrMsg = ahres.ErrMsg
  30518. res.Cainfo = ahres.Cainfo
  30519. res.WarnMsg = ahres.WarnMsg
  30520. res.Infcode = ahres.Infcode
  30521. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30522. var result string
  30523. var request_log string
  30524. if his.IdCardType == 2 {
  30525. 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")
  30526. } else if his.IdCardType == 1 {
  30527. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30528. bas := strings.Split(psn_info.CardInfo, "|")
  30529. basNumber := bas[2]
  30530. card_sn := bas[3]
  30531. 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")
  30532. } else {
  30533. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30534. 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")
  30535. }
  30536. var dat map[string]interface{}
  30537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30538. fmt.Println(dat)
  30539. } else {
  30540. fmt.Println(err)
  30541. }
  30542. saveLog(result, request_log, "2206", "预结算")
  30543. userJSONBytes, _ := json.Marshal(dat)
  30544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30545. utils.ErrorLog("解析失败:%v", err)
  30546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30547. return
  30548. }
  30549. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30550. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30551. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30552. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30554. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30555. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30556. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30557. resp, requestErr := http.Get(api)
  30558. if requestErr != nil {
  30559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30560. return
  30561. }
  30562. body, ioErr := ioutil.ReadAll(resp.Body)
  30563. if ioErr != nil {
  30564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30566. return
  30567. }
  30568. var respJSON map[string]interface{}
  30569. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30572. return
  30573. }
  30574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30575. result, _ := json.Marshal(respJSON)
  30576. fmt.Println("log")
  30577. fmt.Println(string(result))
  30578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30579. utils.ErrorLog("解析失败:%v", err)
  30580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30581. return
  30582. }
  30583. } else {
  30584. if miConfig.MdtrtareaAdmvs == "441202" {
  30585. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30586. if result3101.Infcode == 0 {
  30587. if len(result3101.Output.Result) > 0 {
  30588. c.ServeSuccessJSON(map[string]interface{}{
  30589. "failed_code": -10,
  30590. "failed_type": 100,
  30591. "msg": result3101.Output.Result,
  30592. })
  30593. return
  30594. } else {
  30595. var result string
  30596. var request_log string
  30597. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30598. allTotal = fmt.Sprintf("%.2f", total_two)
  30599. if his.IdCardType == 4 {
  30600. 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)
  30601. } else {
  30602. 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)
  30603. }
  30604. var dat map[string]interface{}
  30605. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30606. fmt.Println(dat)
  30607. } else {
  30608. fmt.Println(err)
  30609. }
  30610. saveLog(result, request_log, "2206", "预结算")
  30611. //userJSONBytes, _ := json.Marshal(dat)
  30612. //
  30613. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30614. // utils.ErrorLog("解析失败:%v", err)
  30615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30616. // return
  30617. //}
  30618. userJSONBytes, _ := json.Marshal(dat)
  30619. if miConfig.Code == "H15049901371" {
  30620. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30621. utils.ErrorLog("解析失败:%v", err)
  30622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30623. return
  30624. }
  30625. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30626. res.Output = resSeven10265.Output
  30627. res.ErrMsg = resSeven10265.ErrMsg
  30628. res.Cainfo = resSeven10265.Cainfo
  30629. res.WarnMsg = resSeven10265.WarnMsg
  30630. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30631. res.Infcode = infocode
  30632. } else {
  30633. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30634. utils.ErrorLog("解析失败:%v", err)
  30635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30636. return
  30637. }
  30638. }
  30639. }
  30640. } else {
  30641. c.ServeSuccessJSON(map[string]interface{}{
  30642. "failed_code": -10,
  30643. "msg": result3101.ErrMsg,
  30644. })
  30645. return
  30646. }
  30647. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30648. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30649. if result3101.Infcode == 0 {
  30650. if len(result3101.Output.Result) > 0 {
  30651. var errMsgs []string
  30652. for _, item := range result3101.Output.Result {
  30653. errMsgs = append(errMsgs, item.VolaCont)
  30654. }
  30655. c.ServeSuccessJSON(map[string]interface{}{
  30656. "failed_code": -10,
  30657. "msg": errMsgs,
  30658. })
  30659. return
  30660. } else {
  30661. var result string
  30662. var request_log string
  30663. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30664. allTotal = fmt.Sprintf("%.2f", total_two)
  30665. if his.IdCardType == 4 {
  30666. 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)
  30667. } else {
  30668. 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)
  30669. }
  30670. var dat map[string]interface{}
  30671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30672. fmt.Println(dat)
  30673. } else {
  30674. fmt.Println(err)
  30675. }
  30676. saveLog(result, request_log, "2206", "预结算")
  30677. //userJSONBytes, _ := json.Marshal(dat)
  30678. //
  30679. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30680. // utils.ErrorLog("解析失败:%v", err)
  30681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30682. // return
  30683. //}
  30684. userJSONBytes, _ := json.Marshal(dat)
  30685. if miConfig.Code == "H15049901371" {
  30686. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30687. utils.ErrorLog("解析失败:%v", err)
  30688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30689. return
  30690. }
  30691. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30692. res.Output = resSeven10265.Output
  30693. res.ErrMsg = resSeven10265.ErrMsg
  30694. res.Cainfo = resSeven10265.Cainfo
  30695. res.WarnMsg = resSeven10265.WarnMsg
  30696. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30697. res.Infcode = infocode
  30698. } else {
  30699. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30700. utils.ErrorLog("解析失败:%v", err)
  30701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30702. return
  30703. }
  30704. }
  30705. }
  30706. } else {
  30707. c.ServeSuccessJSON(map[string]interface{}{
  30708. "failed_code": -10,
  30709. "msg": result3101.ErrMsg,
  30710. })
  30711. return
  30712. }
  30713. } else {
  30714. var result string
  30715. var request_log string
  30716. var dat map[string]interface{}
  30717. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30718. allTotal = fmt.Sprintf("%.2f", total_two)
  30719. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  30720. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30721. if result3101.Infcode == 0 {
  30722. if len(result3101.Output.Result) > 0 {
  30723. c.ServeSuccessJSON(map[string]interface{}{
  30724. "failed_code": -10,
  30725. "failed_type": 100,
  30726. "msg": result3101.Output.Result,
  30727. })
  30728. return
  30729. } else {
  30730. var result string
  30731. var request_log string
  30732. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30733. allTotal = fmt.Sprintf("%.2f", total_two)
  30734. if his.IdCardType == 4 {
  30735. 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)
  30736. } else {
  30737. if his.IdCardType == 2 {
  30738. cert_no = psn_info.Certno
  30739. psn_info.VerifyNumber = psn_info.Certno
  30740. } else {
  30741. bas := strings.Split(psn_info.CardInfo, "|")
  30742. cert_no = bas[2]
  30743. }
  30744. 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)
  30745. }
  30746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30747. fmt.Println(dat)
  30748. } else {
  30749. fmt.Println(err)
  30750. }
  30751. saveLog(result, request_log, "2206", "预结算")
  30752. }
  30753. } else {
  30754. c.ServeSuccessJSON(map[string]interface{}{
  30755. "failed_code": -10,
  30756. "msg": result3101.ErrMsg,
  30757. })
  30758. return
  30759. }
  30760. } else {
  30761. if his.IdCardType == 4 {
  30762. 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)
  30763. } else {
  30764. if his.IdCardType == 2 {
  30765. cert_no = psn_info.Certno
  30766. psn_info.VerifyNumber = psn_info.Certno
  30767. } else {
  30768. bas := strings.Split(psn_info.CardInfo, "|")
  30769. cert_no = bas[2]
  30770. }
  30771. 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)
  30772. }
  30773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30774. fmt.Println(dat)
  30775. } else {
  30776. fmt.Println(err)
  30777. }
  30778. saveLog(result, request_log, "2206", "预结算")
  30779. }
  30780. //userJSONBytes, _ := json.Marshal(dat)
  30781. //
  30782. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30783. // utils.ErrorLog("解析失败:%v", err)
  30784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30785. // return
  30786. //}
  30787. userJSONBytes, _ := json.Marshal(dat)
  30788. if miConfig.Code == "H15049901371" {
  30789. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30790. utils.ErrorLog("解析失败:%v", err)
  30791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30792. return
  30793. }
  30794. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30795. res.Output = resSeven10265.Output
  30796. res.ErrMsg = resSeven10265.ErrMsg
  30797. res.Cainfo = resSeven10265.Cainfo
  30798. res.WarnMsg = resSeven10265.WarnMsg
  30799. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30800. res.Infcode = infocode
  30801. } else {
  30802. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30803. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30804. utils.ErrorLog("解析失败:%v", err)
  30805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30806. return
  30807. }
  30808. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30809. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30810. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30811. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30812. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30813. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30814. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30815. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30816. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30817. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30818. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30819. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30820. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30821. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30822. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30823. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30824. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30825. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30826. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30827. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30828. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30829. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30830. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30831. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30832. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30833. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30834. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30835. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30836. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30837. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30838. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30839. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30840. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30841. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30842. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30843. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30844. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30845. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30846. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30847. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30848. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30849. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30850. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30851. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30852. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30853. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30854. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30855. res.Cainfo = gzresSeven10265Two.Cainfo
  30856. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30857. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30858. //res.Infcode = infocode
  30859. } else {
  30860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30861. utils.ErrorLog("解析失败:%v", err)
  30862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30863. return
  30864. }
  30865. }
  30866. }
  30867. }
  30868. }
  30869. utils.ErrorLog("解析失败:%v", res.Infcode)
  30870. if res.Infcode == -1 {
  30871. errlog := &models.HisOrderError{
  30872. UserOrgId: adminUser.CurrentOrgId,
  30873. Ctime: time.Now().Unix(),
  30874. Mtime: time.Now().Unix(),
  30875. Number: chrg_bchno,
  30876. ErrMsg: res.ErrMsg,
  30877. Status: 1,
  30878. PatientId: id,
  30879. RecordTime: recordDateTime,
  30880. Stage: 20,
  30881. }
  30882. service.CreateErrMsgLog(errlog)
  30883. c.ServeSuccessJSON(map[string]interface{}{
  30884. "failed_code": -10,
  30885. "msg": res.ErrMsg,
  30886. })
  30887. return
  30888. }
  30889. if res.Infcode != 0 {
  30890. errlog := &models.HisOrderError{
  30891. UserOrgId: adminUser.CurrentOrgId,
  30892. Ctime: time.Now().Unix(),
  30893. Mtime: time.Now().Unix(),
  30894. Number: chrg_bchno,
  30895. ErrMsg: res.ErrMsg,
  30896. Status: 1,
  30897. PatientId: id,
  30898. RecordTime: recordDateTime,
  30899. Stage: 20,
  30900. }
  30901. service.CreateErrMsgLog(errlog)
  30902. c.ServeSuccessJSON(map[string]interface{}{
  30903. "failed_code": -10,
  30904. "msg": res.ErrMsg,
  30905. })
  30906. return
  30907. } else {
  30908. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30909. order.OrderStatus = 1
  30910. order.IsPre = 1
  30911. order.Status = 1
  30912. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30913. order.SetlId = res.Output.Setlinfo.SetlID
  30914. order.PsnNo = res.Output.Setlinfo.PsnNo
  30915. order.PsnName = res.Output.Setlinfo.PsnName
  30916. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30917. order.Certno = res.Output.Setlinfo.Certno
  30918. order.Gend = res.Output.Setlinfo.Gend
  30919. order.Naty = res.Output.Setlinfo.Naty
  30920. order.Age = res.Output.Setlinfo.Age
  30921. order.Insutype = res.Output.Setlinfo.Insutype
  30922. order.PsnType = res.Output.Setlinfo.PsnType
  30923. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30924. order.SetlTime = res.Output.Setlinfo.SetlTime
  30925. order.AcctUsedFlag = acct_used_flag
  30926. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30927. if res.Output.Setlinfo.MedType == "140101" {
  30928. order.MedType = "14"
  30929. } else {
  30930. if res.Output.Setlinfo.MedType == "110104" {
  30931. order.MedType = "11"
  30932. } else {
  30933. order.MedType = res.Output.Setlinfo.MedType
  30934. }
  30935. }
  30936. if res.Output.Setlinfo.MedType == "992102" {
  30937. order.MedType = "992102"
  30938. }
  30939. if res.Output.Setlinfo.MedType == "140104" {
  30940. order.MedType = "140104"
  30941. }
  30942. if res.Output.Setlinfo.MedType == "140201" {
  30943. order.MedType = "140201"
  30944. }
  30945. if res.Output.Setlinfo.MedType == "14" {
  30946. order.MedType = "14"
  30947. }
  30948. if reg_type == 1112 {
  30949. order.MedType = "1112"
  30950. }
  30951. if reg_type == 1111 {
  30952. order.MedType = "1111"
  30953. }
  30954. order.ClrType = res.Output.Setlinfo.ClrType
  30955. if adminUser.CurrentOrgId == 10480 {
  30956. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30957. order.ClrType = "11"
  30958. } else {
  30959. order.ClrType = "9903"
  30960. }
  30961. }
  30962. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30963. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30964. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30965. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30966. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30967. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30968. order.HifpPay = res.Output.Setlinfo.HifpPay
  30969. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30970. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30971. order.HifesPay = res.Output.Setlinfo.HifesPay
  30972. order.HifobPay = res.Output.Setlinfo.HifobPay
  30973. order.MafPay = res.Output.Setlinfo.MafPay
  30974. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30975. order.OthPay = res.Output.Setlinfo.OthPay
  30976. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30977. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30978. order.AcctPay = res.Output.Setlinfo.AcctPay
  30979. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30980. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30981. order.Balc = res.Output.Setlinfo.Balc
  30982. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30983. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30984. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30985. order.ClrWay = res.Output.Setlinfo.ClrWay
  30986. order.Creator = order.Creator
  30987. order.Modify = roles.AdminUserId
  30988. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30989. //detailStr := string(setlDetail)
  30990. //order.SetlDetail = detailStr
  30991. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30992. err = service.UpDateOrder(order)
  30993. if err == nil {
  30994. c.ServeSuccessJSON(map[string]interface{}{
  30995. "msg": "预结算成功",
  30996. })
  30997. } else {
  30998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30999. return
  31000. }
  31001. }
  31002. } else {
  31003. adminUser := c.GetAdminUserInfo()
  31004. errlog := &models.HisOrderError{
  31005. UserOrgId: adminUser.CurrentOrgId,
  31006. Ctime: time.Now().Unix(),
  31007. Mtime: time.Now().Unix(),
  31008. ErrMsg: res.ErrMsg,
  31009. Status: 1,
  31010. PatientId: id,
  31011. RecordTime: recordDateTime,
  31012. Stage: 4,
  31013. }
  31014. service.CreateErrMsgLog(errlog)
  31015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31016. return
  31017. }
  31018. } else {
  31019. if miConfig.MdtrtareaAdmvs == "150499" {
  31020. order := &models.HisOrder{
  31021. UserOrgId: adminUser.CurrentOrgId,
  31022. HisPatientId: his.ID,
  31023. PatientId: his.PatientId,
  31024. SettleAccountsDate: recordDateTime,
  31025. Ctime: time.Now().Unix(),
  31026. Mtime: time.Now().Unix(),
  31027. MdtrtId: his.Number,
  31028. PsnNo: his.PsnNo,
  31029. MedType: strconv.FormatInt(reg_type, 10),
  31030. Status: 1,
  31031. Number: chrg_bchno,
  31032. Infcode: res.Infcode,
  31033. WarnMsg: res.WarnMsg,
  31034. Cainfo: res.Cainfo,
  31035. ErrMsg: res.ErrMsg,
  31036. RespondTime: res.RefmsgTime,
  31037. InfRefmsgid: res.InfRefmsgid,
  31038. OrderStatus: 1,
  31039. IsMedicineInsurance: 1,
  31040. SettleType: settle_accounts_type,
  31041. SettleStartTime: start_time,
  31042. SettleEndTime: end_time,
  31043. Creator: roles.AdminUserId,
  31044. Modify: roles.AdminUserId,
  31045. PType: 2,
  31046. Diagnosis: diagnosis_id,
  31047. }
  31048. err = service.CreateOrder(order)
  31049. if err != nil {
  31050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31051. return
  31052. }
  31053. }
  31054. adminUser := c.GetAdminUserInfo()
  31055. errlog := &models.HisOrderError{
  31056. UserOrgId: adminUser.CurrentOrgId,
  31057. Ctime: time.Now().Unix(),
  31058. Mtime: time.Now().Unix(),
  31059. ErrMsg: res.ErrMsg,
  31060. Status: 1,
  31061. PatientId: id,
  31062. RecordTime: recordDateTime,
  31063. Stage: 4,
  31064. }
  31065. service.CreateErrMsgLog(errlog)
  31066. c.ServeSuccessJSON(map[string]interface{}{
  31067. "failed_code": -10,
  31068. "msg": res.ErrMsg,
  31069. })
  31070. return
  31071. }
  31072. }
  31073. }
  31074. }
  31075. // 退款
  31076. func (c *HisApiController) Refund() {
  31077. order_id, _ := c.GetInt64("order_id")
  31078. admin_user_id, _ := c.GetInt64("admin_user_id")
  31079. adminUser := c.GetAdminUserInfo()
  31080. var order models.HisOrder
  31081. order, _ = service.GetHisOrderByID(order_id)
  31082. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31083. if fapiao.ID > 0 {
  31084. c.ServeSuccessJSON(map[string]interface{}{
  31085. "failed_code": -10,
  31086. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31087. })
  31088. return
  31089. }
  31090. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31091. if order.ID == 0 {
  31092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31093. return
  31094. }
  31095. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31097. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31098. if config.IsOpen == 1 { //对接了医保,走医保流程
  31099. var res ResultSixteen
  31100. var ahres ResultSevenAH
  31101. var resSixteen10265 ResultSixteen10265
  31102. var resSixteen10265Two ResultSixteen10265Two
  31103. var gz ResultgzSixteen10265Two
  31104. var src_resquest string
  31105. var result string
  31106. if miConfig.MdtrtareaAdmvs == "421300" {
  31107. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31108. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31110. resp3, requestErr3 := http.Get(api3)
  31111. if requestErr3 != nil {
  31112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31113. return
  31114. }
  31115. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31116. if ioErr3 != nil {
  31117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31119. return
  31120. }
  31121. var respJSON3 map[string]interface{}
  31122. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31125. return
  31126. }
  31127. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31128. userJSONBytes3, _ := json.Marshal(respJSON3)
  31129. fmt.Println("log")
  31130. fmt.Println(string(userJSONBytes3))
  31131. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31132. utils.ErrorLog("解析失败:%v", err)
  31133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31134. return
  31135. }
  31136. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31137. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31138. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31139. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31140. resp3, requestErr3 := http.Get(api3)
  31141. if requestErr3 != nil {
  31142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31143. return
  31144. }
  31145. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31146. if ioErr3 != nil {
  31147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31149. return
  31150. }
  31151. var respJSON3 map[string]interface{}
  31152. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31155. return
  31156. }
  31157. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31158. userJSONBytes3, _ := json.Marshal(respJSON3)
  31159. fmt.Println("log")
  31160. fmt.Println(string(userJSONBytes3))
  31161. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31162. utils.ErrorLog("解析失败:%v", err)
  31163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31164. return
  31165. }
  31166. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31167. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31168. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31169. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31170. resp3, requestErr3 := http.Get(api3)
  31171. if requestErr3 != nil {
  31172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31173. return
  31174. }
  31175. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31176. if ioErr3 != nil {
  31177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31179. return
  31180. }
  31181. var respJSON3 map[string]interface{}
  31182. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31185. return
  31186. }
  31187. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31188. userJSONBytes3, _ := json.Marshal(respJSON3)
  31189. fmt.Println("log")
  31190. fmt.Println(string(userJSONBytes3))
  31191. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31192. utils.ErrorLog("解析失败:%v", err)
  31193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31194. return
  31195. }
  31196. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31197. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31198. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31199. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31200. resp3, requestErr3 := http.Get(api3)
  31201. if requestErr3 != nil {
  31202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31203. return
  31204. }
  31205. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31206. if ioErr3 != nil {
  31207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31209. return
  31210. }
  31211. var respJSON3 map[string]interface{}
  31212. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31215. return
  31216. }
  31217. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31218. userJSONBytes3, _ := json.Marshal(respJSON3)
  31219. fmt.Println("log")
  31220. fmt.Println(string(userJSONBytes3))
  31221. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31222. utils.ErrorLog("解析失败:%v", err)
  31223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31224. return
  31225. }
  31226. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31227. var api3 string
  31228. if miConfig.MdtrtareaAdmvs == "320921" {
  31229. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31230. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31231. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31232. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31233. } else {
  31234. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31235. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31236. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31237. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31238. }
  31239. resp3, requestErr3 := http.Get(api3)
  31240. if requestErr3 != nil {
  31241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31242. return
  31243. }
  31244. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31245. if ioErr3 != nil {
  31246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31248. return
  31249. }
  31250. var respJSON3 map[string]interface{}
  31251. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31254. return
  31255. }
  31256. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31257. userJSONBytes3, _ := json.Marshal(respJSON3)
  31258. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31259. utils.ErrorLog("解析失败:%v", err)
  31260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31261. return
  31262. }
  31263. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31264. res.Output = resSixteen10265.Output
  31265. res.ErrMsg = resSixteen10265.ErrMsg
  31266. res.Cainfo = resSixteen10265.Cainfo
  31267. res.WarnMsg = resSixteen10265.WarnMsg
  31268. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31269. res.Infcode = infocode
  31270. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31271. var api3 string
  31272. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31273. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31274. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31275. resp3, requestErr3 := http.Get(api3)
  31276. if requestErr3 != nil {
  31277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31278. return
  31279. }
  31280. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31281. if ioErr3 != nil {
  31282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31284. return
  31285. }
  31286. var respJSON3 map[string]interface{}
  31287. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31290. return
  31291. }
  31292. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31293. userJSONBytes3, _ := json.Marshal(respJSON3)
  31294. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31295. utils.ErrorLog("解析失败:%v", err)
  31296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31297. return
  31298. }
  31299. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31300. res.Output = resSixteen10265.Output
  31301. res.ErrMsg = resSixteen10265.ErrMsg
  31302. res.Cainfo = resSixteen10265.Cainfo
  31303. res.WarnMsg = resSixteen10265.WarnMsg
  31304. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31305. res.Infcode = infocode
  31306. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31307. 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)
  31308. var dat map[string]interface{}
  31309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31310. fmt.Println(dat)
  31311. } else {
  31312. fmt.Println(err)
  31313. }
  31314. saveLog(result, src_resquest, "2208", "退费")
  31315. userJSONBytes, _ := json.Marshal(dat)
  31316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31317. utils.ErrorLog("解析失败:%v", err)
  31318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31319. return
  31320. }
  31321. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31322. 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, "")
  31323. var dat map[string]interface{}
  31324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31325. fmt.Println(dat)
  31326. } else {
  31327. fmt.Println(err)
  31328. }
  31329. saveLog(result, src_resquest, "2208", "退费")
  31330. userJSONBytes, _ := json.Marshal(dat)
  31331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31332. utils.ErrorLog("解析失败:%v", err)
  31333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31334. return
  31335. }
  31336. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31337. 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, "")
  31338. var dat map[string]interface{}
  31339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31340. fmt.Println(dat)
  31341. } else {
  31342. fmt.Println(err)
  31343. }
  31344. saveLog(result, src_resquest, "2208", "退费")
  31345. userJSONBytes, _ := json.Marshal(dat)
  31346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31347. utils.ErrorLog("解析失败:%v", err)
  31348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31349. return
  31350. }
  31351. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31352. var api3 string
  31353. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31354. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31355. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31356. resp3, requestErr3 := http.Get(api3)
  31357. if requestErr3 != nil {
  31358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31359. return
  31360. }
  31361. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31362. if ioErr3 != nil {
  31363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31365. return
  31366. }
  31367. var respJSON3 map[string]interface{}
  31368. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31371. return
  31372. }
  31373. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31374. if status == "0" {
  31375. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31376. c.ServeSuccessJSON(map[string]interface{}{
  31377. "failed_code": -10,
  31378. "msg": err_msg,
  31379. })
  31380. return
  31381. }
  31382. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31383. userJSONBytes3, _ := json.Marshal(respJSON3)
  31384. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31385. // utils.ErrorLog("解析失败:%v", err)
  31386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31387. // return
  31388. //}
  31389. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31390. utils.ErrorLog("解析失败:%v", err)
  31391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31392. return
  31393. }
  31394. res.InfRefmsgid = ahres.InfRefmsgid
  31395. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31396. // 创建对应的Time类型
  31397. t := time.UnixMilli(timestamp)
  31398. // 格式化成指定的日期字符串
  31399. str := t.Format("2006-01-02 15:04:05")
  31400. res.Output.Setlinfo.SetlTime = str
  31401. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31402. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31403. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31404. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31405. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31406. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31407. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31408. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31409. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31410. //
  31411. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31412. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31413. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31414. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31415. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31416. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31417. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31418. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31419. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31420. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31421. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31422. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31423. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31424. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31425. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31426. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31427. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31428. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31429. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31430. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31431. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31432. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31433. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31434. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31435. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31436. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31437. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31438. //res.Output.Setldetail = ahres.Output.Setldetail
  31439. res.ErrMsg = ahres.ErrMsg
  31440. res.Cainfo = ahres.Cainfo
  31441. res.WarnMsg = ahres.WarnMsg
  31442. res.Infcode = ahres.Infcode
  31443. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31444. var api3 string
  31445. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31446. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31447. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31448. resp3, requestErr3 := http.Get(api3)
  31449. if requestErr3 != nil {
  31450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31451. return
  31452. }
  31453. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31454. if ioErr3 != nil {
  31455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31457. return
  31458. }
  31459. var respJSON3 map[string]interface{}
  31460. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31463. return
  31464. }
  31465. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31466. if status == "0" {
  31467. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31468. c.ServeSuccessJSON(map[string]interface{}{
  31469. "failed_code": -10,
  31470. "msg": err_msg,
  31471. })
  31472. return
  31473. }
  31474. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31475. userJSONBytes3, _ := json.Marshal(respJSON3)
  31476. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31477. // utils.ErrorLog("解析失败:%v", err)
  31478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31479. // return
  31480. //}
  31481. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31482. utils.ErrorLog("解析失败:%v", err)
  31483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31484. return
  31485. }
  31486. res.InfRefmsgid = ahres.InfRefmsgid
  31487. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31488. // 创建对应的Time类型
  31489. t := time.UnixMilli(timestamp)
  31490. // 格式化成指定的日期字符串
  31491. str := t.Format("2006-01-02 15:04:05")
  31492. res.Output.Setlinfo.SetlTime = str
  31493. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31494. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31495. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31496. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31497. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31498. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31499. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31500. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31501. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31502. //
  31503. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31504. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31505. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31506. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31507. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31508. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31509. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31510. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31511. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31512. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31513. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31514. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31515. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31516. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31517. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31518. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31519. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31520. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31521. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31522. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31523. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31524. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31525. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31526. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31527. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31528. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31529. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31530. //res.Output.Setldetail = ahres.Output.Setldetail
  31531. res.ErrMsg = ahres.ErrMsg
  31532. res.Cainfo = ahres.Cainfo
  31533. res.WarnMsg = ahres.WarnMsg
  31534. res.Infcode = ahres.Infcode
  31535. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31536. 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, "")
  31537. var dat map[string]interface{}
  31538. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31539. fmt.Println(dat)
  31540. } else {
  31541. fmt.Println(err)
  31542. }
  31543. saveLog(result, src_resquest, "2208", "退费")
  31544. userJSONBytes, _ := json.Marshal(dat)
  31545. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31546. utils.ErrorLog("解析失败:%v", err)
  31547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31548. return
  31549. }
  31550. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31551. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31552. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31554. resp3, requestErr3 := http.Get(api3)
  31555. if requestErr3 != nil {
  31556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31557. return
  31558. }
  31559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31560. if ioErr3 != nil {
  31561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31563. return
  31564. }
  31565. var respJSON3 map[string]interface{}
  31566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31569. return
  31570. }
  31571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31572. userJSONBytes3, _ := json.Marshal(respJSON3)
  31573. fmt.Println("log")
  31574. fmt.Println(string(userJSONBytes3))
  31575. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31576. utils.ErrorLog("解析失败:%v", err)
  31577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31578. return
  31579. }
  31580. } else {
  31581. if miConfig.Code == "H15049901371" {
  31582. 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)
  31583. var dat map[string]interface{}
  31584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31585. fmt.Println(dat)
  31586. } else {
  31587. fmt.Println(err)
  31588. }
  31589. saveLog(result, src_resquest, "2208", "退费")
  31590. if strings.Contains(result, "Post") {
  31591. res.Infcode = -1
  31592. res.ErrMsg = result
  31593. }
  31594. userJSONBytes, _ := json.Marshal(dat)
  31595. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31596. utils.ErrorLog("解析失败:%v", err)
  31597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31598. return
  31599. }
  31600. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31601. res.Output = resSixteen10265.Output
  31602. res.ErrMsg = resSixteen10265.ErrMsg
  31603. res.Cainfo = resSixteen10265.Cainfo
  31604. res.WarnMsg = resSixteen10265.WarnMsg
  31605. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31606. res.Infcode = infocode
  31607. } else {
  31608. 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)
  31609. var dat map[string]interface{}
  31610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31611. fmt.Println(dat)
  31612. } else {
  31613. fmt.Println(err)
  31614. }
  31615. saveLog(result, src_resquest, "2208", "退费")
  31616. userJSONBytes, _ := json.Marshal(dat)
  31617. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31618. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31619. utils.ErrorLog("解析失败:%v", err)
  31620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31621. return
  31622. }
  31623. res.Infcode = gz.Infcode
  31624. } else {
  31625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31626. utils.ErrorLog("解析失败:%v", err)
  31627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31628. return
  31629. }
  31630. }
  31631. if strings.Contains(result, "Post") {
  31632. res.Infcode = -1
  31633. res.ErrMsg = result
  31634. }
  31635. }
  31636. }
  31637. if res.Infcode == -1 {
  31638. c.ServeSuccessJSON(map[string]interface{}{
  31639. "failed_code": -10,
  31640. "msg": res.ErrMsg,
  31641. })
  31642. return
  31643. }
  31644. if res.Infcode != -1 {
  31645. var res2 ResultSix
  31646. var resSix10265 ResultSix10265
  31647. if miConfig.MdtrtareaAdmvs == "421300" {
  31648. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31649. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31650. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31651. resp3, requestErr3 := http.Get(api3)
  31652. if requestErr3 != nil {
  31653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31654. return
  31655. }
  31656. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31657. if ioErr3 != nil {
  31658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31660. return
  31661. }
  31662. var respJSON3 map[string]interface{}
  31663. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31666. return
  31667. }
  31668. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31669. userJSONBytes3, _ := json.Marshal(respJSON3)
  31670. fmt.Println("log")
  31671. fmt.Println(string(userJSONBytes3))
  31672. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31673. utils.ErrorLog("解析失败:%v", err)
  31674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31675. return
  31676. }
  31677. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31678. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31679. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31681. resp3, requestErr3 := http.Get(api3)
  31682. if requestErr3 != nil {
  31683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31684. return
  31685. }
  31686. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31687. if ioErr3 != nil {
  31688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31690. return
  31691. }
  31692. var respJSON3 map[string]interface{}
  31693. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31696. return
  31697. }
  31698. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31699. userJSONBytes3, _ := json.Marshal(respJSON3)
  31700. fmt.Println("log")
  31701. fmt.Println(string(userJSONBytes3))
  31702. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31703. utils.ErrorLog("解析失败:%v", err)
  31704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31705. return
  31706. }
  31707. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31708. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31709. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31710. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31711. resp3, requestErr3 := http.Get(api3)
  31712. if requestErr3 != nil {
  31713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31714. return
  31715. }
  31716. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31717. if ioErr3 != nil {
  31718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31720. return
  31721. }
  31722. var respJSON3 map[string]interface{}
  31723. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31726. return
  31727. }
  31728. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31729. userJSONBytes3, _ := json.Marshal(respJSON3)
  31730. fmt.Println("log")
  31731. fmt.Println(string(userJSONBytes3))
  31732. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31733. utils.ErrorLog("解析失败:%v", err)
  31734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31735. return
  31736. }
  31737. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31738. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31739. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31740. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31741. resp3, requestErr3 := http.Get(api3)
  31742. if requestErr3 != nil {
  31743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31744. return
  31745. }
  31746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31747. if ioErr3 != nil {
  31748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31750. return
  31751. }
  31752. var respJSON3 map[string]interface{}
  31753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31756. return
  31757. }
  31758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31759. userJSONBytes3, _ := json.Marshal(respJSON3)
  31760. fmt.Println("log")
  31761. fmt.Println(string(userJSONBytes3))
  31762. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31763. utils.ErrorLog("解析失败:%v", err)
  31764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31765. return
  31766. }
  31767. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31768. var api3 string
  31769. if miConfig.MdtrtareaAdmvs == "320921" {
  31770. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31771. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31772. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31773. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31774. } else {
  31775. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31776. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31777. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31779. }
  31780. resp3, requestErr3 := http.Get(api3)
  31781. if requestErr3 != nil {
  31782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31783. return
  31784. }
  31785. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31786. if ioErr3 != nil {
  31787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31789. return
  31790. }
  31791. var respJSON3 map[string]interface{}
  31792. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31795. return
  31796. }
  31797. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31798. userJSONBytes3, _ := json.Marshal(respJSON3)
  31799. fmt.Println("log")
  31800. fmt.Println(string(userJSONBytes3))
  31801. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31802. utils.ErrorLog("解析失败:%v", err)
  31803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31804. return
  31805. }
  31806. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31807. res2.Output = resSix10265.Output
  31808. res2.ErrMsg = resSix10265.ErrMsg
  31809. res2.Cainfo = resSix10265.Cainfo
  31810. res2.WarnMsg = resSix10265.WarnMsg
  31811. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31812. res2.Infcode = infocode
  31813. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31814. var api3 string
  31815. new_chrg_bchno := order.Number
  31816. if adminUser.CurrentOrgId == 10265 {
  31817. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31818. new_chrg_bchno = "0000"
  31819. }
  31820. }
  31821. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31822. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31823. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31824. resp3, requestErr3 := http.Get(api3)
  31825. if requestErr3 != nil {
  31826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31827. return
  31828. }
  31829. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31830. if ioErr3 != nil {
  31831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31833. return
  31834. }
  31835. var respJSON3 map[string]interface{}
  31836. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31839. return
  31840. }
  31841. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31842. userJSONBytes3, _ := json.Marshal(respJSON3)
  31843. fmt.Println("log")
  31844. fmt.Println(string(userJSONBytes3))
  31845. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31846. utils.ErrorLog("解析失败:%v", err)
  31847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31848. return
  31849. }
  31850. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31851. res2.Output = resSix10265.Output
  31852. res2.ErrMsg = resSix10265.ErrMsg
  31853. res2.Cainfo = resSix10265.Cainfo
  31854. res2.WarnMsg = resSix10265.WarnMsg
  31855. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31856. res2.Infcode = infocode
  31857. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31858. 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)
  31859. var dat map[string]interface{}
  31860. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31861. fmt.Println(dat)
  31862. } else {
  31863. fmt.Println(err)
  31864. }
  31865. saveLog(result2, src_request, "2205", "撤销明细")
  31866. userJSONBytes, _ := json.Marshal(dat)
  31867. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31868. utils.ErrorLog("解析失败:%v", err)
  31869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31870. return
  31871. }
  31872. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31873. 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, "")
  31874. var dat map[string]interface{}
  31875. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31876. fmt.Println(dat)
  31877. } else {
  31878. fmt.Println(err)
  31879. }
  31880. saveLog(result2, src_request, "2205", "撤销明细")
  31881. userJSONBytes, _ := json.Marshal(dat)
  31882. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31883. utils.ErrorLog("解析失败:%v", err)
  31884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31885. return
  31886. }
  31887. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31888. 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, "")
  31889. var dat map[string]interface{}
  31890. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31891. fmt.Println(dat)
  31892. } else {
  31893. fmt.Println(err)
  31894. }
  31895. saveLog(result2, src_request, "2205", "撤销明细")
  31896. userJSONBytes, _ := json.Marshal(dat)
  31897. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31898. utils.ErrorLog("解析失败:%v", err)
  31899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31900. return
  31901. }
  31902. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31903. var api3 string
  31904. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31905. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31906. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31907. resp3, requestErr3 := http.Get(api3)
  31908. if requestErr3 != nil {
  31909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31910. return
  31911. }
  31912. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31913. if ioErr3 != nil {
  31914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31916. return
  31917. }
  31918. var respJSON3 map[string]interface{}
  31919. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31922. return
  31923. }
  31924. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31925. if status == "0" {
  31926. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31927. c.ServeSuccessJSON(map[string]interface{}{
  31928. "failed_code": -10,
  31929. "msg": err_msg,
  31930. })
  31931. return
  31932. }
  31933. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31934. userJSONBytes3, _ := json.Marshal(respJSON3)
  31935. fmt.Println("log")
  31936. fmt.Println(string(userJSONBytes3))
  31937. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31938. utils.ErrorLog("解析失败:%v", err)
  31939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31940. return
  31941. }
  31942. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31943. 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, "")
  31944. var dat map[string]interface{}
  31945. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31946. fmt.Println(dat)
  31947. } else {
  31948. fmt.Println(err)
  31949. }
  31950. saveLog(result2, src_request, "2205", "撤销明细")
  31951. userJSONBytes, _ := json.Marshal(dat)
  31952. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31953. utils.ErrorLog("解析失败:%v", err)
  31954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31955. return
  31956. }
  31957. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31958. 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, "")
  31959. var dat map[string]interface{}
  31960. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31961. fmt.Println(dat)
  31962. } else {
  31963. fmt.Println(err)
  31964. }
  31965. saveLog(result2, src_request, "2205", "撤销明细")
  31966. userJSONBytes, _ := json.Marshal(dat)
  31967. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31968. utils.ErrorLog("解析失败:%v", err)
  31969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31970. return
  31971. }
  31972. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31973. var api3 string
  31974. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31975. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31976. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31977. resp3, requestErr3 := http.Get(api3)
  31978. if requestErr3 != nil {
  31979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31980. return
  31981. }
  31982. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31983. if ioErr3 != nil {
  31984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31986. return
  31987. }
  31988. var respJSON3 map[string]interface{}
  31989. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31992. return
  31993. }
  31994. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31995. if status == "0" {
  31996. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31997. c.ServeSuccessJSON(map[string]interface{}{
  31998. "failed_code": -10,
  31999. "msg": err_msg,
  32000. })
  32001. return
  32002. }
  32003. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32004. userJSONBytes3, _ := json.Marshal(respJSON3)
  32005. fmt.Println("log")
  32006. fmt.Println(string(userJSONBytes3))
  32007. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32008. utils.ErrorLog("解析失败:%v", err)
  32009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32010. return
  32011. }
  32012. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32013. 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, "")
  32014. var dat map[string]interface{}
  32015. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32016. fmt.Println(dat)
  32017. } else {
  32018. fmt.Println(err)
  32019. }
  32020. saveLog(result2, src_request, "2205", "撤销明细")
  32021. userJSONBytes, _ := json.Marshal(dat)
  32022. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32023. utils.ErrorLog("解析失败:%v", err)
  32024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32025. return
  32026. }
  32027. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32028. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32029. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32030. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32031. resp3, requestErr3 := http.Get(api3)
  32032. if requestErr3 != nil {
  32033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32034. return
  32035. }
  32036. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32037. if ioErr3 != nil {
  32038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32040. return
  32041. }
  32042. var respJSON3 map[string]interface{}
  32043. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32046. return
  32047. }
  32048. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32049. userJSONBytes3, _ := json.Marshal(respJSON3)
  32050. fmt.Println("log")
  32051. fmt.Println(string(userJSONBytes3))
  32052. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32053. utils.ErrorLog("解析失败:%v", err)
  32054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32055. return
  32056. }
  32057. } else {
  32058. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32059. res2.Infcode = 0
  32060. } else {
  32061. 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)
  32062. var dat map[string]interface{}
  32063. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32064. fmt.Println(dat)
  32065. } else {
  32066. fmt.Println(err)
  32067. }
  32068. saveLog(result2, src_request, "2205", "撤销明细")
  32069. userJSONBytes, _ := json.Marshal(dat)
  32070. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32071. utils.ErrorLog("解析失败:%v", err)
  32072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32073. return
  32074. }
  32075. }
  32076. }
  32077. if res2.Infcode == -1 {
  32078. c.ServeSuccessJSON(map[string]interface{}{
  32079. "failed_code": -10,
  32080. "msg": res2.ErrMsg,
  32081. })
  32082. return
  32083. }
  32084. if res2.Infcode == 0 {
  32085. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32086. if err == nil {
  32087. //当押金不为零时产生退费记录
  32088. if order.Decimal != 0 {
  32089. tmp := strconv.FormatInt(order.ID, 10)
  32090. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32091. if err != nil {
  32092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32093. return
  32094. }
  32095. }
  32096. c.ServeSuccessJSON(map[string]interface{}{
  32097. "msg": "退费成功",
  32098. })
  32099. } else {
  32100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32101. return
  32102. }
  32103. } else {
  32104. c.ServeSuccessJSON(map[string]interface{}{
  32105. "failed_code": -10,
  32106. "msg": res2.ErrMsg,
  32107. })
  32108. }
  32109. } else {
  32110. c.ServeSuccessJSON(map[string]interface{}{
  32111. "failed_code": -10,
  32112. "msg": res.ErrMsg,
  32113. })
  32114. }
  32115. }
  32116. }
  32117. func (c *HisApiController) RefundNumber() {
  32118. record_time := c.GetString("record_time")
  32119. //patient_id, _ := c.GetInt64("patient_id")
  32120. admin_user_id, _ := c.GetInt64("admin_user_id")
  32121. his_patient_id, _ := c.GetInt64("id")
  32122. timeLayout := "2006-01-02"
  32123. loc, _ := time.LoadLocation("Local")
  32124. adminUser := c.GetAdminUserInfo()
  32125. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32126. fmt.Println(err)
  32127. if err != nil {
  32128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32129. return
  32130. }
  32131. recordDateTime := theTime.Unix()
  32132. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32133. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32134. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32135. //order, _ := service.GetHisOrderByID(order_id)
  32136. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32137. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32138. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32139. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32140. if count > 0 {
  32141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32142. return
  32143. }
  32144. if config.IsOpen == 1 { //对接了医保,走医保流程
  32145. var res2 ResultSix
  32146. var res3 GZResultSix
  32147. var resSix10265 ResultSix10265
  32148. if miConfig.MdtrtareaAdmvs == "421300" {
  32149. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32150. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32151. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32152. resp3, requestErr3 := http.Get(api3)
  32153. if requestErr3 != nil {
  32154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32155. return
  32156. }
  32157. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32158. if ioErr3 != nil {
  32159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32161. return
  32162. }
  32163. var respJSON3 map[string]interface{}
  32164. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32167. return
  32168. }
  32169. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32170. userJSONBytes3, _ := json.Marshal(respJSON3)
  32171. fmt.Println("log")
  32172. fmt.Println(string(userJSONBytes3))
  32173. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32174. utils.ErrorLog("解析失败:%v", err)
  32175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32176. return
  32177. }
  32178. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32179. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32180. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32181. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32182. resp3, requestErr3 := http.Get(api3)
  32183. if requestErr3 != nil {
  32184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32185. return
  32186. }
  32187. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32188. if ioErr3 != nil {
  32189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32191. return
  32192. }
  32193. var respJSON3 map[string]interface{}
  32194. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32197. return
  32198. }
  32199. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32200. userJSONBytes3, _ := json.Marshal(respJSON3)
  32201. fmt.Println("log")
  32202. fmt.Println(string(userJSONBytes3))
  32203. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32204. utils.ErrorLog("解析失败:%v", err)
  32205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32206. return
  32207. }
  32208. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32209. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32210. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32211. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32212. resp3, requestErr3 := http.Get(api3)
  32213. if requestErr3 != nil {
  32214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32215. return
  32216. }
  32217. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32218. if ioErr3 != nil {
  32219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32221. return
  32222. }
  32223. var respJSON3 map[string]interface{}
  32224. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32227. return
  32228. }
  32229. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32230. userJSONBytes3, _ := json.Marshal(respJSON3)
  32231. fmt.Println("log")
  32232. fmt.Println(string(userJSONBytes3))
  32233. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32234. utils.ErrorLog("解析失败:%v", err)
  32235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32236. return
  32237. }
  32238. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32239. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32240. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32241. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32242. resp3, requestErr3 := http.Get(api3)
  32243. if requestErr3 != nil {
  32244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32245. return
  32246. }
  32247. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32248. if ioErr3 != nil {
  32249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32251. return
  32252. }
  32253. var respJSON3 map[string]interface{}
  32254. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32257. return
  32258. }
  32259. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32260. userJSONBytes3, _ := json.Marshal(respJSON3)
  32261. fmt.Println("log")
  32262. fmt.Println(string(userJSONBytes3))
  32263. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32264. utils.ErrorLog("解析失败:%v", err)
  32265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32266. return
  32267. }
  32268. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32269. var api3 string
  32270. if miConfig.MdtrtareaAdmvs == "320921" {
  32271. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32272. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32273. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32274. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32275. } else {
  32276. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32277. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32278. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32279. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32280. }
  32281. resp3, requestErr3 := http.Get(api3)
  32282. if requestErr3 != nil {
  32283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32284. return
  32285. }
  32286. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32287. if ioErr3 != nil {
  32288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32290. return
  32291. }
  32292. var respJSON3 map[string]interface{}
  32293. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32296. return
  32297. }
  32298. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32299. userJSONBytes3, _ := json.Marshal(respJSON3)
  32300. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32301. utils.ErrorLog("解析失败:%v", err)
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. return
  32304. }
  32305. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32306. res2.Output = resSix10265.Output
  32307. res2.ErrMsg = resSix10265.ErrMsg
  32308. res2.Cainfo = resSix10265.Cainfo
  32309. res2.WarnMsg = resSix10265.WarnMsg
  32310. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32311. res2.Infcode = infocode
  32312. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32313. var api3 string
  32314. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32315. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32316. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32317. resp3, requestErr3 := http.Get(api3)
  32318. if requestErr3 != nil {
  32319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32320. return
  32321. }
  32322. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32323. if ioErr3 != nil {
  32324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32326. return
  32327. }
  32328. var respJSON3 map[string]interface{}
  32329. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32332. return
  32333. }
  32334. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32335. userJSONBytes3, _ := json.Marshal(respJSON3)
  32336. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32337. utils.ErrorLog("解析失败:%v", err)
  32338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32339. return
  32340. }
  32341. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32342. res2.Output = resSix10265.Output
  32343. res2.ErrMsg = resSix10265.ErrMsg
  32344. res2.Cainfo = resSix10265.Cainfo
  32345. res2.WarnMsg = resSix10265.WarnMsg
  32346. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32347. res2.Infcode = infocode
  32348. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32349. 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)
  32350. var dat map[string]interface{}
  32351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32352. fmt.Println(dat)
  32353. } else {
  32354. fmt.Println(err)
  32355. }
  32356. saveLog(result, request, "2202", "退号")
  32357. userJSONBytes, _ := json.Marshal(dat)
  32358. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32359. utils.ErrorLog("解析失败:%v", err)
  32360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32361. return
  32362. }
  32363. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32364. 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, "")
  32365. var dat map[string]interface{}
  32366. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32367. fmt.Println(dat)
  32368. } else {
  32369. fmt.Println(err)
  32370. }
  32371. saveLog(result, request, "2202", "退号")
  32372. userJSONBytes, _ := json.Marshal(dat)
  32373. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32374. utils.ErrorLog("解析失败:%v", err)
  32375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32376. return
  32377. }
  32378. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32379. 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, "")
  32380. var dat map[string]interface{}
  32381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32382. fmt.Println(dat)
  32383. } else {
  32384. fmt.Println(err)
  32385. }
  32386. saveLog(result, request, "2202", "退号")
  32387. userJSONBytes, _ := json.Marshal(dat)
  32388. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32389. utils.ErrorLog("解析失败:%v", err)
  32390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32391. return
  32392. }
  32393. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32394. var api3 string
  32395. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32396. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32397. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32398. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32399. resp3, requestErr3 := http.Get(api3)
  32400. if requestErr3 != nil {
  32401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32402. return
  32403. }
  32404. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32405. if ioErr3 != nil {
  32406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32408. return
  32409. }
  32410. var respJSON3 map[string]interface{}
  32411. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32414. return
  32415. }
  32416. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32417. if status == "0" {
  32418. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32419. c.ServeSuccessJSON(map[string]interface{}{
  32420. "failed_code": -10,
  32421. "msg": err_msg,
  32422. })
  32423. return
  32424. }
  32425. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32426. userJSONBytes3, _ := json.Marshal(respJSON3)
  32427. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32428. utils.ErrorLog("解析失败:%v", err)
  32429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32430. return
  32431. }
  32432. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32433. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32434. var api3 string
  32435. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32436. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32437. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32438. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32439. resp3, requestErr3 := http.Get(api3)
  32440. if requestErr3 != nil {
  32441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32442. return
  32443. }
  32444. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32445. if ioErr3 != nil {
  32446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32448. return
  32449. }
  32450. var respJSON3 map[string]interface{}
  32451. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32454. return
  32455. }
  32456. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32457. if status == "0" {
  32458. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32459. c.ServeSuccessJSON(map[string]interface{}{
  32460. "failed_code": -10,
  32461. "msg": err_msg,
  32462. })
  32463. return
  32464. }
  32465. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32466. userJSONBytes3, _ := json.Marshal(respJSON3)
  32467. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32468. utils.ErrorLog("解析失败:%v", err)
  32469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32470. return
  32471. }
  32472. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32473. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32474. 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, "")
  32475. var dat map[string]interface{}
  32476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32477. fmt.Println(dat)
  32478. } else {
  32479. fmt.Println(err)
  32480. }
  32481. saveLog(result, request, "2202", "退号")
  32482. userJSONBytes, _ := json.Marshal(dat)
  32483. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32484. utils.ErrorLog("解析失败:%v", err)
  32485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32486. return
  32487. }
  32488. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32489. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32490. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32491. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32492. resp3, requestErr3 := http.Get(api3)
  32493. if requestErr3 != nil {
  32494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32495. return
  32496. }
  32497. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32498. if ioErr3 != nil {
  32499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32501. return
  32502. }
  32503. var respJSON3 map[string]interface{}
  32504. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32507. return
  32508. }
  32509. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32510. userJSONBytes3, _ := json.Marshal(respJSON3)
  32511. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32512. utils.ErrorLog("解析失败:%v", err)
  32513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32514. return
  32515. }
  32516. } else {
  32517. var api3 string
  32518. if miConfig.Code == "H15049901371" {
  32519. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32520. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32521. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32522. } else {
  32523. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32524. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32525. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32526. }
  32527. resp3, requestErr3 := http.Get(api3)
  32528. if requestErr3 != nil {
  32529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32530. return
  32531. }
  32532. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32533. if ioErr3 != nil {
  32534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32536. return
  32537. }
  32538. var respJSON3 map[string]interface{}
  32539. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32542. return
  32543. }
  32544. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32545. userJSONBytes3, _ := json.Marshal(respJSON3)
  32546. if miConfig.Code == "H15049901371" {
  32547. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32548. utils.ErrorLog("解析失败:%v", err)
  32549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32550. return
  32551. }
  32552. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32553. res2.Output = resSix10265.Output
  32554. res2.ErrMsg = resSix10265.ErrMsg
  32555. res2.Cainfo = resSix10265.Cainfo
  32556. res2.WarnMsg = resSix10265.WarnMsg
  32557. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32558. res2.Infcode = infocode
  32559. } else {
  32560. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32561. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32562. utils.ErrorLog("解析失败:%v", err)
  32563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32564. return
  32565. }
  32566. res2.Infcode = res3.Infcode
  32567. } else {
  32568. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32569. utils.ErrorLog("解析失败:%v", err)
  32570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32571. return
  32572. }
  32573. }
  32574. }
  32575. }
  32576. if res2.Infcode == -1 {
  32577. c.ServeSuccessJSON(map[string]interface{}{
  32578. "failed_code": -10,
  32579. "msg": res2.ErrMsg,
  32580. })
  32581. return
  32582. }
  32583. if res2.Infcode == 0 {
  32584. if err == nil {
  32585. c.ServeSuccessJSON(map[string]interface{}{
  32586. "msg": "退号成功",
  32587. })
  32588. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32589. } else {
  32590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32591. return
  32592. }
  32593. }
  32594. } else {
  32595. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32596. //if err == nil {
  32597. // c.ServeSuccessJSON(map[string]interface{}{
  32598. // "msg": "退费成功",
  32599. // })
  32600. //} else {
  32601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32602. // return
  32603. //}
  32604. }
  32605. }
  32606. func (c *HisApiController) RefundDetail() {
  32607. order_id, _ := c.GetInt64("order_id")
  32608. admin_user_id, _ := c.GetInt64("admin_user_id")
  32609. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32610. number := c.GetString("number")
  32611. record_time := c.GetString("record_time")
  32612. patient_id, _ := c.GetInt64("patient_id")
  32613. //med_type, _ := c.GetInt64("med_type")
  32614. timeLayout := "2006-01-02"
  32615. loc, _ := time.LoadLocation("Local")
  32616. adminUser := c.GetAdminUserInfo()
  32617. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32618. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32619. fmt.Println(err)
  32620. if err != nil {
  32621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32622. return
  32623. }
  32624. recordDateTime := theTime.Unix()
  32625. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32626. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32628. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32629. var order models.HisOrder
  32630. order, _ = service.GetHisOrderByID(order_id)
  32631. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32632. if config.IsOpen == 1 { //对接了医保,走医保流程
  32633. var res2 ResultSix
  32634. if miConfig.MdtrtareaAdmvs == "421300" {
  32635. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32636. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32638. resp3, requestErr3 := http.Get(api3)
  32639. if requestErr3 != nil {
  32640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32641. return
  32642. }
  32643. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32644. if ioErr3 != nil {
  32645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32647. return
  32648. }
  32649. var respJSON3 map[string]interface{}
  32650. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32653. return
  32654. }
  32655. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32656. userJSONBytes3, _ := json.Marshal(respJSON3)
  32657. fmt.Println("log")
  32658. fmt.Println(string(userJSONBytes3))
  32659. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32660. utils.ErrorLog("解析失败:%v", err)
  32661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32662. return
  32663. }
  32664. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32665. if err == nil {
  32666. c.ServeSuccessJSON(map[string]interface{}{
  32667. "msg": "撤销明细成功",
  32668. })
  32669. return
  32670. } else {
  32671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32672. return
  32673. }
  32674. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32675. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32676. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32677. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32678. resp3, requestErr3 := http.Get(api3)
  32679. if requestErr3 != nil {
  32680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32681. return
  32682. }
  32683. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32684. if ioErr3 != nil {
  32685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32687. return
  32688. }
  32689. var respJSON3 map[string]interface{}
  32690. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32693. return
  32694. }
  32695. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32696. userJSONBytes3, _ := json.Marshal(respJSON3)
  32697. fmt.Println("log")
  32698. fmt.Println(string(userJSONBytes3))
  32699. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32700. utils.ErrorLog("解析失败:%v", err)
  32701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32702. return
  32703. }
  32704. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32705. if err == nil {
  32706. c.ServeSuccessJSON(map[string]interface{}{
  32707. "msg": "撤销明细成功",
  32708. })
  32709. return
  32710. } else {
  32711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32712. return
  32713. }
  32714. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32715. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32716. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32717. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32718. resp3, requestErr3 := http.Get(api3)
  32719. if requestErr3 != nil {
  32720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32721. return
  32722. }
  32723. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32724. if ioErr3 != nil {
  32725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32727. return
  32728. }
  32729. var respJSON3 map[string]interface{}
  32730. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32733. return
  32734. }
  32735. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32736. userJSONBytes3, _ := json.Marshal(respJSON3)
  32737. fmt.Println("log")
  32738. fmt.Println(string(userJSONBytes3))
  32739. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32740. utils.ErrorLog("解析失败:%v", err)
  32741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32742. return
  32743. }
  32744. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32745. if err == nil {
  32746. c.ServeSuccessJSON(map[string]interface{}{
  32747. "msg": "撤销明细成功",
  32748. })
  32749. return
  32750. } else {
  32751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32752. return
  32753. }
  32754. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32755. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32756. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32757. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32758. resp3, requestErr3 := http.Get(api3)
  32759. if requestErr3 != nil {
  32760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32761. return
  32762. }
  32763. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32764. if ioErr3 != nil {
  32765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32767. return
  32768. }
  32769. var respJSON3 map[string]interface{}
  32770. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32773. return
  32774. }
  32775. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32776. userJSONBytes3, _ := json.Marshal(respJSON3)
  32777. fmt.Println("log")
  32778. fmt.Println(string(userJSONBytes3))
  32779. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32780. utils.ErrorLog("解析失败:%v", err)
  32781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32782. return
  32783. }
  32784. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32785. if err == nil {
  32786. c.ServeSuccessJSON(map[string]interface{}{
  32787. "msg": "撤销明细成功",
  32788. })
  32789. return
  32790. } else {
  32791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32792. return
  32793. }
  32794. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32795. var resSix10265 ResultSix10265
  32796. var api3 string
  32797. if miConfig.MdtrtareaAdmvs == "320921" {
  32798. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32799. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32801. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32802. } else {
  32803. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32804. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32805. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32806. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32807. }
  32808. resp3, requestErr3 := http.Get(api3)
  32809. utils.ErrorLog("接口: %v", requestErr3)
  32810. if requestErr3 != nil {
  32811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32812. return
  32813. }
  32814. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32815. if ioErr3 != nil {
  32816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32818. return
  32819. }
  32820. var respJSON3 map[string]interface{}
  32821. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32824. return
  32825. }
  32826. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32827. userJSONBytes3, _ := json.Marshal(respJSON3)
  32828. fmt.Println("log")
  32829. fmt.Println(string(userJSONBytes3))
  32830. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32831. utils.ErrorLog("解析失败:%v", err)
  32832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32833. return
  32834. }
  32835. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32836. res2.Output = resSix10265.Output
  32837. res2.ErrMsg = resSix10265.ErrMsg
  32838. res2.Cainfo = resSix10265.Cainfo
  32839. res2.WarnMsg = resSix10265.WarnMsg
  32840. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32841. res2.Infcode = infocode
  32842. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32843. if err == nil {
  32844. c.ServeSuccessJSON(map[string]interface{}{
  32845. "msg": "撤销明细成功",
  32846. })
  32847. return
  32848. } else {
  32849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32850. return
  32851. }
  32852. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32853. var api3 string
  32854. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32855. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32856. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32857. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32858. resp3, requestErr3 := http.Get(api3)
  32859. utils.ErrorLog("接口: %v", requestErr3)
  32860. if requestErr3 != nil {
  32861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32862. return
  32863. }
  32864. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32865. if ioErr3 != nil {
  32866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32868. return
  32869. }
  32870. var respJSON3 map[string]interface{}
  32871. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32874. return
  32875. }
  32876. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32877. if status == "0" {
  32878. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32879. c.ServeSuccessJSON(map[string]interface{}{
  32880. "failed_code": -10,
  32881. "msg": err_msg,
  32882. })
  32883. return
  32884. }
  32885. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32886. userJSONBytes3, _ := json.Marshal(respJSON3)
  32887. fmt.Println("log")
  32888. fmt.Println(string(userJSONBytes3))
  32889. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32890. utils.ErrorLog("解析失败:%v", err)
  32891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32892. return
  32893. }
  32894. fmt.Println(res2.Infcode)
  32895. if res2.Infcode == -1 {
  32896. c.ServeSuccessJSON(map[string]interface{}{
  32897. "failed_code": -10,
  32898. "msg": res2.ErrMsg,
  32899. })
  32900. return
  32901. }
  32902. if res2.Infcode == 0 {
  32903. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32904. if err == nil {
  32905. c.ServeSuccessJSON(map[string]interface{}{
  32906. "msg": "撤销明细成功",
  32907. })
  32908. return
  32909. } else {
  32910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32911. return
  32912. }
  32913. } else {
  32914. c.ServeSuccessJSON(map[string]interface{}{
  32915. "failed_code": -10,
  32916. "msg": res2.ErrMsg,
  32917. })
  32918. }
  32919. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32920. if err == nil {
  32921. c.ServeSuccessJSON(map[string]interface{}{
  32922. "msg": "撤销明细成功",
  32923. })
  32924. return
  32925. } else {
  32926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32927. return
  32928. }
  32929. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32930. var api3 string
  32931. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32932. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32934. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32935. resp3, requestErr3 := http.Get(api3)
  32936. utils.ErrorLog("接口: %v", requestErr3)
  32937. if requestErr3 != nil {
  32938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32939. return
  32940. }
  32941. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32942. if ioErr3 != nil {
  32943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32945. return
  32946. }
  32947. var respJSON3 map[string]interface{}
  32948. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32951. return
  32952. }
  32953. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32954. if status == "0" {
  32955. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32956. c.ServeSuccessJSON(map[string]interface{}{
  32957. "failed_code": -10,
  32958. "msg": err_msg,
  32959. })
  32960. return
  32961. }
  32962. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32963. userJSONBytes3, _ := json.Marshal(respJSON3)
  32964. fmt.Println("log")
  32965. fmt.Println(string(userJSONBytes3))
  32966. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32967. utils.ErrorLog("解析失败:%v", err)
  32968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32969. return
  32970. }
  32971. fmt.Println(res2.Infcode)
  32972. if res2.Infcode == -1 {
  32973. c.ServeSuccessJSON(map[string]interface{}{
  32974. "failed_code": -10,
  32975. "msg": res2.ErrMsg,
  32976. })
  32977. return
  32978. }
  32979. if res2.Infcode == 0 {
  32980. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32981. if err == nil {
  32982. c.ServeSuccessJSON(map[string]interface{}{
  32983. "msg": "撤销明细成功",
  32984. })
  32985. return
  32986. } else {
  32987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32988. return
  32989. }
  32990. } else {
  32991. c.ServeSuccessJSON(map[string]interface{}{
  32992. "failed_code": -10,
  32993. "msg": res2.ErrMsg,
  32994. })
  32995. }
  32996. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32997. if err == nil {
  32998. c.ServeSuccessJSON(map[string]interface{}{
  32999. "msg": "撤销明细成功",
  33000. })
  33001. return
  33002. } else {
  33003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33004. return
  33005. }
  33006. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33007. var resSix10265 ResultSix10265
  33008. new_chrg_bchno := order.Number
  33009. if adminUser.CurrentOrgId == 10265 {
  33010. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33011. new_chrg_bchno = "0000"
  33012. }
  33013. }
  33014. var api3 string
  33015. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33016. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33018. resp3, requestErr3 := http.Get(api3)
  33019. if requestErr3 != nil {
  33020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33021. return
  33022. }
  33023. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33024. if ioErr3 != nil {
  33025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33027. return
  33028. }
  33029. var respJSON3 map[string]interface{}
  33030. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33033. return
  33034. }
  33035. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33036. userJSONBytes3, _ := json.Marshal(respJSON3)
  33037. fmt.Println("log")
  33038. fmt.Println(string(userJSONBytes3))
  33039. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33040. utils.ErrorLog("解析失败:%v", err)
  33041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33042. return
  33043. }
  33044. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33045. res2.Output = resSix10265.Output
  33046. res2.ErrMsg = resSix10265.ErrMsg
  33047. res2.Cainfo = resSix10265.Cainfo
  33048. res2.WarnMsg = resSix10265.WarnMsg
  33049. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33050. res2.Infcode = infocode
  33051. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33052. if err == nil {
  33053. c.ServeSuccessJSON(map[string]interface{}{
  33054. "msg": "撤销明细成功",
  33055. })
  33056. return
  33057. } else {
  33058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33059. return
  33060. }
  33061. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33062. 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)
  33063. var dat map[string]interface{}
  33064. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33065. fmt.Println(dat)
  33066. } else {
  33067. fmt.Println(err)
  33068. }
  33069. saveLog(result2, src_request, "2205", "撤销明细")
  33070. userJSONBytes, _ := json.Marshal(dat)
  33071. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33072. utils.ErrorLog("解析失败:%v", err)
  33073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33074. return
  33075. }
  33076. if res2.Infcode == 0 {
  33077. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33078. if err == nil {
  33079. c.ServeSuccessJSON(map[string]interface{}{
  33080. "msg": "撤销明细成功",
  33081. })
  33082. return
  33083. } else {
  33084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33085. return
  33086. }
  33087. } else {
  33088. c.ServeSuccessJSON(map[string]interface{}{
  33089. "failed_code": -10,
  33090. "msg": res2.ErrMsg,
  33091. })
  33092. }
  33093. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33094. 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, "")
  33095. var dat map[string]interface{}
  33096. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33097. fmt.Println(dat)
  33098. } else {
  33099. fmt.Println(err)
  33100. }
  33101. saveLog(result2, src_request, "2205", "撤销明细")
  33102. userJSONBytes, _ := json.Marshal(dat)
  33103. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33104. utils.ErrorLog("解析失败:%v", err)
  33105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33106. return
  33107. }
  33108. if res2.Infcode == 0 {
  33109. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33110. if err == nil {
  33111. c.ServeSuccessJSON(map[string]interface{}{
  33112. "msg": "撤销明细成功",
  33113. })
  33114. return
  33115. } else {
  33116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33117. return
  33118. }
  33119. } else {
  33120. c.ServeSuccessJSON(map[string]interface{}{
  33121. "failed_code": -10,
  33122. "msg": res2.ErrMsg,
  33123. })
  33124. }
  33125. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33126. 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, "")
  33127. var dat map[string]interface{}
  33128. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33129. fmt.Println(dat)
  33130. } else {
  33131. fmt.Println(err)
  33132. }
  33133. saveLog(result2, src_request, "2205", "撤销明细")
  33134. userJSONBytes, _ := json.Marshal(dat)
  33135. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33136. utils.ErrorLog("解析失败:%v", err)
  33137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33138. return
  33139. }
  33140. if res2.Infcode == 0 {
  33141. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33142. if err == nil {
  33143. c.ServeSuccessJSON(map[string]interface{}{
  33144. "msg": "撤销明细成功",
  33145. })
  33146. return
  33147. } else {
  33148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33149. return
  33150. }
  33151. } else {
  33152. c.ServeSuccessJSON(map[string]interface{}{
  33153. "failed_code": -10,
  33154. "msg": res2.ErrMsg,
  33155. })
  33156. }
  33157. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33158. 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, "")
  33159. var dat map[string]interface{}
  33160. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33161. fmt.Println(dat)
  33162. } else {
  33163. fmt.Println(err)
  33164. }
  33165. saveLog(result2, src_request, "2205", "撤销明细")
  33166. userJSONBytes, _ := json.Marshal(dat)
  33167. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33168. utils.ErrorLog("解析失败:%v", err)
  33169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33170. return
  33171. }
  33172. if res2.Infcode == 0 {
  33173. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33174. if err == nil {
  33175. c.ServeSuccessJSON(map[string]interface{}{
  33176. "msg": "撤销明细成功",
  33177. })
  33178. return
  33179. } else {
  33180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33181. return
  33182. }
  33183. } else {
  33184. c.ServeSuccessJSON(map[string]interface{}{
  33185. "failed_code": -10,
  33186. "msg": res2.ErrMsg,
  33187. })
  33188. }
  33189. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33190. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33191. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33192. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33193. resp2, requestErr2 := http.Get(api2)
  33194. if requestErr2 != nil {
  33195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33196. return
  33197. }
  33198. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33199. if ioErr2 != nil {
  33200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33202. return
  33203. }
  33204. var respJSON2 map[string]interface{}
  33205. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33208. return
  33209. }
  33210. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33211. userJSONBytes3, _ := json.Marshal(respJSON2)
  33212. fmt.Println("log")
  33213. fmt.Println(string(userJSONBytes3))
  33214. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33215. utils.ErrorLog("解析失败:%v", err)
  33216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33217. return
  33218. }
  33219. if res2.Infcode == 0 {
  33220. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33221. if err == nil {
  33222. c.ServeSuccessJSON(map[string]interface{}{
  33223. "msg": "撤销明细成功",
  33224. })
  33225. return
  33226. } else {
  33227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33228. return
  33229. }
  33230. } else {
  33231. c.ServeSuccessJSON(map[string]interface{}{
  33232. "failed_code": -10,
  33233. "msg": res2.ErrMsg,
  33234. })
  33235. }
  33236. } else {
  33237. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33238. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33239. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33240. resp2, requestErr2 := http.Get(api2)
  33241. if requestErr2 != nil {
  33242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33243. return
  33244. }
  33245. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33246. if ioErr2 != nil {
  33247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33249. return
  33250. }
  33251. var respJSON2 map[string]interface{}
  33252. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33255. return
  33256. }
  33257. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33258. userJSONBytes3, _ := json.Marshal(respJSON2)
  33259. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33260. utils.ErrorLog("解析失败:%v", err)
  33261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33262. return
  33263. }
  33264. if res2.Infcode == -1 {
  33265. c.ServeSuccessJSON(map[string]interface{}{
  33266. "failed_code": -10,
  33267. "msg": res2.ErrMsg,
  33268. })
  33269. return
  33270. } else {
  33271. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33272. if err == nil {
  33273. c.ServeSuccessJSON(map[string]interface{}{
  33274. "msg": "撤销明细成功",
  33275. })
  33276. return
  33277. } else {
  33278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33279. return
  33280. }
  33281. }
  33282. }
  33283. } else {
  33284. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33285. if err == nil {
  33286. c.ServeSuccessJSON(map[string]interface{}{
  33287. "msg": "退费成功",
  33288. })
  33289. } else {
  33290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33291. return
  33292. }
  33293. }
  33294. }
  33295. // 对账
  33296. func (c *HisApiController) GetCheckAccount() {
  33297. start_time := c.GetString("start_time")
  33298. end_time := c.GetString("end_time")
  33299. insutype := c.GetString("insutype")
  33300. clr_type := c.GetString("clr_type")
  33301. clr_org := c.GetString("clr_optins")
  33302. admin_user_id, _ := c.GetInt64("admin_user_id")
  33303. adminUser := c.GetAdminUserInfo()
  33304. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33305. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33306. if len(clr_org) == 0 {
  33307. clr_org = miConfig.InsuplcAdmdvs
  33308. }
  33309. timeLayout := "2006-01-02"
  33310. loc, _ := time.LoadLocation("Local")
  33311. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33312. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33313. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33314. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33315. fixmedins_setl_cnt := int64(len(orders))
  33316. var medfee_sumamt float64
  33317. var acct_pay float64
  33318. var fund_pay_sumamt float64
  33319. for _, item := range orders {
  33320. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33321. acct_pay = acct_pay + item.AcctPay
  33322. if miConfig.MdtrtareaAdmvs == "361025" {
  33323. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  33324. } else {
  33325. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33326. }
  33327. }
  33328. var user_name string
  33329. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33330. if role.ID == 0 {
  33331. user_name = "xxx"
  33332. } else {
  33333. user_name = role.UserName
  33334. }
  33335. var res ResultEight
  33336. var res10188 ResultEightFor10188
  33337. if config.IsOpen == 1 {
  33338. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33339. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33340. "insutype=" + insutype +
  33341. "&clr_type=" + clr_type +
  33342. "&setl_optins=" + clr_org +
  33343. "&stmt_begndate=" + start_time +
  33344. "&stm_enddate=" + end_time +
  33345. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33346. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33347. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33348. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33349. "&fixmedins_code=" + miConfig.Code +
  33350. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33351. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33352. "&secret_key=" + miConfig.SecretKey +
  33353. "&org_name=" + miConfig.OrgName +
  33354. "&doctor=" + user_name +
  33355. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33356. fmt.Println(api)
  33357. resp, requestErr := http.Get(api)
  33358. if requestErr != nil {
  33359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33360. return
  33361. }
  33362. body, ioErr := ioutil.ReadAll(resp.Body)
  33363. fmt.Println(body)
  33364. if ioErr != nil {
  33365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33367. return
  33368. }
  33369. var respJSON map[string]interface{}
  33370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33373. return
  33374. }
  33375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33376. userJSONBytes, _ := json.Marshal(respJSON)
  33377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33378. utils.ErrorLog("解析失败:%v", err)
  33379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33380. return
  33381. }
  33382. res.InfRefmsgid = res10188.InfRefmsgid
  33383. res.Output = res10188.Output
  33384. res.ErrMsg = res10188.ErrMsg
  33385. res.Cainfo = res10188.Cainfo
  33386. res.WarnMsg = res10188.WarnMsg
  33387. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33388. res.Infcode = infocode
  33389. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33390. if clr_type != "9903" {
  33391. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33392. }
  33393. if clr_type == "9903" {
  33394. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33395. }
  33396. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33397. "insutype=" + insutype +
  33398. "&clr_type=" + clr_type +
  33399. "&setl_optins=" + clr_org +
  33400. "&stmt_begndate=" + start_time +
  33401. "&stm_enddate=" + end_time +
  33402. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33403. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33404. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33405. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33406. "&fixmedins_code=" + miConfig.Code +
  33407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33408. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33409. "&secret_key=" + miConfig.SecretKey +
  33410. "&org_name=" + miConfig.OrgName +
  33411. "&doctor=" + user_name
  33412. resp, requestErr := http.Get(api)
  33413. if requestErr != nil {
  33414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33415. return
  33416. }
  33417. body, ioErr := ioutil.ReadAll(resp.Body)
  33418. if ioErr != nil {
  33419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33421. return
  33422. }
  33423. var respJSON map[string]interface{}
  33424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33427. return
  33428. }
  33429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33430. result, _ := json.Marshal(respJSON)
  33431. fmt.Println("log")
  33432. fmt.Println(string(result))
  33433. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33434. utils.ErrorLog("解析失败:%v", err)
  33435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33436. return
  33437. }
  33438. res.InfRefmsgid = res10188.InfRefmsgid
  33439. res.Output = res10188.Output
  33440. res.ErrMsg = res10188.ErrMsg
  33441. res.Cainfo = res10188.Cainfo
  33442. res.WarnMsg = res10188.WarnMsg
  33443. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33444. res.Infcode = infocode
  33445. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33446. var baseParams models.BaseParams
  33447. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33448. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33449. baseParams.SecretKey = miConfig.SecretKey
  33450. baseParams.OrgName = miConfig.OrgName
  33451. baseParams.FixmedinsCode = miConfig.Code
  33452. baseParams.EncKey = miConfig.EncKey
  33453. baseParams.AppSecret = miConfig.AppSecret
  33454. baseParams.SignKey = miConfig.SignKey
  33455. baseParams.AppID = miConfig.Code
  33456. baseParams.Doctor = role.UserName
  33457. baseParams.RequestUrl = miConfig.Url
  33458. businessParams := models.BusinessParams{
  33459. Insutype: insutype,
  33460. ClrType: clr_type,
  33461. SetlOptins: clr_org,
  33462. StmtBegndate: start_time,
  33463. StmtEnddate: end_time,
  33464. MedfeeSumamt: medfee_sumamt,
  33465. FundPaySumamt: fund_pay_sumamt,
  33466. AcctPay: acct_pay,
  33467. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33468. }
  33469. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33470. fmt.Println(requestLog)
  33471. fmt.Println(result)
  33472. fmt.Println(err_msg)
  33473. var dat map[string]interface{}
  33474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33475. fmt.Println(dat)
  33476. } else {
  33477. fmt.Println(err)
  33478. }
  33479. userJSONBytes, _ := json.Marshal(dat)
  33480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33481. utils.ErrorLog("解析失败:%v", err)
  33482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33483. return
  33484. }
  33485. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33486. var baseParams models.BaseParams
  33487. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33488. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33489. baseParams.SecretKey = miConfig.SecretKey
  33490. baseParams.OrgName = miConfig.OrgName
  33491. baseParams.FixmedinsCode = miConfig.Code
  33492. baseParams.EncKey = miConfig.EncKey
  33493. baseParams.AppSecret = miConfig.AppSecret
  33494. baseParams.SignKey = miConfig.SignKey
  33495. baseParams.AppID = miConfig.Code
  33496. baseParams.Doctor = role.UserName
  33497. baseParams.RequestUrl = miConfig.Url
  33498. baseParams.AccessKey = miConfig.AccessKey
  33499. businessParams := models.BusinessParams{
  33500. Insutype: insutype,
  33501. ClrType: clr_type,
  33502. SetlOptins: "430822",
  33503. StmtBegndate: start_time,
  33504. StmtEnddate: end_time,
  33505. MedfeeSumamt: medfee_sumamt,
  33506. FundPaySumamt: fund_pay_sumamt,
  33507. AcctPay: acct_pay,
  33508. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33509. }
  33510. result, requestLog := 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)
  33511. fmt.Println(requestLog)
  33512. fmt.Println(result)
  33513. var dat map[string]interface{}
  33514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33515. fmt.Println(dat)
  33516. } else {
  33517. fmt.Println(err)
  33518. }
  33519. userJSONBytes, _ := json.Marshal(dat)
  33520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33521. utils.ErrorLog("解析失败:%v", err)
  33522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33523. return
  33524. }
  33525. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33526. var baseParams models.BaseParams
  33527. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33528. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33529. baseParams.SecretKey = miConfig.SecretKey
  33530. baseParams.OrgName = miConfig.OrgName
  33531. baseParams.FixmedinsCode = miConfig.Code
  33532. baseParams.EncKey = miConfig.EncKey
  33533. baseParams.AppSecret = miConfig.AppSecret
  33534. baseParams.SignKey = miConfig.SignKey
  33535. baseParams.AppID = miConfig.Code
  33536. baseParams.Doctor = role.UserName
  33537. baseParams.RequestUrl = miConfig.Url
  33538. businessParams := models.BusinessParams{
  33539. Insutype: insutype,
  33540. ClrType: clr_type,
  33541. SetlOptins: clr_org,
  33542. StmtBegndate: start_time,
  33543. StmtEnddate: end_time,
  33544. MedfeeSumamt: medfee_sumamt,
  33545. FundPaySumamt: fund_pay_sumamt,
  33546. AcctPay: acct_pay,
  33547. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33548. }
  33549. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33550. fmt.Println(requestLog)
  33551. fmt.Println(result)
  33552. fmt.Println(err_msg)
  33553. var dat map[string]interface{}
  33554. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33555. fmt.Println(dat)
  33556. } else {
  33557. fmt.Println(err)
  33558. }
  33559. userJSONBytes, _ := json.Marshal(dat)
  33560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33561. utils.ErrorLog("解析失败:%v", err)
  33562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33563. return
  33564. }
  33565. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33566. if len(clr_type) == 0 {
  33567. clr_type = "11"
  33568. }
  33569. api := miConfig.Url + "gdyb/ten?" +
  33570. "insutype=" + insutype +
  33571. "&clr_type=" + clr_type +
  33572. "&setl_optins=" + clr_org +
  33573. "&stmt_begndate=" + start_time +
  33574. "&stm_enddate=" + end_time +
  33575. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33576. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33577. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33578. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33579. "&fixmedins_code=" + miConfig.Code +
  33580. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33581. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33582. "&secret_key=" + miConfig.SecretKey +
  33583. "&org_name=" + miConfig.OrgName +
  33584. "&doctor=" + user_name
  33585. fmt.Println(api)
  33586. resp, requestErr := http.Get(api)
  33587. if requestErr != nil {
  33588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33589. return
  33590. }
  33591. body, ioErr := ioutil.ReadAll(resp.Body)
  33592. fmt.Println(body)
  33593. if ioErr != nil {
  33594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33596. return
  33597. }
  33598. var respJSON map[string]interface{}
  33599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33602. return
  33603. }
  33604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33605. userJSONBytes, _ := json.Marshal(respJSON)
  33606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33607. utils.ErrorLog("解析失败:%v", err)
  33608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33609. return
  33610. }
  33611. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33612. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33613. //fixmedins_setl_cnt := int64(len(orders_two))
  33614. //var medfee_sumamt float64
  33615. //var acct_pay float64
  33616. //var fund_pay_sumamt float64
  33617. //for _, item := range orders_two {
  33618. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33619. // acct_pay = acct_pay + item.AcctPay
  33620. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33621. //}
  33622. var baseParams models.BaseParams
  33623. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33624. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33625. baseParams.SecretKey = miConfig.SecretKey
  33626. baseParams.OrgName = miConfig.OrgName
  33627. baseParams.FixmedinsCode = miConfig.Code
  33628. baseParams.EncKey = miConfig.EncKey
  33629. baseParams.AppSecret = miConfig.AppSecret
  33630. baseParams.SignKey = miConfig.SignKey
  33631. baseParams.AppID = miConfig.Code
  33632. baseParams.Doctor = role.UserName
  33633. baseParams.RequestUrl = miConfig.Url
  33634. if clr_type == "9903" {
  33635. clr_type = "9994"
  33636. }
  33637. businessParams := models.BusinessParams{
  33638. Insutype: insutype,
  33639. ClrType: clr_type,
  33640. SetlOptins: "360302",
  33641. StmtBegndate: start_time,
  33642. StmtEnddate: end_time,
  33643. MedfeeSumamt: 0,
  33644. FundPaySumamt: 0,
  33645. AcctPay: 0,
  33646. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33647. }
  33648. 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))
  33649. fmt.Println(requestLog)
  33650. fmt.Println(result)
  33651. var dat map[string]interface{}
  33652. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33653. fmt.Println(dat)
  33654. } else {
  33655. fmt.Println(err)
  33656. }
  33657. userJSONBytes, _ := json.Marshal(dat)
  33658. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33659. utils.ErrorLog("解析失败:%v", err)
  33660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33661. return
  33662. }
  33663. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33664. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33665. //fixmedins_setl_cnt := int64(len(orders_two))
  33666. //var medfee_sumamt float64
  33667. //var acct_pay float64
  33668. //var fund_pay_sumamt float64
  33669. //for _, item := range orders_two {
  33670. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33671. // acct_pay = acct_pay + item.AcctPay
  33672. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33673. //}
  33674. var baseParams models.BaseParams
  33675. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33676. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33677. baseParams.SecretKey = miConfig.SecretKey
  33678. baseParams.OrgName = miConfig.OrgName
  33679. baseParams.FixmedinsCode = miConfig.Code
  33680. baseParams.EncKey = miConfig.EncKey
  33681. baseParams.AppSecret = miConfig.AppSecret
  33682. baseParams.SignKey = miConfig.SignKey
  33683. baseParams.AppID = miConfig.Code
  33684. baseParams.Doctor = role.UserName
  33685. baseParams.RequestUrl = miConfig.Url
  33686. if clr_type == "9903" {
  33687. clr_type = "9994"
  33688. }
  33689. businessParams := models.BusinessParams{
  33690. Insutype: insutype,
  33691. ClrType: clr_type,
  33692. SetlOptins: "361025",
  33693. StmtBegndate: start_time,
  33694. StmtEnddate: end_time,
  33695. MedfeeSumamt: 0,
  33696. FundPaySumamt: 0,
  33697. AcctPay: 0,
  33698. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33699. }
  33700. 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))
  33701. fmt.Println(requestLog)
  33702. fmt.Println(result)
  33703. var dat map[string]interface{}
  33704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33705. fmt.Println(dat)
  33706. } else {
  33707. fmt.Println(err)
  33708. }
  33709. userJSONBytes, _ := json.Marshal(dat)
  33710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33711. utils.ErrorLog("解析失败:%v", err)
  33712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33713. return
  33714. }
  33715. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33716. var api string
  33717. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33718. "&clr_type=" + clr_type +
  33719. "&setl_optins=" + clr_org +
  33720. "&stmt_begndate=" + start_time +
  33721. "&stm_enddate=" + end_time +
  33722. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33723. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33724. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33725. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33726. "&fixmedins_code=" + miConfig.Code +
  33727. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33728. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33729. "&secret_key=" + miConfig.SecretKey +
  33730. "&org_name=" + miConfig.OrgName +
  33731. "&doctor=" + user_name + "&url=" + miConfig.Url
  33732. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33733. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33734. resp, requestErr := http.Get(api)
  33735. if requestErr != nil {
  33736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33737. return
  33738. }
  33739. body, ioErr := ioutil.ReadAll(resp.Body)
  33740. if ioErr != nil {
  33741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33743. return
  33744. }
  33745. var respJSON map[string]interface{}
  33746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33749. return
  33750. }
  33751. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33752. if status == "0" {
  33753. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33754. c.ServeSuccessJSON(map[string]interface{}{
  33755. "failed_code": -10,
  33756. "msg": err_msg,
  33757. })
  33758. return
  33759. }
  33760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33761. userJSONBytes, _ := json.Marshal(respJSON)
  33762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33763. utils.ErrorLog("解析失败:%v", err)
  33764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33765. return
  33766. }
  33767. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33768. var api string
  33769. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33770. "&clr_type=" + clr_type +
  33771. "&setl_optins=" + clr_org +
  33772. "&stmt_begndate=" + start_time +
  33773. "&stm_enddate=" + end_time +
  33774. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33775. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33776. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33777. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33778. "&fixmedins_code=" + miConfig.Code +
  33779. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33780. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33781. "&secret_key=" + miConfig.SecretKey +
  33782. "&org_name=" + miConfig.OrgName +
  33783. "&doctor=" + user_name + "&url=" + miConfig.Url
  33784. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33785. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33786. resp, requestErr := http.Get(api)
  33787. if requestErr != nil {
  33788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33789. return
  33790. }
  33791. body, ioErr := ioutil.ReadAll(resp.Body)
  33792. if ioErr != nil {
  33793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33795. return
  33796. }
  33797. var respJSON map[string]interface{}
  33798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33801. return
  33802. }
  33803. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33804. if status == "0" {
  33805. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33806. c.ServeSuccessJSON(map[string]interface{}{
  33807. "failed_code": -10,
  33808. "msg": err_msg,
  33809. })
  33810. return
  33811. }
  33812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33813. userJSONBytes, _ := json.Marshal(respJSON)
  33814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33815. utils.ErrorLog("解析失败:%v", err)
  33816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33817. return
  33818. }
  33819. } else {
  33820. if len(clr_type) == 0 {
  33821. clr_type = "11"
  33822. }
  33823. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33824. "insutype=" + insutype +
  33825. "&clr_type=" + clr_type +
  33826. "&setl_optins=" + clr_org +
  33827. "&stmt_begndate=" + start_time +
  33828. "&stm_enddate=" + end_time +
  33829. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33830. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33831. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33832. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33833. "&fixmedins_code=" + miConfig.Code +
  33834. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33835. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33836. "&secret_key=" + miConfig.SecretKey +
  33837. "&org_name=" + miConfig.OrgName +
  33838. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33839. fmt.Println(api)
  33840. resp, requestErr := http.Get(api)
  33841. if requestErr != nil {
  33842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33843. return
  33844. }
  33845. body, ioErr := ioutil.ReadAll(resp.Body)
  33846. fmt.Println(body)
  33847. if ioErr != nil {
  33848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. return
  33851. }
  33852. var respJSON map[string]interface{}
  33853. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33856. return
  33857. }
  33858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33859. userJSONBytes, _ := json.Marshal(respJSON)
  33860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33861. utils.ErrorLog("解析失败:%v", err)
  33862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33863. return
  33864. }
  33865. }
  33866. if res.Infcode == 0 {
  33867. if res.Output.Stmtinfo.StmtRslt == "0" {
  33868. micc := &models.MedicalInsuranceCostCompare{
  33869. StartTime: startime.Unix(),
  33870. EndTime: endtime.Unix(),
  33871. Insutype: insutype,
  33872. CheckType: 1,
  33873. Num: fixmedins_setl_cnt,
  33874. Mtime: time.Now().Unix(),
  33875. Status: 1,
  33876. UserOrgId: adminUser.CurrentOrgId,
  33877. CostTotal: medfee_sumamt,
  33878. FuncTotal: fund_pay_sumamt,
  33879. PsnPay: acct_pay,
  33880. Creator: admin_user_id,
  33881. Ctime: time.Now().Unix(),
  33882. ClrType: clr_type,
  33883. }
  33884. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33885. if err == nil {
  33886. c.ServeSuccessJSON(map[string]interface{}{
  33887. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33888. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33889. })
  33890. } else {
  33891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33892. }
  33893. } else {
  33894. c.ServeSuccessJSON(map[string]interface{}{
  33895. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33896. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33897. })
  33898. }
  33899. } else {
  33900. c.ServeSuccessJSON(map[string]interface{}{
  33901. "failed_code": -10,
  33902. "msg": res.ErrMsg,
  33903. })
  33904. }
  33905. }
  33906. }
  33907. func (c *HisApiController) Check310() {
  33908. adminUser := c.GetAdminUserInfo()
  33909. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33910. var user_name string
  33911. user_name = "高慧裕"
  33912. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33913. "insutype=" + "310" +
  33914. "&clr_type=" + "" +
  33915. "&setl_optins=" + "441202" +
  33916. "&stmt_begndate=" + "2022-03-01" +
  33917. "&stm_enddate=" + "2022-03-31" +
  33918. "&medfee_sumamt=" + "194930.12" +
  33919. "&fund_pay_sumamt=" + "188741.46" +
  33920. "&acct_pay=" + "0" +
  33921. "&fixmedins_setl_cnt=" + "452" +
  33922. "&fixmedins_code=" + miConfig.Code +
  33923. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33924. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33925. "&secret_key=" + miConfig.SecretKey +
  33926. "&org_name=" + miConfig.OrgName +
  33927. "&doctor=" + user_name
  33928. fmt.Println(api)
  33929. resp, requestErr := http.Get(api)
  33930. if requestErr != nil {
  33931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33932. return
  33933. }
  33934. body, ioErr := ioutil.ReadAll(resp.Body)
  33935. fmt.Println(body)
  33936. if ioErr != nil {
  33937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33939. return
  33940. }
  33941. var respJSON map[string]interface{}
  33942. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33945. return
  33946. }
  33947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33948. userJSONBytes, _ := json.Marshal(respJSON)
  33949. var res ResultEight
  33950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33951. utils.ErrorLog("解析失败:%v", err)
  33952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33953. return
  33954. }
  33955. }
  33956. func (c *HisApiController) Check390() {
  33957. adminUser := c.GetAdminUserInfo()
  33958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33959. var user_name string
  33960. user_name = "高慧裕"
  33961. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33962. "insutype=" + "390" +
  33963. "&clr_type=" + "" +
  33964. "&setl_optins=" + "441202" +
  33965. "&stmt_begndate=" + "2022-03-01" +
  33966. "&stm_enddate=" + "2022-03-31" +
  33967. "&medfee_sumamt=" + "1068448.89" +
  33968. "&fund_pay_sumamt=" + "1014677.62" +
  33969. "&acct_pay=" + "0" +
  33970. "&fixmedins_setl_cnt=" + "1950" +
  33971. "&fixmedins_code=" + miConfig.Code +
  33972. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33973. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33974. "&secret_key=" + miConfig.SecretKey +
  33975. "&org_name=" + miConfig.OrgName +
  33976. "&doctor=" + user_name
  33977. fmt.Println(api)
  33978. resp, requestErr := http.Get(api)
  33979. if requestErr != nil {
  33980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33981. return
  33982. }
  33983. body, ioErr := ioutil.ReadAll(resp.Body)
  33984. fmt.Println(body)
  33985. if ioErr != nil {
  33986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33988. return
  33989. }
  33990. var respJSON map[string]interface{}
  33991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33994. return
  33995. }
  33996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33997. userJSONBytes, _ := json.Marshal(respJSON)
  33998. var res ResultEight
  33999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34000. utils.ErrorLog("解析失败:%v", err)
  34001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34002. return
  34003. }
  34004. }
  34005. // 对账明细
  34006. func (c *HisApiController) GetCheckDetailAccount() {
  34007. start_time := c.GetString("start_time")
  34008. end_time := c.GetString("end_time")
  34009. admin_user_id, _ := c.GetInt64("admin_user_id")
  34010. adminUser := c.GetAdminUserInfo()
  34011. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34012. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34013. timeLayout := "2006-01-02"
  34014. loc, _ := time.LoadLocation("Local")
  34015. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34016. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34017. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34018. rand.Seed(time.Now().UnixNano())
  34019. num := rand.Intn(30000)
  34020. Mkdir(miConfig.OrgName)
  34021. file := strconv.FormatInt(int64(num), 10)
  34022. file_name := file + ".txt"
  34023. zip_name := file + ".zip"
  34024. zip_path := miConfig.OrgName + "/" + zip_name
  34025. file_path := miConfig.OrgName + "/" + file_name
  34026. decimal.DivisionPrecision = 2
  34027. var medfee_sumamt float64
  34028. var psn_cash_pay float64
  34029. var fund_pay_sumamt float64
  34030. fixmedins_setl_cnt := int64(len(orders))
  34031. for _, item := range orders {
  34032. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34033. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34034. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34035. }
  34036. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34037. defer f.Close()
  34038. if err != nil {
  34039. fmt.Println(err.Error())
  34040. } else {
  34041. for _, item := range orders {
  34042. var refd_setl_flag string
  34043. if item.OrderStatus == 2 {
  34044. refd_setl_flag = "0"
  34045. var str string
  34046. str = item.SetlId + " " +
  34047. item.MdtrtId + " " +
  34048. item.PsnNo + " " +
  34049. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34050. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34051. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34052. _, err = f.Write([]byte(str))
  34053. }
  34054. if item.OrderStatus == 3 {
  34055. var str string
  34056. str = item.SetlId + " " +
  34057. item.MdtrtId + " " +
  34058. item.PsnNo + " " +
  34059. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34060. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34061. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34062. _, err = f.Write([]byte(str))
  34063. var str2 string
  34064. str2 = item.SetlId + " " +
  34065. item.MdtrtId + " " +
  34066. item.PsnNo + " " +
  34067. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34068. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34069. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34070. _, err = f.Write([]byte(str2))
  34071. }
  34072. }
  34073. }
  34074. Zip(file_path, zip_path)
  34075. fmt.Println(ReadFile(zip_path))
  34076. fmt.Println(string(ReadFile(zip_path)))
  34077. if config.IsOpen == 1 {
  34078. var user_name string
  34079. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34080. if role.ID == 0 {
  34081. user_name = "管理员"
  34082. } else {
  34083. user_name = role.UserName
  34084. }
  34085. baseParams := models.BaseParams{
  34086. SecretKey: miConfig.SecretKey,
  34087. FixmedinsCode: miConfig.Code,
  34088. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34089. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34090. OrgName: miConfig.OrgName,
  34091. Doctor: user_name,
  34092. }
  34093. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34094. var dat map[string]interface{}
  34095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34096. fmt.Println(dat)
  34097. } else {
  34098. fmt.Println(err)
  34099. }
  34100. userJSONBytes, _ := json.Marshal(dat)
  34101. var res ResultNine
  34102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34103. utils.ErrorLog("解析失败:%v", err)
  34104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34105. return
  34106. }
  34107. if res.Infcode == 0 {
  34108. fileNo := res.Output.FileQuryNo
  34109. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34110. "file_qury_no=" + fileNo +
  34111. "&setl_optins=" + "定点医保中心" +
  34112. "&stmt_begndate=" + start_time +
  34113. "&stm_enddate=" + end_time +
  34114. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34115. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34116. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34117. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34118. "&fixmedins_code=" + miConfig.Code +
  34119. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34120. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34121. "&secret_key=" + miConfig.SecretKey +
  34122. "&org_name=" + miConfig.OrgName +
  34123. "&doctor=" + user_name
  34124. resp, requestErr := http.Get(api)
  34125. if requestErr != nil {
  34126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34127. return
  34128. }
  34129. body, ioErr := ioutil.ReadAll(resp.Body)
  34130. if ioErr != nil {
  34131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34133. return
  34134. }
  34135. var respJSON map[string]interface{}
  34136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34139. return
  34140. }
  34141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34142. userJSONBytes, _ := json.Marshal(respJSON)
  34143. var res ResultTen
  34144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34145. utils.ErrorLog("解析失败:%v", err)
  34146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34147. return
  34148. }
  34149. if res.Infcode == 0 {
  34150. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34151. micc := &models.MedicalInsuranceCostCompare{
  34152. StartTime: startime.Unix(),
  34153. EndTime: endtime.Unix(),
  34154. Insutype: "0",
  34155. CheckType: 2,
  34156. Num: fixmedins_setl_cnt,
  34157. Mtime: time.Now().Unix(),
  34158. Status: 1,
  34159. UserOrgId: adminUser.CurrentOrgId,
  34160. CostTotal: medfee_sumamt,
  34161. FuncTotal: fund_pay_sumamt,
  34162. PsnPay: psn_cash_pay,
  34163. Creator: admin_user_id,
  34164. Ctime: time.Now().Unix(),
  34165. }
  34166. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34167. c.ServeSuccessJSON(map[string]interface{}{
  34168. "msg": "明细对账成功",
  34169. })
  34170. }
  34171. } else {
  34172. }
  34173. }
  34174. }
  34175. type CustomOrderInfo struct {
  34176. Name string
  34177. Spec string
  34178. Unit string
  34179. Count float64
  34180. Price float64
  34181. Total float64
  34182. }
  34183. func (c *HisApiController) GetBatchSettleAccounts() {
  34184. admin_user_id, _ := c.GetInt64("admin_user_id")
  34185. order_ids := c.GetString("order_ids")
  34186. order_ids_arr := strings.Split(order_ids, ",")
  34187. data3 := []map[string]interface{}{}
  34188. for _, item := range order_ids_arr {
  34189. id, _ := strconv.ParseInt(item, 10, 64)
  34190. order_id := id
  34191. adminUser := c.GetAdminUserInfo()
  34192. order, _ := service.GetHisOrderByID(order_id)
  34193. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34194. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34195. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34196. orderInfos = append(orderInfos, orderInfos_two...)
  34197. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34198. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34199. var diagnosis_ids []string
  34200. if his.ID > 0 {
  34201. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34202. } else {
  34203. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34204. }
  34205. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34206. var dia_config []*models.HisXtDiagnoseConfig
  34207. var name string
  34208. for _, item := range diagnosis_ids {
  34209. id, _ := strconv.ParseInt(item, 10, 64)
  34210. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34211. dia_config = append(dia_config, &diagnosisConfig)
  34212. if len(name) == 0 {
  34213. name = diagnosisConfig.ClassName
  34214. }
  34215. //} else {
  34216. // name = name + "," + diagnosisConfig.ClassName
  34217. //}
  34218. }
  34219. var bedCostTotal float64 = 0 //床位总费
  34220. var bedCostSelfTotal float64 = 0 //床位自费
  34221. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34222. var bedSelfTotal float64 = 0 //床位部分项目自费
  34223. var bedInscpTotal float64 = 0 //床位部分项目自费
  34224. var operationCostTotal float64 = 0 //手术费
  34225. var operationCostSelfTotal float64 = 0 //手术费
  34226. var operationCostPartSelfTotal float64 = 0 //手术费
  34227. var operationSelfTotal float64 = 0 //床位部分项目自费
  34228. var operationInscpTotal float64 = 0 //床位部分项目自费
  34229. var otherCostTotal float64 = 0 //其他费用
  34230. var otherCostSelfTotal float64 = 0 //其他费用
  34231. var otherCostPartSelfTotal float64 = 0 //其他费用
  34232. var otherSelfTotal float64 = 0 //床位部分项目自费
  34233. var otherInscpTotal float64 = 0 //床位部分项目自费
  34234. var materialCostTotal float64 = 0 //材料费
  34235. var materialCostSelfTotal float64 = 0 //材料费
  34236. var materialCostPartSelfTotal float64 = 0 //材料费
  34237. var materialSelfTotal float64 = 0 //床位部分项目自费
  34238. var materialInscpTotal float64 = 0 //床位部分项目自费
  34239. var westernMedicineCostTotal float64 = 0 //西药费
  34240. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34241. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34242. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34243. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34244. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34245. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34246. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34247. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34248. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34249. var checkCostTotal float64 = 0 //检查费
  34250. var checkCostSelfTotal float64 = 0 //检查费
  34251. var checkCostPartSelfTotal float64 = 0 //检查费
  34252. var checkSelfTotal float64 = 0 //床位部分项目自费
  34253. var checkInscpTotal float64 = 0 //床位部分项目自费
  34254. var laboratoryCostTotal float64 = 0 //化验费
  34255. var laboratoryCostSelfTotal float64 = 0 //化验费
  34256. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34257. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34258. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34259. var treatCostTotal float64 = 0 //治疗费用
  34260. var treatCostSelfTotal float64 = 0 //治疗费用
  34261. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34262. var treatSelfTotal float64 = 0 //床位部分项目自费
  34263. var treatInscpTotal float64 = 0 //床位部分项目自费
  34264. decimal.DivisionPrecision = 2
  34265. for _, item := range orderInfos {
  34266. if item.MedChrgitmType == "01" { //床位费
  34267. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34268. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34269. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34270. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34271. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34272. }
  34273. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34274. if item.MedChrgitmType == "03" { //检查费
  34275. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34276. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34277. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34278. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34279. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34280. }
  34281. } else {
  34282. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34283. fmt.Println("------------")
  34284. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34285. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34286. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34287. }
  34288. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34289. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34290. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34291. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34292. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34293. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34294. }
  34295. }
  34296. if item.MedChrgitmType == "04" { //化验费
  34297. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34298. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34299. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34300. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34301. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34302. }
  34303. if item.MedChrgitmType == "05" { //治疗费
  34304. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34305. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34306. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34307. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34308. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34309. }
  34310. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34311. fmt.Println("------------")
  34312. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34313. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34314. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34315. }
  34316. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34317. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34318. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34319. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34320. }
  34321. //if item.MedChrgitmType == "06" { //手术费
  34322. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34323. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34324. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34325. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34326. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34327. //
  34328. //}
  34329. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34330. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34331. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34332. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34333. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34334. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34335. }
  34336. if item.MedChrgitmType == "09" { //西药费
  34337. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34338. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34339. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34340. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34341. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34342. }
  34343. if item.MedChrgitmType == "11" { //中成费
  34344. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34345. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34346. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34347. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34348. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34349. }
  34350. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34351. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34352. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34353. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34354. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34355. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34356. }
  34357. }
  34358. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34359. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34360. var user_name string
  34361. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34362. if role.ID == 0 {
  34363. user_name = "管理员"
  34364. } else {
  34365. user_name = role.UserName
  34366. }
  34367. baseParams := models.BaseParams{
  34368. SecretKey: miConfig.SecretKey,
  34369. FixmedinsCode: miConfig.Code,
  34370. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34371. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34372. OrgName: miConfig.OrgName,
  34373. Doctor: user_name,
  34374. RequestUrl: miConfig.Url,
  34375. AccessKey: miConfig.AccessKey,
  34376. }
  34377. businessParams := models.BusinessParams{
  34378. PsnNo: order.PsnNo,
  34379. MdtrtId: order.MdtrtId,
  34380. SetlId: order.SetlId,
  34381. }
  34382. var res ResultEleven
  34383. var resEleven10265 ResultEleven10265
  34384. if config.IsOpen == 1 {
  34385. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34386. result := service.Gdyb5203(baseParams, businessParams)
  34387. service.Gdyb5204(baseParams, businessParams)
  34388. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34389. var dat map[string]interface{}
  34390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34391. fmt.Println(dat)
  34392. } else {
  34393. fmt.Println(err)
  34394. }
  34395. userJSONBytes, _ := json.Marshal(dat)
  34396. if miConfig.Code == "H15049901371" {
  34397. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34398. utils.ErrorLog("解析失败:%v", err)
  34399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34400. return
  34401. }
  34402. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34403. res.Output = resEleven10265.Output
  34404. res.ErrMsg = resEleven10265.ErrMsg
  34405. res.Cainfo = resEleven10265.Cainfo
  34406. res.WarnMsg = resEleven10265.WarnMsg
  34407. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34408. res.Infcode = infocode
  34409. } else {
  34410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34411. utils.ErrorLog("解析失败:%v", err)
  34412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34413. return
  34414. }
  34415. }
  34416. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34417. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34418. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34419. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34420. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34421. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34422. var doctor_name string
  34423. if roles.ID == 0 {
  34424. doctor_name = "管理员"
  34425. } else {
  34426. doctor_name = roles.UserName
  34427. }
  34428. yiliao_leibie := ""
  34429. switch order.MedType {
  34430. case "11":
  34431. yiliao_leibie = "普通门诊"
  34432. break
  34433. case "12":
  34434. yiliao_leibie = "门诊挂号"
  34435. break
  34436. case "13":
  34437. yiliao_leibie = "急诊"
  34438. break
  34439. case "14":
  34440. yiliao_leibie = "门诊特殊病"
  34441. break
  34442. case "15":
  34443. yiliao_leibie = "门诊统筹"
  34444. break
  34445. case "16":
  34446. yiliao_leibie = "门诊慢性病"
  34447. break
  34448. case "21":
  34449. yiliao_leibie = "普通住院"
  34450. break
  34451. }
  34452. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34453. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34454. if res.Infcode == 0 {
  34455. data2 := map[string]interface{}{
  34456. "diagnosis": name,
  34457. "order_infos": orderInfos,
  34458. "number": order.MdtrtId,
  34459. "date": order.SettleAccountsDate,
  34460. "charge_admin": charge_admin,
  34461. "printor_admin": printor_admin,
  34462. "info": res.Output.Setlinfo,
  34463. "order": order,
  34464. "bedCostTotal": bedCostTotal,
  34465. "bedCostSelfTotal": bedCostSelfTotal,
  34466. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34467. "bedSelfTotal": bedSelfTotal,
  34468. "bedInscpTotal": bedInscpTotal,
  34469. "operationCostTotal": operationCostTotal,
  34470. "operationCostSelfTotal": operationCostSelfTotal,
  34471. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34472. "operationSelfTotal": operationSelfTotal,
  34473. "operationInscpTotal": operationInscpTotal,
  34474. "otherCostTotal": otherCostTotal,
  34475. "otherCostSelfTotal": otherCostSelfTotal,
  34476. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34477. "otherSelfTotal": otherSelfTotal,
  34478. "otherInscpTotal": otherInscpTotal,
  34479. "materialCostTotal": materialCostTotal,
  34480. "materialCostSelfTotal": materialCostSelfTotal,
  34481. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34482. "materialSelfTotal": materialSelfTotal,
  34483. "materialInscpTotal": materialInscpTotal,
  34484. "westernMedicineCostTotal": westernMedicineCostTotal,
  34485. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34486. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34487. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34488. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34489. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34490. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34491. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34492. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34493. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34494. "checkCostTotal": checkCostTotal,
  34495. "checkCostSelfTotal": checkCostSelfTotal,
  34496. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34497. "checkSelfTotal": checkSelfTotal,
  34498. "checkInscpTotal": checkInscpTotal,
  34499. "laboratoryCostTotal": laboratoryCostTotal,
  34500. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34501. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34502. "laboratorySelfTotal": laboratorySelfTotal,
  34503. "laboratoryInscpTotal": laboratoryInscpTotal,
  34504. "treatCostTotal": treatCostTotal,
  34505. "treatCostSelfTotal": treatCostSelfTotal,
  34506. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34507. "treatSelfTotal": treatSelfTotal,
  34508. "treatInscpTotal": treatInscpTotal,
  34509. "doctor_info": doctor_info,
  34510. "doctor_code": adminRole_two.DoctorCode,
  34511. "doctor_name": doctor_name,
  34512. "health_card_no": order.PsnNo,
  34513. "department": departments.Name,
  34514. "yiliao_leibie": yiliao_leibie,
  34515. "after_money": order.AccountPrice,
  34516. "patient": patient,
  34517. "org_name": miConfig.OrgName,
  34518. "org_code": miConfig.Code,
  34519. "order_number": order.Number,
  34520. "his_hospital": his_hospital,
  34521. "his": his,
  34522. "dia_config": dia_config,
  34523. "psn_cash_pay": order.PsnCashPay,
  34524. //"check_order_info": cus_slice,
  34525. }
  34526. data3 = append(data3, data2)
  34527. }
  34528. }
  34529. }
  34530. c.ServeSuccessJSON(map[string]interface{}{
  34531. "infos": data3,
  34532. })
  34533. }
  34534. func (c *HisApiController) GetSettleAccounts() {
  34535. //id, _ := c.GetInt64("id")
  34536. //record_time := c.GetString("record_time")
  34537. order_id, _ := c.GetInt64("order_id")
  34538. admin_user_id, _ := c.GetInt64("admin_user_id")
  34539. //timeLayout := "2006-01-02"
  34540. //loc, _ := time.LoadLocation("Local")
  34541. //
  34542. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34543. //if err != nil {
  34544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34545. // return
  34546. //}Hbyb5203
  34547. //recordDateTime := theTime.Unix()
  34548. adminUser := c.GetAdminUserInfo()
  34549. order, _ := service.GetHisOrderByID(order_id)
  34550. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34551. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34552. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34553. orderInfos = append(orderInfos, orderInfos_two...)
  34554. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34555. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34556. var diagnosis_ids []string
  34557. if his.ID > 0 {
  34558. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34559. } else {
  34560. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34561. }
  34562. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34563. var dia_config []*models.HisXtDiagnoseConfig
  34564. var name string
  34565. for _, item := range diagnosis_ids {
  34566. id, _ := strconv.ParseInt(item, 10, 64)
  34567. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34568. dia_config = append(dia_config, &diagnosisConfig)
  34569. if len(name) == 0 {
  34570. name = diagnosisConfig.ClassName
  34571. } else {
  34572. name = name + "," + diagnosisConfig.ClassName
  34573. }
  34574. }
  34575. if patient.UserOrgId == 10215 {
  34576. name = "慢性肾功能不全(血透治疗)"
  34577. }
  34578. var bedCostTotal float64 = 0 //床位总费
  34579. var bedCostSelfTotal float64 = 0 //床位自费
  34580. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34581. var bedSelfTotal float64 = 0 //床位部分项目自费
  34582. var bedInscpTotal float64 = 0 //床位部分项目自费
  34583. var operationCostTotal float64 = 0 //手术费
  34584. var operationCostSelfTotal float64 = 0 //手术费
  34585. var operationCostPartSelfTotal float64 = 0 //手术费
  34586. var operationSelfTotal float64 = 0 //床位部分项目自费
  34587. var operationInscpTotal float64 = 0 //床位部分项目自费
  34588. var otherCostTotal float64 = 0 //其他费用
  34589. var otherCostSelfTotal float64 = 0 //其他费用
  34590. var otherCostPartSelfTotal float64 = 0 //其他费用
  34591. var otherSelfTotal float64 = 0 //床位部分项目自费
  34592. var otherInscpTotal float64 = 0 //床位部分项目自费
  34593. var materialCostTotal float64 = 0 //材料费
  34594. var materialCostSelfTotal float64 = 0 //材料费
  34595. var materialCostPartSelfTotal float64 = 0 //材料费
  34596. var materialSelfTotal float64 = 0 //床位部分项目自费
  34597. var materialInscpTotal float64 = 0 //床位部分项目自费
  34598. var westernMedicineCostTotal float64 = 0 //西药费
  34599. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34600. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34601. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34602. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34603. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34604. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34605. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34606. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34607. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34608. var checkCostTotal float64 = 0 //检查费
  34609. var checkCostSelfTotal float64 = 0 //检查费
  34610. var checkCostPartSelfTotal float64 = 0 //检查费
  34611. var checkSelfTotal float64 = 0 //床位部分项目自费
  34612. var checkInscpTotal float64 = 0 //床位部分项目自费
  34613. var laboratoryCostTotal float64 = 0 //化验费
  34614. var laboratoryCostSelfTotal float64 = 0 //化验费
  34615. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34616. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34617. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34618. var treatCostTotal float64 = 0 //治疗费用
  34619. var treatCostSelfTotal float64 = 0 //治疗费用
  34620. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34621. var treatSelfTotal float64 = 0 //床位部分项目自费
  34622. var treatInscpTotal float64 = 0 //床位部分项目自费
  34623. var zcCostTotal float64 = 0 //治疗费用
  34624. var zcCostSelfTotal float64 = 0 //治疗费用
  34625. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34626. var zcSelfTotal float64 = 0 //床位部分项目自费
  34627. var zcInscpTotal float64 = 0 //床位部分项目自费
  34628. var huliCostTotal float64 = 0 //治疗费用
  34629. var huliCostSelfTotal float64 = 0 //治疗费用
  34630. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34631. var huliSelfTotal float64 = 0 //床位部分项目自费
  34632. var huliInscpTotal float64 = 0 //床位部分项目自费
  34633. decimal.DivisionPrecision = 2
  34634. for _, item := range orderInfos {
  34635. if item.MedChrgitmType == "01" { //床位费
  34636. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34637. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34638. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34639. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34640. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34641. }
  34642. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34643. if item.MedChrgitmType == "03" { //检查费
  34644. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34645. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34646. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34647. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34648. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34649. }
  34650. } else {
  34651. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34652. fmt.Println("------------")
  34653. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34654. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34655. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34656. }
  34657. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34658. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34659. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34660. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34661. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34662. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34663. }
  34664. }
  34665. if item.MedChrgitmType == "04" { //化验费
  34666. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34667. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34668. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34669. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34670. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34671. }
  34672. if item.MedChrgitmType == "05" { //治疗费
  34673. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34674. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34675. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34676. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34677. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34678. }
  34679. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34680. fmt.Println("------------")
  34681. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34682. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34683. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34684. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34685. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34686. }
  34687. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34688. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34689. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34690. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34691. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34692. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34693. }
  34694. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34695. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34696. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34697. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34698. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34699. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34700. }
  34701. if item.MedChrgitmType == "09" { //西药费
  34702. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34703. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34704. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34705. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34706. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34707. }
  34708. if item.MedChrgitmType == "11" { //中成费
  34709. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34710. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34711. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34712. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34713. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34714. }
  34715. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34716. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34717. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34718. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34719. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34720. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34721. }
  34722. if item.MedChrgitmType == "02" { //其他费
  34723. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34724. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34725. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34726. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34727. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34728. }
  34729. if item.MedChrgitmType == "07" { //其他费
  34730. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34731. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34732. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34733. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34734. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34735. }
  34736. }
  34737. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34738. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34739. var user_name string
  34740. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34741. if role.ID == 0 {
  34742. user_name = "管理员"
  34743. } else {
  34744. user_name = role.UserName
  34745. }
  34746. baseParams := models.BaseParams{
  34747. SecretKey: miConfig.SecretKey,
  34748. FixmedinsCode: miConfig.Code,
  34749. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34750. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34751. OrgName: miConfig.OrgName,
  34752. Doctor: user_name,
  34753. RequestUrl: miConfig.Url,
  34754. AccessKey: miConfig.AccessKey,
  34755. }
  34756. businessParams := models.BusinessParams{
  34757. PsnNo: order.PsnNo,
  34758. MdtrtId: order.MdtrtId,
  34759. SetlId: order.SetlId,
  34760. }
  34761. var res ResultEleven
  34762. var resah ResultElevenah
  34763. var resEleven10265 ResultEleven10265
  34764. if config.IsOpen == 1 {
  34765. if miConfig.MdtrtareaAdmvs == "421300" {
  34766. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34767. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34768. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34769. resp, requestErr := http.Get(api)
  34770. if requestErr != nil {
  34771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34772. return
  34773. }
  34774. body, ioErr := ioutil.ReadAll(resp.Body)
  34775. if ioErr != nil {
  34776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34778. return
  34779. }
  34780. var respJSON map[string]interface{}
  34781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34784. return
  34785. }
  34786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34787. result, _ := json.Marshal(respJSON)
  34788. fmt.Println("log")
  34789. fmt.Println(string(result))
  34790. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34791. utils.ErrorLog("解析失败:%v", err)
  34792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34793. return
  34794. }
  34795. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34796. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34797. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34798. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34799. resp, requestErr := http.Get(api)
  34800. if requestErr != nil {
  34801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34802. return
  34803. }
  34804. body, ioErr := ioutil.ReadAll(resp.Body)
  34805. if ioErr != nil {
  34806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34808. return
  34809. }
  34810. var respJSON map[string]interface{}
  34811. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34814. return
  34815. }
  34816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34817. result, _ := json.Marshal(respJSON)
  34818. fmt.Println("log")
  34819. fmt.Println(string(result))
  34820. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34821. utils.ErrorLog("解析失败:%v", err)
  34822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34823. return
  34824. }
  34825. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34826. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34827. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34828. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34829. resp, requestErr := http.Get(api)
  34830. if requestErr != nil {
  34831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34832. return
  34833. }
  34834. body, ioErr := ioutil.ReadAll(resp.Body)
  34835. if ioErr != nil {
  34836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34838. return
  34839. }
  34840. var respJSON map[string]interface{}
  34841. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34847. result, _ := json.Marshal(respJSON)
  34848. fmt.Println("log")
  34849. fmt.Println(string(result))
  34850. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34851. utils.ErrorLog("解析失败:%v", err)
  34852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34853. return
  34854. }
  34855. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34856. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34857. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34858. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34859. resp, requestErr := http.Get(api)
  34860. if requestErr != nil {
  34861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34862. return
  34863. }
  34864. body, ioErr := ioutil.ReadAll(resp.Body)
  34865. if ioErr != nil {
  34866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34868. return
  34869. }
  34870. var respJSON map[string]interface{}
  34871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34874. return
  34875. }
  34876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34877. result, _ := json.Marshal(respJSON)
  34878. fmt.Println("log")
  34879. fmt.Println(string(result))
  34880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34881. utils.ErrorLog("解析失败:%v", err)
  34882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34883. return
  34884. }
  34885. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34886. var api string
  34887. if miConfig.MdtrtareaAdmvs == "320921" {
  34888. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34889. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34891. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34892. } else {
  34893. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34894. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34895. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34896. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34897. }
  34898. resp, requestErr := http.Get(api)
  34899. if requestErr != nil {
  34900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34901. return
  34902. }
  34903. body, ioErr := ioutil.ReadAll(resp.Body)
  34904. if ioErr != nil {
  34905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34907. return
  34908. }
  34909. var respJSON map[string]interface{}
  34910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34913. return
  34914. }
  34915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34916. result, _ := json.Marshal(respJSON)
  34917. fmt.Println("log")
  34918. fmt.Println(string(result))
  34919. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34920. utils.ErrorLog("解析失败:%v", err)
  34921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34922. return
  34923. }
  34924. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34925. res.Output = resEleven10265.Output
  34926. res.ErrMsg = resEleven10265.ErrMsg
  34927. res.Cainfo = resEleven10265.Cainfo
  34928. res.WarnMsg = resEleven10265.WarnMsg
  34929. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34930. res.Infcode = infocode
  34931. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34932. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34933. saveLog(result, requestLog, "5203", "结算单")
  34934. var dat map[string]interface{}
  34935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34936. fmt.Println(dat)
  34937. } else {
  34938. fmt.Println(err)
  34939. }
  34940. userJSONBytes, _ := json.Marshal(dat)
  34941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34942. utils.ErrorLog("解析失败:%v", err)
  34943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34944. return
  34945. }
  34946. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34947. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34948. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34949. saveLog(result, requestLog, "5203", "结算单")
  34950. var dat map[string]interface{}
  34951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34952. fmt.Println(dat)
  34953. } else {
  34954. fmt.Println(err)
  34955. }
  34956. userJSONBytes, _ := json.Marshal(dat)
  34957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34958. utils.ErrorLog("解析失败:%v", err)
  34959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34960. return
  34961. }
  34962. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34963. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34964. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34965. saveLog(result, requestLog, "5203", "结算单")
  34966. var dat map[string]interface{}
  34967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34968. fmt.Println(dat)
  34969. } else {
  34970. fmt.Println(err)
  34971. }
  34972. userJSONBytes, _ := json.Marshal(dat)
  34973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34974. utils.ErrorLog("解析失败:%v", err)
  34975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34976. return
  34977. }
  34978. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34979. var api string
  34980. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34981. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34982. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34983. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34984. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34985. resp, requestErr := http.Get(api)
  34986. if requestErr != nil {
  34987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34988. return
  34989. }
  34990. body, ioErr := ioutil.ReadAll(resp.Body)
  34991. if ioErr != nil {
  34992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34994. return
  34995. }
  34996. var respJSON map[string]interface{}
  34997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35000. return
  35001. }
  35002. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35003. if status == "0" {
  35004. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35005. c.ServeSuccessJSON(map[string]interface{}{
  35006. "failed_code": -10,
  35007. "msg": err_msg,
  35008. })
  35009. return
  35010. }
  35011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35012. result, _ := json.Marshal(respJSON)
  35013. fmt.Println("log")
  35014. fmt.Println(string(result))
  35015. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35016. utils.ErrorLog("解析失败:%v", err)
  35017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35018. return
  35019. }
  35020. res.InfRefmsgid = resah.InfRefmsgid
  35021. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35022. // 创建对应的Time类型
  35023. t := time.UnixMilli(timestamp)
  35024. // 格式化成指定的日期字符串
  35025. str := t.Format("2006-01-02 15:04:05")
  35026. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35027. // 创建对应的Time类型
  35028. t3 := time.UnixMilli(timestamp2)
  35029. // 格式化成指定的日期字符串
  35030. str2 := t3.Format("2006-01-02 15:04:05")
  35031. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35032. // 创建对应的Time类型
  35033. t4 := time.UnixMilli(timestamp3)
  35034. // 格式化成指定的日期字符串
  35035. str3 := t4.Format("2006-01-02 15:04:05")
  35036. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35037. // 创建对应的Time类型
  35038. t5 := time.UnixMilli(timestamp4)
  35039. // 格式化成指定的日期字符串
  35040. str5 := t5.Format("2006-01-02 15:04:05")
  35041. res.Output.Setlinfo.Brdy = str2
  35042. res.Output.Setlinfo.SetlTime = str
  35043. res.Output.Setlinfo.Begndate = str3
  35044. res.Output.Setlinfo.Enddate = str5
  35045. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35046. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35047. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35048. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35049. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35050. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35051. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35052. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35053. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35054. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35055. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35056. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35057. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35058. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35059. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35060. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35061. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35062. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35063. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35064. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35065. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35066. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35067. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35068. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35069. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35070. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35071. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35072. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35073. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35074. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35075. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35076. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35077. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35078. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35079. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35080. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35081. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35082. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35083. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35084. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35085. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35086. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35087. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35088. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35089. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35090. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35091. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35092. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35093. //res.Output.Setldetail = resah.Output.Setldetail
  35094. res.ErrMsg = resah.ErrMsg
  35095. res.Cainfo = resah.Cainfo
  35096. res.WarnMsg = resah.WarnMsg
  35097. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35098. var api string
  35099. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35100. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35101. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35102. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35103. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35104. resp, requestErr := http.Get(api)
  35105. if requestErr != nil {
  35106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35107. return
  35108. }
  35109. body, ioErr := ioutil.ReadAll(resp.Body)
  35110. if ioErr != nil {
  35111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35113. return
  35114. }
  35115. var respJSON map[string]interface{}
  35116. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35119. return
  35120. }
  35121. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35122. if status == "0" {
  35123. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35124. c.ServeSuccessJSON(map[string]interface{}{
  35125. "failed_code": -10,
  35126. "msg": err_msg,
  35127. })
  35128. return
  35129. }
  35130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35131. result, _ := json.Marshal(respJSON)
  35132. fmt.Println("log")
  35133. fmt.Println(string(result))
  35134. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35135. utils.ErrorLog("解析失败:%v", err)
  35136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35137. return
  35138. }
  35139. res.InfRefmsgid = resah.InfRefmsgid
  35140. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35141. // 创建对应的Time类型
  35142. t := time.UnixMilli(timestamp)
  35143. // 格式化成指定的日期字符串
  35144. str := t.Format("2006-01-02 15:04:05")
  35145. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35146. // 创建对应的Time类型
  35147. t3 := time.UnixMilli(timestamp2)
  35148. // 格式化成指定的日期字符串
  35149. str2 := t3.Format("2006-01-02 15:04:05")
  35150. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35151. // 创建对应的Time类型
  35152. t4 := time.UnixMilli(timestamp3)
  35153. // 格式化成指定的日期字符串
  35154. str3 := t4.Format("2006-01-02 15:04:05")
  35155. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35156. // 创建对应的Time类型
  35157. t5 := time.UnixMilli(timestamp4)
  35158. // 格式化成指定的日期字符串
  35159. str5 := t5.Format("2006-01-02 15:04:05")
  35160. res.Output.Setlinfo.Brdy = str2
  35161. res.Output.Setlinfo.SetlTime = str
  35162. res.Output.Setlinfo.Begndate = str3
  35163. res.Output.Setlinfo.Enddate = str5
  35164. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35165. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35166. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35167. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35168. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35169. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35170. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35171. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35172. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35173. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35174. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35175. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35176. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35177. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35178. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35179. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35180. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35181. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35182. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35183. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35184. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35185. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35186. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35187. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35188. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35189. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35190. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35191. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35192. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35193. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35194. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35195. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35196. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35197. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35198. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35199. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35200. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35201. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35202. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35203. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35204. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35205. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35206. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35207. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35208. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35209. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35210. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35211. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35212. //res.Output.Setldetail = resah.Output.Setldetail
  35213. res.ErrMsg = resah.ErrMsg
  35214. res.Cainfo = resah.Cainfo
  35215. res.WarnMsg = resah.WarnMsg
  35216. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35217. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35218. saveLog(result, requestLog, "5203", "结算单")
  35219. var dat map[string]interface{}
  35220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35221. fmt.Println(dat)
  35222. } else {
  35223. fmt.Println(err)
  35224. }
  35225. userJSONBytes, _ := json.Marshal(dat)
  35226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35227. utils.ErrorLog("解析失败:%v", err)
  35228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35229. return
  35230. }
  35231. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35232. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35233. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35234. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35235. resp, requestErr := http.Get(api)
  35236. if requestErr != nil {
  35237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35238. return
  35239. }
  35240. body, ioErr := ioutil.ReadAll(resp.Body)
  35241. if ioErr != nil {
  35242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35244. return
  35245. }
  35246. var respJSON map[string]interface{}
  35247. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35250. return
  35251. }
  35252. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35253. result, _ := json.Marshal(respJSON)
  35254. fmt.Println("log")
  35255. fmt.Println(string(result))
  35256. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35257. utils.ErrorLog("解析失败:%v", err)
  35258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35259. return
  35260. }
  35261. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35262. res.Output = resEleven10265.Output
  35263. res.ErrMsg = resEleven10265.ErrMsg
  35264. res.Cainfo = resEleven10265.Cainfo
  35265. res.WarnMsg = resEleven10265.WarnMsg
  35266. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35267. res.Infcode = infocode
  35268. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35269. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35270. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35271. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35272. resp, requestErr := http.Get(api)
  35273. if requestErr != nil {
  35274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35275. return
  35276. }
  35277. body, ioErr := ioutil.ReadAll(resp.Body)
  35278. if ioErr != nil {
  35279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35281. return
  35282. }
  35283. var respJSON map[string]interface{}
  35284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35287. return
  35288. }
  35289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35290. result, _ := json.Marshal(respJSON)
  35291. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35292. utils.ErrorLog("解析失败:%v", err)
  35293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35294. return
  35295. }
  35296. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35297. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35298. //return
  35299. } else {
  35300. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35301. if len(his.InsuplcAdmdvs) == 0 {
  35302. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35303. } else {
  35304. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35305. }
  35306. result := service.Gdyb5203(baseParams, businessParams)
  35307. //service.Gdyb5204(baseParams, businessParams)
  35308. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35309. var dat map[string]interface{}
  35310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35311. fmt.Println(dat)
  35312. } else {
  35313. fmt.Println(err)
  35314. }
  35315. userJSONBytes, _ := json.Marshal(dat)
  35316. if miConfig.Code == "H15049901371" {
  35317. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35318. utils.ErrorLog("解析失败:%v", err)
  35319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35320. return
  35321. }
  35322. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35323. res.Output = resEleven10265.Output
  35324. res.ErrMsg = resEleven10265.ErrMsg
  35325. res.Cainfo = resEleven10265.Cainfo
  35326. res.WarnMsg = resEleven10265.WarnMsg
  35327. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35328. res.Infcode = infocode
  35329. } else {
  35330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35331. utils.ErrorLog("解析失败:%v", err)
  35332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35333. return
  35334. }
  35335. }
  35336. }
  35337. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35338. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35339. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35340. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35341. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35342. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35343. var doctor_name string
  35344. if roles.ID == 0 {
  35345. doctor_name = "管理员"
  35346. } else {
  35347. doctor_name = roles.UserName
  35348. }
  35349. yiliao_leibie := ""
  35350. switch order.MedType {
  35351. case "11":
  35352. yiliao_leibie = "普通门诊"
  35353. break
  35354. case "12":
  35355. yiliao_leibie = "门诊挂号"
  35356. break
  35357. case "13":
  35358. yiliao_leibie = "急诊"
  35359. break
  35360. case "14":
  35361. yiliao_leibie = "门诊特殊病"
  35362. break
  35363. case "15":
  35364. yiliao_leibie = "门诊统筹"
  35365. break
  35366. case "16":
  35367. yiliao_leibie = "门诊慢性病"
  35368. break
  35369. case "21":
  35370. yiliao_leibie = "普通住院"
  35371. break
  35372. }
  35373. //var rf []CustomFundPay
  35374. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35375. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35376. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35377. if res.Infcode == 0 {
  35378. 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 {
  35379. c.ServeSuccessJSON(map[string]interface{}{
  35380. "diagnosis": name,
  35381. "order_infos": orderInfos,
  35382. "number": order.MdtrtId,
  35383. "date": order.SettleAccountsDate,
  35384. "charge_admin": charge_admin,
  35385. "printor_admin": printor_admin,
  35386. "info": res.Output.Setlinfo,
  35387. "order": order,
  35388. "bedCostTotal": bedCostTotal,
  35389. "bedCostSelfTotal": bedCostSelfTotal,
  35390. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35391. "bedSelfTotal": bedSelfTotal,
  35392. "bedInscpTotal": bedInscpTotal,
  35393. "operationCostTotal": operationCostTotal,
  35394. "operationCostSelfTotal": operationCostSelfTotal,
  35395. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35396. "operationSelfTotal": operationSelfTotal,
  35397. "operationInscpTotal": operationInscpTotal,
  35398. "otherCostTotal": otherCostTotal,
  35399. "otherCostSelfTotal": otherCostSelfTotal,
  35400. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35401. "otherSelfTotal": otherSelfTotal,
  35402. "otherInscpTotal": otherInscpTotal,
  35403. "materialCostTotal": materialCostTotal,
  35404. "materialCostSelfTotal": materialCostSelfTotal,
  35405. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35406. "materialSelfTotal": materialSelfTotal,
  35407. "materialInscpTotal": materialInscpTotal,
  35408. "westernMedicineCostTotal": westernMedicineCostTotal,
  35409. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35410. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35411. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35412. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35413. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35414. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35415. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35416. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35417. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35418. "checkCostTotal": checkCostTotal,
  35419. "checkCostSelfTotal": checkCostSelfTotal,
  35420. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35421. "checkSelfTotal": checkSelfTotal,
  35422. "checkInscpTotal": checkInscpTotal,
  35423. "laboratoryCostTotal": laboratoryCostTotal,
  35424. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35425. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35426. "laboratorySelfTotal": laboratorySelfTotal,
  35427. "laboratoryInscpTotal": laboratoryInscpTotal,
  35428. "treatCostTotal": treatCostTotal,
  35429. "treatCostSelfTotal": treatCostSelfTotal,
  35430. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35431. "treatSelfTotal": treatSelfTotal,
  35432. "treatInscpTotal": treatInscpTotal,
  35433. "doctor_info": doctor_info,
  35434. "doctor_code": adminRole_two.DoctorCode,
  35435. "doctor_name": doctor_name,
  35436. "health_card_no": order.PsnNo,
  35437. "department": departments.Name,
  35438. "yiliao_leibie": yiliao_leibie,
  35439. "after_money": order.AccountPrice,
  35440. "patient": patient,
  35441. "org_name": miConfig.OrgName,
  35442. "org_code": miConfig.Code,
  35443. "order_number": order.Number,
  35444. "his_hospital": his_hospital,
  35445. "his": his,
  35446. "dia_config": dia_config,
  35447. "psn_cash_pay": order.PsnCashPay,
  35448. "zcCostTotal": zcCostTotal,
  35449. "zcCostSelfTotal": zcCostSelfTotal,
  35450. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35451. "zcSelfTotal": zcSelfTotal,
  35452. "zcInscpTotal": zcInscpTotal,
  35453. "huliCostTotal": huliCostTotal,
  35454. "huliCostSelfTotal": huliCostSelfTotal,
  35455. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35456. "huliSelfTotal": huliSelfTotal,
  35457. "huliInscpTotal": huliInscpTotal,
  35458. //"funds": rf,
  35459. //"check_order_info": cus_slice,
  35460. })
  35461. } else {
  35462. c.ServeSuccessJSON(map[string]interface{}{
  35463. "diagnosis": name,
  35464. "order_infos": orderInfos,
  35465. "number": order.MdtrtId,
  35466. "date": order.SettleAccountsDate,
  35467. "charge_admin": charge_admin,
  35468. "printor_admin": printor_admin,
  35469. "info": order,
  35470. "order": order,
  35471. "bedCostTotal": bedCostTotal,
  35472. "bedCostSelfTotal": bedCostSelfTotal,
  35473. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35474. "bedSelfTotal": bedSelfTotal,
  35475. "bedInscpTotal": bedInscpTotal,
  35476. "operationCostTotal": operationCostTotal,
  35477. "operationCostSelfTotal": operationCostSelfTotal,
  35478. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35479. "operationSelfTotal": operationSelfTotal,
  35480. "operationInscpTotal": operationInscpTotal,
  35481. "otherCostTotal": otherCostTotal,
  35482. "otherCostSelfTotal": otherCostSelfTotal,
  35483. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35484. "otherSelfTotal": otherSelfTotal,
  35485. "otherInscpTotal": otherInscpTotal,
  35486. "materialCostTotal": materialCostTotal,
  35487. "materialCostSelfTotal": materialCostSelfTotal,
  35488. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35489. "materialSelfTotal": materialSelfTotal,
  35490. "materialInscpTotal": materialInscpTotal,
  35491. "westernMedicineCostTotal": westernMedicineCostTotal,
  35492. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35493. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35494. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35495. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35496. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35497. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35498. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35499. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35500. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35501. "checkCostTotal": checkCostTotal,
  35502. "checkCostSelfTotal": checkCostSelfTotal,
  35503. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35504. "checkSelfTotal": checkSelfTotal,
  35505. "checkInscpTotal": checkInscpTotal,
  35506. "laboratoryCostTotal": laboratoryCostTotal,
  35507. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35508. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35509. "laboratorySelfTotal": laboratorySelfTotal,
  35510. "laboratoryInscpTotal": laboratoryInscpTotal,
  35511. "treatCostTotal": treatCostTotal,
  35512. "treatCostSelfTotal": treatCostSelfTotal,
  35513. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35514. "treatSelfTotal": treatSelfTotal,
  35515. "treatInscpTotal": treatInscpTotal,
  35516. "doctor_info": doctor_info,
  35517. "doctor_code": adminRole_two.DoctorCode,
  35518. "doctor_name": doctor_name,
  35519. "health_card_no": order.PsnNo,
  35520. "department": departments.Name,
  35521. "yiliao_leibie": yiliao_leibie,
  35522. "after_money": order.AccountPrice,
  35523. "patient": patient,
  35524. "org_name": miConfig.OrgName,
  35525. "org_code": miConfig.Code,
  35526. "order_number": order.Number,
  35527. "his_hospital": his_hospital,
  35528. "his": his,
  35529. "dia_config": dia_config,
  35530. "psn_cash_pay": order.PsnCashPay,
  35531. "zcCostTotal": zcCostTotal,
  35532. "zcCostSelfTotal": zcCostSelfTotal,
  35533. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35534. "zcSelfTotal": zcSelfTotal,
  35535. "zcInscpTotal": zcInscpTotal,
  35536. "huliCostTotal": huliCostTotal,
  35537. "huliCostSelfTotal": huliCostSelfTotal,
  35538. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35539. "huliSelfTotal": huliSelfTotal,
  35540. "huliInscpTotal": huliInscpTotal,
  35541. //"funds": rf,
  35542. //"check_order_info": cus_slice,
  35543. })
  35544. }
  35545. }
  35546. }
  35547. }
  35548. //func (c *HisApiController) CheckTreatment() {
  35549. // patient_id, _ := c.GetInt64("patient_id")
  35550. // id_card_no := c.GetString("id_card_no")
  35551. // insutype := c.GetString("insutype")
  35552. // med_type := c.GetString("med_type")
  35553. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35554. //
  35555. // adminUser := c.GetAdminUserInfo()
  35556. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35557. //
  35558. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35559. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35560. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35561. //
  35562. // if miConfig.MdtrtareaAdmvs == "421300" {
  35563. // var res ResultTwo
  35564. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35565. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35566. // "&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)
  35567. // resp, requestErr := http.Get(api)
  35568. // if requestErr != nil {
  35569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35570. // return
  35571. // }
  35572. //
  35573. // body, ioErr := ioutil.ReadAll(resp.Body)
  35574. // if ioErr != nil {
  35575. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35577. // return
  35578. // }
  35579. // var respJSON map[string]interface{}
  35580. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35581. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35583. // return
  35584. // }
  35585. //
  35586. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35587. // result, _ := json.Marshal(respJSON)
  35588. //
  35589. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35590. // utils.ErrorLog("解析失败:%v", err)
  35591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35592. // return
  35593. // }
  35594. //
  35595. // if res.Infcode == 0 {
  35596. //
  35597. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35598. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35599. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35600. // resp, requestErr := http.Get(api)
  35601. // if requestErr != nil {
  35602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35603. // return
  35604. // }
  35605. //
  35606. // body, ioErr := ioutil.ReadAll(resp.Body)
  35607. // if ioErr != nil {
  35608. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35610. // return
  35611. // }
  35612. // var respJSON map[string]interface{}
  35613. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35614. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35616. // return
  35617. // }
  35618. // var res Result2001
  35619. //
  35620. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35621. // result2, _ := json.Marshal(respJSON)
  35622. //
  35623. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35624. // utils.ErrorLog("解析失败:%v", err)
  35625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35626. // return
  35627. // }
  35628. //
  35629. // if res.Infcode == 0 {
  35630. // c.ServeSuccessJSON(map[string]interface{}{
  35631. // "msg": res.Output.Trtinfo,
  35632. // })
  35633. // }
  35634. //
  35635. // } else {
  35636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35637. // return
  35638. // }
  35639. //
  35640. // } else {
  35641. //
  35642. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35643. // var dat map[string]interface{}
  35644. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35645. // fmt.Println(dat)
  35646. // } else {
  35647. // fmt.Println(err)
  35648. // }
  35649. // userJSONBytes, _ := json.Marshal(dat)
  35650. // var res ResultTwo
  35651. // var res10265 ResultTwo10265
  35652. // if miConfig.Code == "H15049901371" {
  35653. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35654. // utils.ErrorLog("解析失败:%v", err)
  35655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35656. // return
  35657. // }
  35658. // res.ErrMsg = res10265.ErrMsg
  35659. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35660. // res.Infcode = infocode
  35661. // res.Output = res10265.Output
  35662. // res.InfRefmsgid = res10265.InfRefmsgid
  35663. // } else {
  35664. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35665. // utils.ErrorLog("解析失败:%v", err)
  35666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35667. // return
  35668. // }
  35669. // }
  35670. //
  35671. // var user_name string
  35672. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35673. // if role.ID == 0 {
  35674. // user_name = "xxx"
  35675. // } else {
  35676. // user_name = role.UserName
  35677. // }
  35678. //
  35679. // baseParams := models.BaseParams{
  35680. // SecretKey: miConfig.SecretKey,
  35681. // FixmedinsCode: miConfig.Code,
  35682. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35683. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35684. // OrgName: miConfig.OrgName,
  35685. // Doctor: user_name,
  35686. // }
  35687. //
  35688. // if config.IsOpen == 1 {
  35689. // if miConfig.Code == "H15049901371" {
  35690. // if med_type == "14" {
  35691. // if insutype == "390" {
  35692. // med_type = "9933"
  35693. // } else if insutype == "310" {
  35694. // med_type = "990502"
  35695. // }
  35696. // } else if med_type == "11" {
  35697. // med_type = "11"
  35698. // }
  35699. // }
  35700. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35701. // var dat map[string]interface{}
  35702. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35703. // fmt.Println(dat)
  35704. // } else {
  35705. // fmt.Println(err)
  35706. // }
  35707. // var res Result2001
  35708. // var res10265 Result2001Org10265
  35709. // if miConfig.Code == "H15049901371" {
  35710. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35711. // utils.ErrorLog("解析失败:%v", err)
  35712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35713. // return
  35714. // }
  35715. // res.ErrMsg = res10265.ErrMsg
  35716. // res.Output = res10265.Output
  35717. // res.InfRefmsgid = res10265.InfRefmsgid
  35718. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35719. // res.Infcode = infocode
  35720. // } else {
  35721. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35722. // utils.ErrorLog("解析失败:%v", err)
  35723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35724. // return
  35725. // }
  35726. // }
  35727. // if res.Infcode == 0 {
  35728. // c.ServeSuccessJSON(map[string]interface{}{
  35729. // "msg": res.Output.Trtinfo,
  35730. // })
  35731. // }
  35732. // }
  35733. // }
  35734. //}
  35735. //func (c *HisApiController) PutRecord() {
  35736. // id, _ := c.GetInt64("id")
  35737. // record_time := c.GetString("record_time")
  35738. // timeLayout := "2006-01-02"
  35739. // loc, _ := time.LoadLocation("Local")
  35740. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35741. // if err != nil {
  35742. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35743. // return
  35744. // }
  35745. // recordDateTime := theTime.Unix()
  35746. //
  35747. // adminInfo := c.GetAdminUserInfo()
  35748. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35749. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35750. //
  35751. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35752. //
  35753. // fmt.Println(miConfig.SecretKey)
  35754. //
  35755. // if patient == nil {
  35756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35757. // return
  35758. // }
  35759. // if len(patient.IdCardNo) == 0 {
  35760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35761. // return
  35762. // }
  35763. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35764. // if config.IsOpen == 1 {
  35765. // 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
  35766. // resp, requestErr := http.Get(api)
  35767. // if requestErr != nil {
  35768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35769. // return
  35770. // }
  35771. // defer resp.Body.Close()
  35772. // body, ioErr := ioutil.ReadAll(resp.Body)
  35773. // if ioErr != nil {
  35774. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35776. // return
  35777. // }
  35778. // var respJSON map[string]interface{}
  35779. //
  35780. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35781. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35783. // return
  35784. // }
  35785. //
  35786. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35787. // userJSONBytes, _ := json.Marshal(userJSON)
  35788. // var res ResultTwo
  35789. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35790. // utils.ErrorLog("解析失败:%v", err)
  35791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35792. // return
  35793. // }
  35794. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35795. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35796. // infoStr := string(Iinfos)
  35797. // idetinfoStr := string(Idetinfos)
  35798. //
  35799. // if res.Infcode == 0 {
  35800. // his := models.VMHisPatient{
  35801. // Status: 1,
  35802. // Ctime: time.Now().Unix(),
  35803. // Mtime: time.Now().Unix(),
  35804. // PsnNo: res.Output.Baseinfo.PsnNo,
  35805. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35806. // Certno: res.Output.Baseinfo.Certno,
  35807. // PsnName: res.Output.Baseinfo.PsnName,
  35808. // Gend: res.Output.Baseinfo.Gend,
  35809. // Naty: res.Output.Baseinfo.Naty,
  35810. // Brdy: res.Output.Baseinfo.Brdy,
  35811. // Age: res.Output.Baseinfo.Age,
  35812. // Iinfo: infoStr,
  35813. // Idetinfo: idetinfoStr,
  35814. // PatientId: patient.ID,
  35815. // RecordDate: theTime.Unix(),
  35816. // UserOrgId: adminInfo.CurrentOrgId,
  35817. // AdminUserId: adminInfo.AdminUser.Id,
  35818. // IsReturn: 1,
  35819. // }
  35820. //
  35821. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35822. // //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")
  35823. // //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")
  35824. //
  35825. // //var dat map[string]interface{}
  35826. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35827. // // fmt.Println(dat)
  35828. // //} else {
  35829. // // fmt.Println(err)
  35830. // //}
  35831. //
  35832. // var dat2 map[string]interface{}
  35833. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35834. // fmt.Println(dat2)
  35835. // } else {
  35836. // fmt.Println(err)
  35837. // }
  35838. //
  35839. // } else {
  35840. // adminUser := c.GetAdminUserInfo()
  35841. // errlog := &models.HisOrderError{
  35842. // UserOrgId: adminUser.CurrentOrgId,
  35843. // Ctime: time.Now().Unix(),
  35844. // Mtime: time.Now().Unix(),
  35845. // ErrMsg: res.ErrMsg,
  35846. // Status: 1,
  35847. // PatientId: id,
  35848. // RecordTime: recordDateTime,
  35849. // Stage: 1,
  35850. // }
  35851. // service.CreateErrMsgLog(errlog)
  35852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35853. // return
  35854. // }
  35855. // }
  35856. //
  35857. //}
  35858. //func (c *HisApiController) GetUploadDiag() {
  35859. // id, _ := c.GetInt64("id")
  35860. // record_time := c.GetString("record_time")
  35861. //
  35862. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35863. // sick_type, _ := c.GetInt64("sick_type")
  35864. // reg_type, _ := c.GetInt64("reg_type")
  35865. //
  35866. // timeLayout := "2006-01-02"
  35867. // loc, _ := time.LoadLocation("Local")
  35868. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35869. // if err != nil {
  35870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35871. // return
  35872. // }
  35873. //
  35874. // var patientPrescription models.HisPrescriptionInfo
  35875. // recordDateTime := theTime.Unix()
  35876. // adminInfo := c.GetAdminUserInfo()
  35877. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35878. //
  35879. // if patientPrescription.ID == 0 {
  35880. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35881. // }
  35882. //
  35883. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35884. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35885. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35886. // sickConfig, _ := service.FindSickById(sick_type)
  35887. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35888. //
  35889. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35890. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35891. // "&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 +
  35892. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35893. // resp2, requestErr2 := http.Get(api2)
  35894. // if requestErr2 != nil {
  35895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35896. // return
  35897. // }
  35898. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35899. // if ioErr2 != nil {
  35900. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35902. // return
  35903. // }
  35904. // var respJSON2 map[string]interface{}
  35905. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35906. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35908. // return
  35909. // }
  35910. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35911. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35912. //
  35913. // var res2 ResultSix
  35914. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35915. // utils.ErrorLog("解析失败:%v", err)
  35916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35917. // return
  35918. // }
  35919. // if res2.Infcode != 0 {
  35920. // adminUser := c.GetAdminUserInfo()
  35921. // errlog := &models.HisOrderError{
  35922. // UserOrgId: adminUser.CurrentOrgId,
  35923. // Ctime: time.Now().Unix(),
  35924. // Mtime: time.Now().Unix(),
  35925. // ErrMsg: res2.ErrMsg,
  35926. // Status: 1,
  35927. // PatientId: id,
  35928. // RecordTime: recordDateTime,
  35929. // Stage: 3,
  35930. // }
  35931. // service.CreateErrMsgLog(errlog)
  35932. //
  35933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35934. // return
  35935. // }
  35936. //
  35937. // c.ServeSuccessJSON(map[string]interface{}{
  35938. // "msg": "上传成功",
  35939. // })
  35940. //
  35941. //}
  35942. type QueryResult struct {
  35943. ID int64
  35944. Name string
  35945. Code string
  35946. List_type_code string
  35947. }
  35948. func (c *HisApiController) GetCheckCode() {
  35949. ids_str := c.GetString("ids")
  35950. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35951. ids_arr := strings.Split(ids_str, ",")
  35952. var queryResult []QueryResult
  35953. ids := make([]int64, 0)
  35954. for _, item := range ids_arr {
  35955. id, _ := strconv.ParseInt(item, 10, 64)
  35956. ids = append(ids, id)
  35957. }
  35958. if record_type == 1 {
  35959. drugs, _ := service.GetBatchDrugList(ids)
  35960. for _, item := range drugs {
  35961. result := QueryResult{
  35962. ID: item.ID,
  35963. Name: item.DrugName,
  35964. Code: item.MedicalInsuranceNumber,
  35965. List_type_code: "101",
  35966. }
  35967. queryResult = append(queryResult, result)
  35968. }
  35969. } else if record_type == 2 {
  35970. goods, _ := service.GetBatchGoodInformationList(ids)
  35971. fmt.Println(goods)
  35972. for _, item := range goods {
  35973. result := QueryResult{
  35974. ID: item.ID,
  35975. Name: item.GoodName,
  35976. Code: item.SocialSecurityDirectoryCode,
  35977. List_type_code: "301",
  35978. }
  35979. queryResult = append(queryResult, result)
  35980. }
  35981. } else if record_type == 3 {
  35982. projects, _ := service.GetBathchMyPorjecgList(ids)
  35983. for _, item := range projects {
  35984. result := QueryResult{
  35985. ID: item.ID,
  35986. Name: item.ProjectName,
  35987. Code: item.MedicalCode,
  35988. List_type_code: "201",
  35989. }
  35990. queryResult = append(queryResult, result)
  35991. }
  35992. }
  35993. admin_user_id, _ := c.GetInt64("admin_user_id")
  35994. adminUser := c.GetAdminUserInfo()
  35995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35996. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35997. var user_name string
  35998. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35999. if role.ID == 0 {
  36000. user_name = "管理员"
  36001. } else {
  36002. user_name = role.UserName
  36003. }
  36004. baseParams := models.BaseParams{
  36005. SecretKey: miConfig.SecretKey,
  36006. FixmedinsCode: miConfig.Code,
  36007. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36008. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36009. OrgName: miConfig.OrgName,
  36010. Doctor: user_name,
  36011. }
  36012. var result string
  36013. if miConfig.MdtrtareaAdmvs == "430800" {
  36014. for _, item := range queryResult {
  36015. if record_type == 1 {
  36016. 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)
  36017. } else if record_type == 2 {
  36018. fmt.Println(item.Code)
  36019. 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)
  36020. } else if record_type == 3 {
  36021. 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)
  36022. }
  36023. var dat map[string]interface{}
  36024. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36025. fmt.Println(dat)
  36026. } else {
  36027. fmt.Println(err)
  36028. }
  36029. userJSONBytes, _ := json.Marshal(dat)
  36030. var res ResultSix
  36031. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36032. utils.ErrorLog("解析失败:%v", err)
  36033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36034. return
  36035. }
  36036. if res.Infcode == 0 {
  36037. if record_type == 1 {
  36038. service.UpdateBaseDrugById(item.ID)
  36039. } else if record_type == 2 {
  36040. service.UpdateGoodInformaitonByDetail(item.ID)
  36041. } else if record_type == 3 {
  36042. service.UpdateProjectById(item.ID)
  36043. }
  36044. c.ServeSuccessJSON(map[string]interface{}{
  36045. "failed_code": 0,
  36046. "msg": "目录对照成功",
  36047. })
  36048. } else {
  36049. c.ServeSuccessJSON(map[string]interface{}{
  36050. "failed_code": -10,
  36051. "msg": res.ErrMsg,
  36052. })
  36053. }
  36054. }
  36055. } else {
  36056. for _, item := range queryResult {
  36057. var result string
  36058. if record_type == 1 {
  36059. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36060. } else if record_type == 2 {
  36061. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36062. } else if record_type == 3 {
  36063. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36064. }
  36065. var dat map[string]interface{}
  36066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36067. fmt.Println(dat)
  36068. } else {
  36069. fmt.Println(err)
  36070. }
  36071. userJSONBytes, _ := json.Marshal(dat)
  36072. var res ResultSix
  36073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36074. utils.ErrorLog("解析失败:%v", err)
  36075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36076. return
  36077. }
  36078. if res.Infcode == 0 {
  36079. if record_type == 1 {
  36080. service.UpdateBaseDrugById(item.ID)
  36081. } else if record_type == 2 {
  36082. service.UpdateGoodInformaitonByDetail(item.ID)
  36083. } else if record_type == 3 {
  36084. service.UpdateProjectById(item.ID)
  36085. }
  36086. c.ServeSuccessJSON(map[string]interface{}{
  36087. "failed_code": 0,
  36088. "msg": "目录对照成功",
  36089. })
  36090. } else {
  36091. c.ServeSuccessJSON(map[string]interface{}{
  36092. "failed_code": -10,
  36093. "msg": res.ErrMsg,
  36094. })
  36095. }
  36096. }
  36097. }
  36098. }
  36099. func (c *HisApiController) UnCheckCode() {
  36100. ids_str := c.GetString("ids")
  36101. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36102. admin_user_id, _ := c.GetInt64("admin_user_id")
  36103. ids_arr := strings.Split(ids_str, ",")
  36104. var queryResult []QueryResult
  36105. ids := make([]int64, 0)
  36106. for _, item := range ids_arr {
  36107. id, _ := strconv.ParseInt(item, 10, 64)
  36108. ids = append(ids, id)
  36109. }
  36110. if record_type == 1 {
  36111. drugs, _ := service.GetBatchDrugList(ids)
  36112. for _, item := range drugs {
  36113. result := QueryResult{
  36114. ID: item.ID,
  36115. Name: item.DrugName,
  36116. Code: item.MedicalInsuranceNumber,
  36117. List_type_code: "101",
  36118. }
  36119. queryResult = append(queryResult, result)
  36120. }
  36121. } else if record_type == 2 {
  36122. goods, _ := service.GetBatchGoodInformationList(ids)
  36123. for _, item := range goods {
  36124. result := QueryResult{
  36125. ID: item.ID,
  36126. Name: item.GoodName,
  36127. Code: item.SocialSecurityDirectoryCode,
  36128. List_type_code: "301",
  36129. }
  36130. queryResult = append(queryResult, result)
  36131. }
  36132. } else if record_type == 3 {
  36133. projects, _ := service.GetBathchMyPorjecgList(ids)
  36134. for _, item := range projects {
  36135. result := QueryResult{
  36136. ID: item.ID,
  36137. Name: item.ProjectName,
  36138. Code: item.MedicalCode,
  36139. List_type_code: "201",
  36140. }
  36141. queryResult = append(queryResult, result)
  36142. }
  36143. }
  36144. adminUser := c.GetAdminUserInfo()
  36145. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36146. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36147. var user_name string
  36148. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36149. if role.ID == 0 {
  36150. user_name = "xxx"
  36151. } else {
  36152. user_name = role.UserName
  36153. }
  36154. baseParams := &models.BaseParams{
  36155. SecretKey: miConfig.SecretKey,
  36156. FixmedinsCode: miConfig.Code,
  36157. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36158. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36159. OrgName: miConfig.OrgName,
  36160. Doctor: user_name,
  36161. }
  36162. if config.IsOpen == 1 {
  36163. if miConfig.MdtrtareaAdmvs == "430800" {
  36164. for _, item := range queryResult {
  36165. var result string
  36166. if record_type == 1 {
  36167. 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)
  36168. } else if record_type == 2 {
  36169. fmt.Println(item.Code)
  36170. 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)
  36171. } else if record_type == 3 {
  36172. 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)
  36173. }
  36174. var dat map[string]interface{}
  36175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36176. fmt.Println(dat)
  36177. } else {
  36178. fmt.Println(err)
  36179. }
  36180. userJSONBytes, _ := json.Marshal(dat)
  36181. var res ResultSix
  36182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36183. utils.ErrorLog("解析失败:%v", err)
  36184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36185. return
  36186. }
  36187. if res.Infcode == 0 {
  36188. if record_type == 1 {
  36189. service.UpdateBaseDrugById(item.ID)
  36190. } else if record_type == 2 {
  36191. service.UpdateGoodInformaitonByDetail(item.ID)
  36192. } else if record_type == 3 {
  36193. service.UpdateProjectById(item.ID)
  36194. }
  36195. c.ServeSuccessJSON(map[string]interface{}{
  36196. "failed_code": 0,
  36197. "msg": "目录对照成功",
  36198. })
  36199. } else {
  36200. c.ServeSuccessJSON(map[string]interface{}{
  36201. "failed_code": -10,
  36202. "msg": res.ErrMsg,
  36203. })
  36204. }
  36205. }
  36206. } else {
  36207. for _, item := range queryResult {
  36208. var result string
  36209. if record_type == 1 {
  36210. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36211. } else if record_type == 2 {
  36212. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36213. } else if record_type == 3 {
  36214. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36215. }
  36216. var dat2 map[string]interface{}
  36217. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36218. fmt.Println(dat2)
  36219. } else {
  36220. fmt.Println(err)
  36221. }
  36222. userJSONBytes, _ := json.Marshal(dat2)
  36223. var res ResultSix
  36224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36225. utils.ErrorLog("解析失败:%v", err)
  36226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36227. return
  36228. }
  36229. if res.Infcode == 0 {
  36230. if record_type == 1 {
  36231. service.UpdateDrugByIdDetail(item.ID)
  36232. } else if record_type == 2 {
  36233. service.UpdateGoodInfoById(item.ID)
  36234. } else if record_type == 3 {
  36235. service.UpdateMyProjectById(item.ID)
  36236. }
  36237. c.ServeSuccessJSON(map[string]interface{}{
  36238. "failed_code": 0,
  36239. "msg": "撤销目录对照成功",
  36240. })
  36241. } else {
  36242. c.ServeSuccessJSON(map[string]interface{}{
  36243. "failed_code": -10,
  36244. "msg": res.ErrMsg,
  36245. })
  36246. }
  36247. }
  36248. }
  36249. }
  36250. }
  36251. func (c *HisApiController) GetPatientInfo() {
  36252. id_card_no := c.GetString("id_card_no")
  36253. admin_user_id, _ := c.GetInt64("admin_user_id")
  36254. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36255. if patient.ID == 0 {
  36256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36257. return
  36258. }
  36259. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36260. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36261. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36262. var res ResultTwo
  36263. var res10265 ResultTwo10265
  36264. if config.IsOpen == 1 {
  36265. if miConfig.MdtrtareaAdmvs == "150499" {
  36266. //请求内网数据
  36267. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36268. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36269. "&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
  36270. resp, requestErr := http.Get(api)
  36271. if requestErr != nil {
  36272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36273. return
  36274. }
  36275. body, ioErr := ioutil.ReadAll(resp.Body)
  36276. if ioErr != nil {
  36277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36279. return
  36280. }
  36281. var respJSON map[string]interface{}
  36282. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36285. return
  36286. }
  36287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36288. result_byte, _ := json.Marshal(respJSON)
  36289. result := string(result_byte)
  36290. var dat map[string]interface{}
  36291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36292. fmt.Println(dat)
  36293. } else {
  36294. fmt.Println(err)
  36295. }
  36296. userJSONBytes, _ := json.Marshal(dat)
  36297. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36298. utils.ErrorLog("解析失败:%v", err)
  36299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36300. return
  36301. }
  36302. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36303. res.Infcode = Infcode
  36304. res.ErrMsg = res10265.ErrMsg
  36305. res.Output = res10265.Output
  36306. res.InfRefmsgid = res10265.InfRefmsgid
  36307. res.RespondTime = res10265.RespondTime
  36308. res.WarnInfo = res10265.WarnInfo
  36309. } else {
  36310. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36311. var dat map[string]interface{}
  36312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36313. fmt.Println(dat)
  36314. } else {
  36315. fmt.Println(err)
  36316. }
  36317. userJSONBytes, _ := json.Marshal(dat)
  36318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36319. utils.ErrorLog("解析失败:%v", err)
  36320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36321. return
  36322. }
  36323. }
  36324. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36325. // utils.ErrorLog("解析失败:%v", err)
  36326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36327. // return
  36328. //}
  36329. for index, item := range res.Output.Iinfo {
  36330. if item.PsnInsuStas == "2" {
  36331. fmt.Println("--------")
  36332. res.Output.Iinfo[index].Insutype = "300"
  36333. res.Output.Iinfo[index].PsnInsuStas = "1"
  36334. }
  36335. }
  36336. fmt.Println(res.Output.Iinfo)
  36337. if res.Infcode != 0 {
  36338. c.ServeSuccessJSON(map[string]interface{}{
  36339. "failed_code": -10,
  36340. "msg": res.ErrMsg,
  36341. })
  36342. } else {
  36343. c.ServeSuccessJSON(map[string]interface{}{
  36344. "failed_code": 0,
  36345. "info": res,
  36346. })
  36347. }
  36348. }
  36349. }
  36350. func (c *HisApiController) PsnPutOnRecord() {
  36351. record_type, _ := c.GetInt64("type")
  36352. patient_id, _ := c.GetInt64("patient_id")
  36353. admin_user_id, _ := c.GetInt64("admin_user_id")
  36354. start_time := c.GetString("start_time")
  36355. end_time := c.GetString("end_time")
  36356. adminUser := c.GetAdminUserInfo()
  36357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36358. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36359. var patients []*models.Patients
  36360. if record_type == 1 { //全部备案
  36361. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36362. patients = append(patients, patient...)
  36363. } else { //单个备案
  36364. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36365. patients = append(patients, patient)
  36366. }
  36367. var user_name string
  36368. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36369. if role.ID == 0 {
  36370. user_name = "xxx"
  36371. } else {
  36372. user_name = role.UserName
  36373. }
  36374. if config.IsOpen == 1 {
  36375. for _, item := range patients {
  36376. 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
  36377. resp, requestErr := http.Get(api)
  36378. if requestErr != nil {
  36379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36380. return
  36381. }
  36382. defer resp.Body.Close()
  36383. body, ioErr := ioutil.ReadAll(resp.Body)
  36384. if ioErr != nil {
  36385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36387. return
  36388. }
  36389. var respJSON map[string]interface{}
  36390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36393. return
  36394. }
  36395. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36396. userJSONBytes, _ := json.Marshal(userJSON)
  36397. var res ResultTwo
  36398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36399. utils.ErrorLog("解析失败:%v", err)
  36400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36401. return
  36402. }
  36403. if res.Infcode == 0 {
  36404. 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)
  36405. var dat map[string]interface{}
  36406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36407. fmt.Println(dat)
  36408. } else {
  36409. fmt.Println(err)
  36410. }
  36411. userJSONBytes, _ := json.Marshal(dat)
  36412. var res2 ResultThirteen
  36413. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36414. utils.ErrorLog("解析失败:%v", err)
  36415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36416. return
  36417. }
  36418. if res2.Infcode == 0 {
  36419. psnResult := &models.GdybPsnRecord{
  36420. UserOrgId: adminUser.CurrentOrgId,
  36421. PatientId: item.ID,
  36422. PsnNo: res.Output.Baseinfo.PsnNo,
  36423. Ctime: time.Now().Unix(),
  36424. Mtime: time.Now().Unix(),
  36425. Status: 1,
  36426. IsCancel: 1,
  36427. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36428. }
  36429. service.CreatePsnRecord(psnResult)
  36430. } else {
  36431. c.ServeSuccessJSON(map[string]interface{}{
  36432. "failed_code": -10,
  36433. "msg": res2.ErrMsg,
  36434. })
  36435. return
  36436. }
  36437. }
  36438. }
  36439. }
  36440. }
  36441. func (c *HisApiController) PsnUnPutOnRecord() {
  36442. id, _ := c.GetInt64("id")
  36443. //record_type, _ := c.GetInt64("type")
  36444. admin_user_id, _ := c.GetInt64("admin_user_id")
  36445. adminUser := c.GetAdminUserInfo()
  36446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36447. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36448. var user_name string
  36449. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36450. if role.ID == 0 {
  36451. user_name = "xxx"
  36452. } else {
  36453. user_name = role.UserName
  36454. }
  36455. psn_record, _ := service.GetPsnRecordById(id)
  36456. if psn_record.ID == 0 {
  36457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36458. return
  36459. }
  36460. if config.IsOpen == 1 {
  36461. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36462. var dat map[string]interface{}
  36463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36464. fmt.Println(dat)
  36465. } else {
  36466. fmt.Println(err)
  36467. }
  36468. userJSONBytes, _ := json.Marshal(dat)
  36469. var res ResultFourteen
  36470. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36471. utils.ErrorLog("解析失败:%v", err)
  36472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36473. return
  36474. }
  36475. if res.Infcode == 0 {
  36476. psn_record.IsCancel = 2
  36477. service.CreatePsnRecord(&psn_record)
  36478. } else {
  36479. c.ServeSuccessJSON(map[string]interface{}{
  36480. "failed_code": -10,
  36481. "msg": res.ErrMsg,
  36482. })
  36483. return
  36484. }
  36485. }
  36486. }
  36487. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36488. patient_id, _ := c.GetInt64("patient_id")
  36489. insutype_two := c.GetString("insutype")
  36490. psn_no := c.GetString("psn_no")
  36491. doctor_id, _ := c.GetInt64("doctor_id")
  36492. sick_id, _ := c.GetInt64("sick_id")
  36493. department_id, _ := c.GetInt64("department_id")
  36494. start_time := c.GetString("start_time")
  36495. end_time := c.GetString("end_time")
  36496. check_time := c.GetString("check_time")
  36497. hospital_code := c.GetString("hospital_code")
  36498. hospital_name := c.GetString("hospital_name")
  36499. adminUser := c.GetAdminUserInfo()
  36500. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36502. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36503. sick, _ := service.FindSickById(sick_id)
  36504. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36505. if len(hospital_code) == 0 {
  36506. hospital_code = miConfig.Code
  36507. }
  36508. if len(hospital_name) == 0 {
  36509. hospital_name = miConfig.OrgName
  36510. }
  36511. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36512. var res ResultTwo
  36513. var res10265 ResultTwo10265
  36514. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36515. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36516. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36517. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36518. "&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
  36519. resp, requestErr := http.Get(api)
  36520. if requestErr != nil {
  36521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36522. return
  36523. }
  36524. body, ioErr := ioutil.ReadAll(resp.Body)
  36525. if ioErr != nil {
  36526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36528. return
  36529. }
  36530. var respJSON map[string]interface{}
  36531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36534. return
  36535. }
  36536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36537. result, _ := json.Marshal(respJSON)
  36538. fmt.Println("log")
  36539. fmt.Println(string(result))
  36540. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36541. utils.ErrorLog("解析失败:%v", err)
  36542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36543. return
  36544. }
  36545. res.ErrMsg = res10265.ErrMsg
  36546. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36547. res.Infcode = infocode
  36548. res.Output = res10265.Output
  36549. res.InfRefmsgid = res10265.InfRefmsgid
  36550. } else {
  36551. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36552. if miConfig.Code == "H15049901371" {
  36553. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36554. utils.ErrorLog("解析失败:%v", err)
  36555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36556. return
  36557. }
  36558. res.ErrMsg = res10265.ErrMsg
  36559. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36560. res.Infcode = infocode
  36561. res.Output = res10265.Output
  36562. res.InfRefmsgid = res10265.InfRefmsgid
  36563. } else {
  36564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36565. utils.ErrorLog("解析失败:%v", err)
  36566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36567. return
  36568. }
  36569. }
  36570. }
  36571. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36572. infoStr := string(Iinfos)
  36573. var rf []*ResultFive
  36574. json.Unmarshal([]byte(infoStr), &rf)
  36575. var insuplc_admdvs string
  36576. var insutype string
  36577. var is390 int = 0
  36578. var is310 int = 0
  36579. var insutypes []*ResultFive
  36580. for _, item := range rf {
  36581. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36582. insutypes = append(insutypes, item)
  36583. }
  36584. }
  36585. if len(insutypes) == 1 {
  36586. insutype = insutypes[0].Insutype
  36587. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36588. } else {
  36589. for _, i := range insutypes {
  36590. if i.Insutype == "390" {
  36591. is390 = 1
  36592. }
  36593. if i.Insutype == "310" {
  36594. is310 = 1
  36595. }
  36596. }
  36597. }
  36598. if is390 == 1 {
  36599. insutype = "390"
  36600. }
  36601. if is310 == 1 {
  36602. insutype = "310"
  36603. }
  36604. if len(insutypes) == 2 {
  36605. insutype = insutype_two
  36606. }
  36607. if len(insutypes) == 0 {
  36608. insutype = "310"
  36609. }
  36610. insutype = insutype_two
  36611. fmt.Println(insutype)
  36612. for _, item := range rf {
  36613. fmt.Println(item.Insutype)
  36614. fmt.Println(insutype)
  36615. if item.Insutype == insutype {
  36616. fmt.Println(item.Insutype)
  36617. fmt.Println(insutype)
  36618. insuplc_admdvs = item.InsuplcAdmdvs
  36619. }
  36620. }
  36621. fmt.Println(insuplc_admdvs)
  36622. var res2 ResultThirteen
  36623. var res10265_2 ResultThirteen10265
  36624. if config.IsOpen == 1 {
  36625. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36626. } else {
  36627. if miConfig.MdtrtareaAdmvs == "150499" {
  36628. //
  36629. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36630. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36631. // "&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
  36632. //resp, requestErr := http.Get(api)
  36633. //if requestErr != nil {
  36634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36635. // return
  36636. //}
  36637. //
  36638. //body, ioErr := ioutil.ReadAll(resp.Body)
  36639. //if ioErr != nil {
  36640. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36642. // return
  36643. //}
  36644. //var respJSON map[string]interface{}
  36645. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36646. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36648. // return
  36649. //}
  36650. //
  36651. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36652. //result, _ := json.Marshal(respJSON)
  36653. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36654. // utils.ErrorLog("解析失败:%v", err)
  36655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36656. // return
  36657. //}
  36658. //infocode = resThree.Infcode
  36659. //result, _ := json.Marshal(respJSON)
  36660. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36661. // utils.ErrorLog("解析失败:%v", err)
  36662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36663. // return
  36664. //}
  36665. //
  36666. //resThree.ErrMsg = resThree10265.ErrMsg
  36667. //
  36668. //resThree.Output = resThree10265.Output
  36669. //
  36670. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36671. //
  36672. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36673. //
  36674. } else {
  36675. 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)
  36676. var dat map[string]interface{}
  36677. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36678. fmt.Println(dat)
  36679. } else {
  36680. fmt.Println(err)
  36681. }
  36682. userJSONBytes, _ := json.Marshal(dat)
  36683. if miConfig.Code == "H15049901371" {
  36684. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36685. utils.ErrorLog("解析失败:%v", err)
  36686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36687. return
  36688. }
  36689. res2.ErrMsg = res10265_2.ErrMsg
  36690. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36691. res2.Infcode = infocode
  36692. res2.Output = res10265_2.Output
  36693. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36694. } else {
  36695. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36696. utils.ErrorLog("解析失败:%v", err)
  36697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36698. return
  36699. }
  36700. }
  36701. }
  36702. }
  36703. if res2.Infcode == 0 {
  36704. psnResult := &models.GdybPsnNcdsRecord{
  36705. UserOrgId: adminUser.CurrentOrgId,
  36706. PatientId: patient.ID,
  36707. PsnNo: psn_no,
  36708. DoctorId: doctor.AdminUserId,
  36709. DepartmentId: department_id,
  36710. SickType: sick_id,
  36711. Insutype: insutype,
  36712. Ctime: time.Now().Unix(),
  36713. Mtime: time.Now().Unix(),
  36714. Status: 1,
  36715. IsCancel: 1,
  36716. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36717. }
  36718. service.CreatePsnNCDSRecord(psnResult)
  36719. c.ServeSuccessJSON(map[string]interface{}{
  36720. "failed_code": 0,
  36721. "msg": "备案成功",
  36722. "result": psnResult,
  36723. })
  36724. } else {
  36725. c.ServeSuccessJSON(map[string]interface{}{
  36726. "failed_code": -10,
  36727. "msg": res2.ErrMsg,
  36728. })
  36729. return
  36730. }
  36731. }
  36732. }
  36733. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36734. id, _ := c.GetInt64("id")
  36735. admin_user_id, _ := c.GetInt64("admin_user_id")
  36736. adminUser := c.GetAdminUserInfo()
  36737. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36738. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36739. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36740. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36741. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36742. //var user_name string
  36743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36744. //if role.ID == 0 {
  36745. // user_name = "xxx"
  36746. //} else {
  36747. // user_name = role.UserName
  36748. //}
  36749. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36750. if psn_record.ID == 0 {
  36751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36752. return
  36753. }
  36754. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36755. var res ResultTwo
  36756. var res10265 ResultTwo10265
  36757. if miConfig.Code == "H15049901371" {
  36758. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36759. utils.ErrorLog("解析失败:%v", err)
  36760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36761. return
  36762. }
  36763. res.ErrMsg = res10265.ErrMsg
  36764. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36765. res.Infcode = infocode
  36766. res.Output = res10265.Output
  36767. res.InfRefmsgid = res10265.InfRefmsgid
  36768. } else {
  36769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36770. utils.ErrorLog("解析失败:%v", err)
  36771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36772. return
  36773. }
  36774. }
  36775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36776. infoStr := string(Iinfos)
  36777. var rf []*ResultFive
  36778. json.Unmarshal([]byte(infoStr), &rf)
  36779. var insuplc_admdvs string
  36780. var insutype string
  36781. var is390 int = 0
  36782. var is310 int = 0
  36783. var insutypes []*ResultFive
  36784. for _, item := range rf {
  36785. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36786. insutypes = append(insutypes, item)
  36787. }
  36788. }
  36789. if len(insutypes) == 1 {
  36790. insutype = insutypes[0].Insutype
  36791. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36792. } else {
  36793. for _, i := range insutypes {
  36794. if i.Insutype == "390" {
  36795. is390 = 1
  36796. }
  36797. if i.Insutype == "310" {
  36798. is310 = 1
  36799. }
  36800. }
  36801. }
  36802. if is390 == 1 {
  36803. insutype = "390"
  36804. }
  36805. if is310 == 1 {
  36806. insutype = "310"
  36807. }
  36808. if len(insutypes) == 0 {
  36809. insutype = "310"
  36810. }
  36811. insutype = psn_record.Insutype
  36812. for _, item := range rf {
  36813. if item.Insutype == insutype {
  36814. insuplc_admdvs = item.InsuplcAdmdvs
  36815. }
  36816. }
  36817. if config.IsOpen == 1 {
  36818. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36819. var dat map[string]interface{}
  36820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36821. fmt.Println(dat)
  36822. } else {
  36823. fmt.Println(err)
  36824. }
  36825. userJSONBytes, _ := json.Marshal(dat)
  36826. var res ResultFourteen
  36827. var res10265 ResultFourteen10265
  36828. if miConfig.Code == "H15049901371" {
  36829. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36830. utils.ErrorLog("解析失败:%v", err)
  36831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36832. return
  36833. }
  36834. res.ErrMsg = res10265.ErrMsg
  36835. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36836. res.Infcode = infocode
  36837. res.Output = res10265.Output
  36838. res.InfRefmsgid = res10265.InfRefmsgid
  36839. } else {
  36840. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36841. utils.ErrorLog("解析失败:%v", err)
  36842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36843. return
  36844. }
  36845. }
  36846. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36847. // utils.ErrorLog("解析失败:%v", err)
  36848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36849. // return
  36850. //}
  36851. if res.Infcode == 0 {
  36852. psn_record.IsCancel = 2
  36853. service.CreatePsnNCDSRecord(&psn_record)
  36854. c.ServeSuccessJSON(map[string]interface{}{
  36855. "failed_code": 0,
  36856. "msg": "撤销备案成功",
  36857. })
  36858. } else {
  36859. c.ServeSuccessJSON(map[string]interface{}{
  36860. "failed_code": -10,
  36861. "msg": res.ErrMsg,
  36862. })
  36863. return
  36864. }
  36865. }
  36866. }
  36867. func (c *HisApiController) TestTest() {
  36868. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36869. fmt.Println(patient.Iinfo)
  36870. }
  36871. type CustomData struct {
  36872. MsgId string
  36873. PsnNo string
  36874. Info string
  36875. }
  36876. func (c *HisApiController) ReversalData() {
  36877. var customData []*CustomData
  36878. custom := &CustomData{
  36879. MsgId: "H44022900158202103301714472004",
  36880. PsnNo: "44020000001101329945",
  36881. Info: "2207",
  36882. }
  36883. customData = append(customData, custom)
  36884. custom1 := &CustomData{
  36885. MsgId: "H4402290015820210330172057803",
  36886. PsnNo: "44020000001101161813",
  36887. Info: "2207",
  36888. }
  36889. customData = append(customData, custom1)
  36890. custom2 := &CustomData{
  36891. MsgId: "H44022900158202103301705198813",
  36892. PsnNo: "44190000133097375417",
  36893. Info: "2207",
  36894. }
  36895. customData = append(customData, custom2)
  36896. custom3 := &CustomData{
  36897. MsgId: "H44022900158202103301715524756",
  36898. PsnNo: "44020000001100187221",
  36899. Info: "2207",
  36900. }
  36901. customData = append(customData, custom3)
  36902. custom4 := &CustomData{
  36903. MsgId: "H44022900158202103301730376224",
  36904. PsnNo: "44020000001101959155",
  36905. Info: "2207",
  36906. }
  36907. customData = append(customData, custom4)
  36908. custom5 := &CustomData{
  36909. MsgId: "H44022900158202103301748008725",
  36910. PsnNo: "44020000001104246641",
  36911. Info: "2207",
  36912. }
  36913. customData = append(customData, custom5)
  36914. custom6 := &CustomData{
  36915. MsgId: "H44022900158202103301718096755",
  36916. PsnNo: "44020000001102211860",
  36917. Info: "2207",
  36918. }
  36919. customData = append(customData, custom6)
  36920. custom7 := &CustomData{
  36921. MsgId: "H44022900158202103301736551640",
  36922. PsnNo: "44020000001102687718",
  36923. Info: "2207",
  36924. }
  36925. customData = append(customData, custom7)
  36926. custom8 := &CustomData{
  36927. MsgId: "H44022900158202103301743097676",
  36928. PsnNo: "44020000001102127785",
  36929. Info: "2207",
  36930. }
  36931. customData = append(customData, custom8)
  36932. custom9 := &CustomData{
  36933. MsgId: "H44022900158202103301712304203",
  36934. PsnNo: "44020000001101518097",
  36935. Info: "2207",
  36936. }
  36937. customData = append(customData, custom9)
  36938. custom10 := &CustomData{
  36939. MsgId: "H44022900158202103301738448785",
  36940. PsnNo: "44020000001100500813",
  36941. Info: "2207",
  36942. }
  36943. customData = append(customData, custom10)
  36944. custom11 := &CustomData{
  36945. MsgId: "H44022900158202103301732455843",
  36946. PsnNo: "44020000001102690557",
  36947. Info: "2207",
  36948. }
  36949. customData = append(customData, custom11)
  36950. custom12 := &CustomData{
  36951. MsgId: "H44022900158202103301745421708",
  36952. PsnNo: "44020000001102211928",
  36953. Info: "2207",
  36954. }
  36955. customData = append(customData, custom12)
  36956. custom1212 := &CustomData{
  36957. MsgId: "H440229001582021033017351627",
  36958. PsnNo: "44020000001102481733",
  36959. Info: "2207",
  36960. }
  36961. customData = append(customData, custom1212)
  36962. custom13 := &CustomData{
  36963. MsgId: "H44022900158202103301740327951",
  36964. PsnNo: "44020000001103174866",
  36965. Info: "2207",
  36966. }
  36967. customData = append(customData, custom13)
  36968. custom14 := &CustomData{
  36969. MsgId: "H4402290015820210330174922668",
  36970. PsnNo: "44020000001102927272",
  36971. Info: "2207",
  36972. }
  36973. customData = append(customData, custom14)
  36974. custom15 := &CustomData{
  36975. MsgId: "H44022900158202103301752362273",
  36976. PsnNo: "44020000001102942890",
  36977. Info: "2207",
  36978. }
  36979. customData = append(customData, custom15)
  36980. custom16 := &CustomData{
  36981. MsgId: "H44022900158202103301751082917",
  36982. PsnNo: "44020000001101662162",
  36983. Info: "2207",
  36984. }
  36985. customData = append(customData, custom16)
  36986. custom17 := &CustomData{
  36987. MsgId: "H44022900158202103301754147728",
  36988. PsnNo: "44020000000229014511",
  36989. Info: "2207",
  36990. }
  36991. customData = append(customData, custom17)
  36992. adminUser := c.GetAdminUserInfo()
  36993. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36994. for _, item := range customData {
  36995. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36996. fmt.Println(result)
  36997. }
  36998. }
  36999. func (c *HisApiController) GetAllopatry() {
  37000. year := c.GetString("year")
  37001. month := c.GetString("month")
  37002. admin_user_id, _ := c.GetInt64("admin_user_id")
  37003. adminUser := c.GetAdminUserInfo()
  37004. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37005. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37006. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37007. var dat map[string]interface{}
  37008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37009. fmt.Println(dat)
  37010. } else {
  37011. fmt.Println(err)
  37012. }
  37013. userJSONBytes, _ := json.Marshal(dat)
  37014. var res models.Result9001
  37015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37016. utils.ErrorLog("解析失败:%v", err)
  37017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37018. return
  37019. }
  37020. fmt.Println(res.Output.Signinoutb)
  37021. fmt.Println(res.Output.Signinoutb.SignNo)
  37022. fmt.Println(string(userJSONBytes))
  37023. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37024. var dat3 map[string]interface{}
  37025. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37026. fmt.Println(dat3)
  37027. } else {
  37028. fmt.Println(err)
  37029. }
  37030. userJSONBytes3, _ := json.Marshal(dat3)
  37031. var res3 models.Result3260
  37032. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37033. utils.ErrorLog("解析失败:%v", err)
  37034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37035. return
  37036. }
  37037. var curpage int
  37038. var pagesize int = 100
  37039. var start int = 1
  37040. //var stop int
  37041. //pagecount := 10
  37042. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37043. var res22 []models.Result3260
  37044. for curpage = 1; curpage <= pagecount; curpage++ {
  37045. if curpage == 1 {
  37046. start = 0
  37047. } else {
  37048. start = (curpage-1)*pagesize + 1
  37049. }
  37050. fmt.Println(start)
  37051. //stop = curpage * pagesize
  37052. //if stop > int(res3.Output.Totalrow) {
  37053. // stop =int(res3.Output.Totalrow)
  37054. //}
  37055. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37056. var dat2 map[string]interface{}
  37057. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37058. fmt.Println(dat)
  37059. } else {
  37060. fmt.Println(err)
  37061. }
  37062. userJSONBytes2, _ := json.Marshal(dat2)
  37063. var res2 models.Result3260
  37064. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37065. utils.ErrorLog("解析失败:%v", err)
  37066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37067. return
  37068. }
  37069. if res2.Infcode == 0 {
  37070. res22 = append(res22, res2)
  37071. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37072. //var dat2 map[string]interface{}
  37073. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37074. // fmt.Println(dat)
  37075. //} else {
  37076. // fmt.Println(err)
  37077. //}
  37078. //c.ServeSuccessJSON(map[string]interface{}{
  37079. // "list": res2.Output.Data,
  37080. //})
  37081. //continue
  37082. }
  37083. }
  37084. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37085. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37086. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37087. //var dat2 map[string]interface{}
  37088. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37089. // fmt.Println(dat)
  37090. //} else {
  37091. // fmt.Println(err)
  37092. //}
  37093. //userJSONBytes2, _ := json.Marshal(dat2)
  37094. //var res2 models.Result3260
  37095. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37096. // utils.ErrorLog("解析失败:%v", err)
  37097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37098. // return
  37099. //}
  37100. //if res2.Infcode == 0 {
  37101. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37102. // var dat2 map[string]interface{}
  37103. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37104. // fmt.Println(dat)
  37105. // } else {
  37106. // fmt.Println(err)
  37107. // }
  37108. // c.ServeSuccessJSON(map[string]interface{}{
  37109. // "list": res2.Output.Data,
  37110. // })
  37111. //}
  37112. }
  37113. func (c *HisApiController) ComfirmAllopatry() {
  37114. year := c.GetString("year")
  37115. month := c.GetString("month")
  37116. admin_user_id, _ := c.GetInt64("admin_user_id")
  37117. adminUser := c.GetAdminUserInfo()
  37118. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37119. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37120. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37121. var dat map[string]interface{}
  37122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37123. fmt.Println(dat)
  37124. } else {
  37125. fmt.Println(err)
  37126. }
  37127. userJSONBytes, _ := json.Marshal(dat)
  37128. var res models.Result9001
  37129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37130. utils.ErrorLog("解析失败:%v", err)
  37131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37132. return
  37133. }
  37134. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37135. var dat2 map[string]interface{}
  37136. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37137. fmt.Println(dat)
  37138. } else {
  37139. fmt.Println(err)
  37140. }
  37141. userJSONBytes2, _ := json.Marshal(dat2)
  37142. var res2 models.Result3260
  37143. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37144. utils.ErrorLog("解析失败:%v", err)
  37145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37146. return
  37147. }
  37148. //if res2.Infcode == 0 {
  37149. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37150. // var dat map[string]interface{}
  37151. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37152. // fmt.Println(dat)
  37153. // } else {
  37154. // fmt.Println(err)
  37155. // }
  37156. // userJSONBytes, _ := json.Marshal(dat)
  37157. // var res3 models.Result3261
  37158. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37159. // utils.ErrorLog("解析失败:%v", err)
  37160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37161. // return
  37162. // }
  37163. //
  37164. // if res3.Infcode == 0 {
  37165. // record := &models.HisYidiClearRecord{
  37166. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37167. // Ctime: time.Now().Unix(),
  37168. // Mtime: time.Now().Unix(),
  37169. // Status: 1,
  37170. // MsgId: msgId,
  37171. // }
  37172. // service.SaveClearRecord(record)
  37173. // c.ServeSuccessJSON(map[string]interface{}{
  37174. // "msg": "提取成功",
  37175. // })
  37176. // }
  37177. //}
  37178. }
  37179. func (c *HisApiController) RefundAllopatry() {
  37180. year := c.GetString("year")
  37181. month := c.GetString("month")
  37182. //id, _ := c.GetInt64("id")
  37183. admin_user_id, _ := c.GetInt64("admin_user_id")
  37184. adminUser := c.GetAdminUserInfo()
  37185. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37186. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37187. //record, _ := service.GetClearRecordById(id)
  37188. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37189. var dat map[string]interface{}
  37190. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37191. fmt.Println(dat)
  37192. } else {
  37193. fmt.Println(err)
  37194. }
  37195. userJSONBytes, _ := json.Marshal(dat)
  37196. var res models.Result9001
  37197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37198. utils.ErrorLog("解析失败:%v", err)
  37199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37200. return
  37201. }
  37202. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37203. var dat2 map[string]interface{}
  37204. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37205. fmt.Println(dat)
  37206. } else {
  37207. fmt.Println(err)
  37208. }
  37209. userJSONBytes2, _ := json.Marshal(dat2)
  37210. var empty ResultFourteen
  37211. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37212. utils.ErrorLog("解析失败:%v", err)
  37213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37214. return
  37215. }
  37216. if empty.Infcode == 0 {
  37217. c.ServeSuccessJSON(map[string]interface{}{
  37218. "msg": "撤销成功",
  37219. })
  37220. return
  37221. }
  37222. }
  37223. func (c *HisApiController) ReversalOtherData() {
  37224. var customData []*CustomData
  37225. custom := &CustomData{
  37226. MsgId: "H44022900158202103301714472004",
  37227. PsnNo: "44020000001101329945",
  37228. Info: "2208",
  37229. }
  37230. customData = append(customData, custom)
  37231. custom1 := &CustomData{
  37232. MsgId: "H4402290015820210330172057803",
  37233. PsnNo: "44020000001101161813",
  37234. Info: "2208",
  37235. }
  37236. customData = append(customData, custom1)
  37237. custom2 := &CustomData{
  37238. MsgId: "H44022900158202103301705198813",
  37239. PsnNo: "44190000133097375417",
  37240. Info: "2208",
  37241. }
  37242. customData = append(customData, custom2)
  37243. custom3 := &CustomData{
  37244. MsgId: "H44022900158202103301715524756",
  37245. PsnNo: "44020000001100187221",
  37246. Info: "2208",
  37247. }
  37248. customData = append(customData, custom3)
  37249. custom4 := &CustomData{
  37250. MsgId: "H44022900158202103301730376224",
  37251. PsnNo: "44020000001101959155",
  37252. Info: "2208",
  37253. }
  37254. customData = append(customData, custom4)
  37255. custom5 := &CustomData{
  37256. MsgId: "H44022900158202103301748008725",
  37257. PsnNo: "44020000001104246641",
  37258. Info: "2208",
  37259. }
  37260. customData = append(customData, custom5)
  37261. custom6 := &CustomData{
  37262. MsgId: "H44022900158202103301718096755",
  37263. PsnNo: "44020000001102211860",
  37264. Info: "2208",
  37265. }
  37266. customData = append(customData, custom6)
  37267. custom7 := &CustomData{
  37268. MsgId: "H44022900158202103301736551640",
  37269. PsnNo: "44020000001102687718",
  37270. Info: "2208",
  37271. }
  37272. customData = append(customData, custom7)
  37273. custom8 := &CustomData{
  37274. MsgId: "H44022900158202103301743097676",
  37275. PsnNo: "44020000001102127785",
  37276. Info: "2208",
  37277. }
  37278. customData = append(customData, custom8)
  37279. custom9 := &CustomData{
  37280. MsgId: "H44022900158202103301712304203",
  37281. PsnNo: "44020000001101518097",
  37282. Info: "2208",
  37283. }
  37284. customData = append(customData, custom9)
  37285. custom10 := &CustomData{
  37286. MsgId: "H44022900158202103301738448785",
  37287. PsnNo: "44020000001100500813",
  37288. Info: "2208",
  37289. }
  37290. customData = append(customData, custom10)
  37291. custom11 := &CustomData{
  37292. MsgId: "H44022900158202103301732455843",
  37293. PsnNo: "44020000001102690557",
  37294. Info: "2208",
  37295. }
  37296. customData = append(customData, custom11)
  37297. custom12 := &CustomData{
  37298. MsgId: "H44022900158202103301745421708",
  37299. PsnNo: "44020000001102211928",
  37300. Info: "2208",
  37301. }
  37302. customData = append(customData, custom12)
  37303. custom1212 := &CustomData{
  37304. MsgId: "H440229001582021033017351627",
  37305. PsnNo: "44020000001102481733",
  37306. Info: "2208",
  37307. }
  37308. customData = append(customData, custom1212)
  37309. custom13 := &CustomData{
  37310. MsgId: "H44022900158202103301740327951",
  37311. PsnNo: "44020000001103174866",
  37312. Info: "2208",
  37313. }
  37314. customData = append(customData, custom13)
  37315. custom14 := &CustomData{
  37316. MsgId: "H4402290015820210330174922668",
  37317. PsnNo: "44020000001102927272",
  37318. Info: "2208",
  37319. }
  37320. customData = append(customData, custom14)
  37321. custom15 := &CustomData{
  37322. MsgId: "H44022900158202103301752362273",
  37323. PsnNo: "44020000001102942890",
  37324. Info: "2208",
  37325. }
  37326. customData = append(customData, custom15)
  37327. custom16 := &CustomData{
  37328. MsgId: "H44022900158202103301751082917",
  37329. PsnNo: "44020000001101662162",
  37330. Info: "2208",
  37331. }
  37332. customData = append(customData, custom16)
  37333. custom17 := &CustomData{
  37334. MsgId: "H44022900158202103301754147728",
  37335. PsnNo: "44020000000229014511",
  37336. Info: "2208",
  37337. }
  37338. customData = append(customData, custom17)
  37339. adminUser := c.GetAdminUserInfo()
  37340. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37341. for _, item := range customData {
  37342. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37343. fmt.Println(result)
  37344. }
  37345. }
  37346. func PathExists(path string) (bool, error) {
  37347. _, err := os.Stat(path)
  37348. if err == nil {
  37349. return true, nil
  37350. }
  37351. if os.IsNotExist(err) {
  37352. return false, nil
  37353. }
  37354. return false, err
  37355. }
  37356. // 创建文件夹
  37357. func Mkdir(dir string) {
  37358. // 创建文件夹
  37359. exist, err := PathExists(dir)
  37360. if err != nil {
  37361. fmt.Println(err.Error())
  37362. } else {
  37363. if exist {
  37364. fmt.Println(dir + "文件夹已存在!")
  37365. } else {
  37366. // 文件夹名称,权限
  37367. err := os.Mkdir(dir, os.ModePerm)
  37368. if err != nil {
  37369. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37370. } else {
  37371. fmt.Println(dir + "文件夹创建成功!")
  37372. }
  37373. }
  37374. }
  37375. }
  37376. // 压缩文件
  37377. func Zip(srcFile string, destZip string) error {
  37378. zipfile, err := os.Create(destZip)
  37379. if err != nil {
  37380. return err
  37381. }
  37382. defer zipfile.Close()
  37383. archive := zip.NewWriter(zipfile)
  37384. defer archive.Close()
  37385. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37386. if err != nil {
  37387. return err
  37388. }
  37389. header, err := zip.FileInfoHeader(info)
  37390. if err != nil {
  37391. return err
  37392. }
  37393. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37394. // header.Name = path
  37395. if info.IsDir() {
  37396. header.Name += "/"
  37397. } else {
  37398. header.Method = zip.Deflate
  37399. }
  37400. writer, err := archive.CreateHeader(header)
  37401. if err != nil {
  37402. return err
  37403. }
  37404. if !info.IsDir() {
  37405. file, err := os.Open(path)
  37406. if err != nil {
  37407. return err
  37408. }
  37409. defer file.Close()
  37410. _, err = io.Copy(writer, file)
  37411. }
  37412. return err
  37413. })
  37414. return err
  37415. }
  37416. func ReadFile(filePath string) []byte {
  37417. f, err := os.Open(filePath)
  37418. if err != nil {
  37419. fmt.Println("read file fail", err)
  37420. return nil
  37421. }
  37422. defer f.Close()
  37423. fd, err := ioutil.ReadAll(f)
  37424. if err != nil {
  37425. fmt.Println("read to fd fail", err)
  37426. return nil
  37427. }
  37428. return fd
  37429. }
  37430. func saveLogq(result string, request string, infno string, desc string) {
  37431. dir := "日志"
  37432. utils.Mkdir(dir)
  37433. month := time.Unix(1557042972, 0).Format("1")
  37434. year := time.Now().Format("2006")
  37435. month = time.Now().Format("01")
  37436. day := time.Now().Format("02")
  37437. hour := time.Now().Format("15")
  37438. min := time.Now().Format("04")
  37439. sec := time.Now().Format("05")
  37440. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37441. file := year + month + day + "_log"
  37442. file_name := file + ".txt"
  37443. file_path := "日志" + "/" + file_name
  37444. exist, _ := utils.PathExists(file_path)
  37445. if exist { //存在
  37446. fmt.Println("存在")
  37447. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37448. if err != nil {
  37449. fmt.Println("read fail")
  37450. }
  37451. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37452. n, _ := f.Seek(0, 2)
  37453. _, err = f.WriteAt([]byte(content), n)
  37454. } else { //不存在
  37455. fmt.Println("文件不存在,创建文件")
  37456. f, err := os.Create("日志" + "/" + file_name)
  37457. defer f.Close()
  37458. if err != nil {
  37459. } else {
  37460. _, err = f.Write([]byte("记录日志"))
  37461. }
  37462. }
  37463. }
  37464. func saveLog(result string, request string, infno string, desc string) {
  37465. org_id, _ := beego.AppConfig.Int64("org_id")
  37466. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37467. dir := miConfig.OrgName + "日志"
  37468. utils.Mkdir(dir)
  37469. month := time.Unix(1557042972, 0).Format("1")
  37470. year := time.Now().Format("2006")
  37471. month = time.Now().Format("01")
  37472. day := time.Now().Format("02")
  37473. hour := time.Now().Format("15")
  37474. min := time.Now().Format("04")
  37475. sec := time.Now().Format("05")
  37476. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37477. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37478. file_name := file + ".txt"
  37479. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37480. exist, _ := utils.PathExists(file_path)
  37481. if exist { //存在
  37482. fmt.Println("存在")
  37483. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37484. if err != nil {
  37485. fmt.Println("read fail")
  37486. }
  37487. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37488. n, _ := f.Seek(0, 2)
  37489. _, err = f.WriteAt([]byte(content), n)
  37490. } else { //不存在
  37491. fmt.Println("文件不存在,创建文件")
  37492. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37493. defer f.Close()
  37494. if err != nil {
  37495. } else {
  37496. _, err = f.Write([]byte("记录日志"))
  37497. }
  37498. }
  37499. }
  37500. type Charset string
  37501. const (
  37502. UTF8 = Charset("UTF-8")
  37503. GB18030 = Charset("GB18030")
  37504. )
  37505. func ConvertToString(src string, srcCode string, tagCode string) string {
  37506. srcCoder := mahonia.NewDecoder(srcCode)
  37507. srcResult := srcCoder.ConvertString(src)
  37508. tagCoder := mahonia.NewDecoder(tagCode)
  37509. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37510. result := string(cdata)
  37511. return result
  37512. }
  37513. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37514. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37515. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37516. var token string
  37517. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37518. var api string
  37519. if miConfig.MdtrtareaAdmvs == "320921" {
  37520. 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 +
  37521. "&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
  37522. fmt.Println(api)
  37523. } else {
  37524. 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 +
  37525. "&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
  37526. }
  37527. resp, requestErr := http.Get(api)
  37528. if requestErr != nil {
  37529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37530. return ""
  37531. }
  37532. body, ioErr := ioutil.ReadAll(resp.Body)
  37533. if ioErr != nil {
  37534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37536. return ""
  37537. }
  37538. var respJSON map[string]interface{}
  37539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37542. return ""
  37543. }
  37544. var status string
  37545. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37546. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37547. var res ResultTwo //1101结果
  37548. var res10265 ResultTwo10265 //1101结果
  37549. if status == "0" { //读卡成功
  37550. var card_info string //卡信息
  37551. var busi_card_info string
  37552. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37553. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37554. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37555. fmt.Println(card_info)
  37556. fmt.Println(busi_card_info)
  37557. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37558. result, _ := json.Marshal(respJSON)
  37559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37560. utils.ErrorLog("解析失败:%v", err)
  37561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37562. return ""
  37563. }
  37564. res.ErrMsg = res10265.ErrMsg
  37565. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37566. res.Infcode = infocode
  37567. res.Output = res10265.Output
  37568. res.InfRefmsgid = res10265.InfRefmsgid
  37569. if res.Infcode == 0 {
  37570. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37571. if err == gorm.ErrRecordNotFound {
  37572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37573. return ""
  37574. } else if err != nil {
  37575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37576. return ""
  37577. } else {
  37578. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37579. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37580. infoStr := string(Iinfos)
  37581. idetinfoStr := string(Idetinfos)
  37582. psn := &models.HisPsn{
  37583. PsnNo: res.Output.Baseinfo.PsnNo,
  37584. PatientId: patient.ID,
  37585. Certno: res.Output.Baseinfo.Certno,
  37586. Gend: res.Output.Baseinfo.Gend,
  37587. Naty: res.Output.Baseinfo.Naty,
  37588. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37589. PsnName: res.Output.Baseinfo.PsnName,
  37590. Idetinfo: idetinfoStr,
  37591. Insuinfo: infoStr,
  37592. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37593. CardInfo: card_info,
  37594. VerifyNumber: token,
  37595. }
  37596. service.CreateHisPsn(psn)
  37597. return token
  37598. }
  37599. }
  37600. } else {
  37601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37602. return ""
  37603. }
  37604. } else { //读卡失败
  37605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37606. return ""
  37607. }
  37608. return token
  37609. }
  37610. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37611. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37612. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37613. var token string
  37614. var api string
  37615. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37616. "&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
  37617. fmt.Println(api)
  37618. resp, requestErr := http.Get(api)
  37619. if requestErr != nil {
  37620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37621. return ""
  37622. }
  37623. body, ioErr := ioutil.ReadAll(resp.Body)
  37624. if ioErr != nil {
  37625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37627. return ""
  37628. }
  37629. var respJSON map[string]interface{}
  37630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37633. return ""
  37634. }
  37635. var status string
  37636. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37637. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37638. var res ResultTwo //1101结果
  37639. if status == "1" { //读卡成功
  37640. var card_info string //卡信息
  37641. var busi_card_info string
  37642. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37643. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37644. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37645. fmt.Println(card_info)
  37646. fmt.Println(busi_card_info)
  37647. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37648. result, _ := json.Marshal(respJSON)
  37649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37650. utils.ErrorLog("解析失败:%v", err)
  37651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37652. return ""
  37653. }
  37654. if res.Infcode == 0 {
  37655. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37656. if err == gorm.ErrRecordNotFound {
  37657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37658. return ""
  37659. } else if err != nil {
  37660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37661. return ""
  37662. } else {
  37663. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37664. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37665. infoStr := string(Iinfos)
  37666. idetinfoStr := string(Idetinfos)
  37667. psn := &models.HisPsn{
  37668. PsnNo: res.Output.Baseinfo.PsnNo,
  37669. PatientId: patient.ID,
  37670. Certno: res.Output.Baseinfo.Certno,
  37671. Gend: res.Output.Baseinfo.Gend,
  37672. Naty: res.Output.Baseinfo.Naty,
  37673. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37674. PsnName: res.Output.Baseinfo.PsnName,
  37675. Idetinfo: idetinfoStr,
  37676. Insuinfo: infoStr,
  37677. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37678. CardInfo: card_info,
  37679. VerifyNumber: token,
  37680. }
  37681. service.CreateHisPsn(psn)
  37682. return token
  37683. }
  37684. }
  37685. } else {
  37686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37687. return ""
  37688. }
  37689. return token
  37690. }
  37691. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37692. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37693. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37694. var token string
  37695. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37696. var api string
  37697. if miConfig.MdtrtareaAdmvs == "320921" {
  37698. 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 +
  37699. "&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
  37700. fmt.Println(api)
  37701. } else {
  37702. 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 +
  37703. "&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
  37704. }
  37705. resp, requestErr := http.Get(api)
  37706. if requestErr != nil {
  37707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37708. return ""
  37709. }
  37710. body, ioErr := ioutil.ReadAll(resp.Body)
  37711. if ioErr != nil {
  37712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37714. return ""
  37715. }
  37716. var respJSON map[string]interface{}
  37717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37720. return ""
  37721. }
  37722. var status string
  37723. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37724. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37725. var res ResultTwo //1101结果
  37726. var res10265 ResultTwo10265 //1101结果
  37727. if status == "0" { //读卡成功
  37728. var card_info string //卡信息
  37729. var busi_card_info string
  37730. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37731. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37732. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37733. fmt.Println(card_info)
  37734. fmt.Println(busi_card_info)
  37735. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37736. result, _ := json.Marshal(respJSON)
  37737. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37738. utils.ErrorLog("解析失败:%v", err)
  37739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37740. return ""
  37741. }
  37742. res.ErrMsg = res10265.ErrMsg
  37743. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37744. res.Infcode = infocode
  37745. res.Output = res10265.Output
  37746. res.InfRefmsgid = res10265.InfRefmsgid
  37747. if res.Infcode == 0 {
  37748. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37749. if err == gorm.ErrRecordNotFound {
  37750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37751. return ""
  37752. } else if err != nil {
  37753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37754. return ""
  37755. } else {
  37756. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37757. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37758. infoStr := string(Iinfos)
  37759. idetinfoStr := string(Idetinfos)
  37760. psn := &models.HisPsn{
  37761. PsnNo: res.Output.Baseinfo.PsnNo,
  37762. PatientId: patient.ID,
  37763. Certno: res.Output.Baseinfo.Certno,
  37764. Gend: res.Output.Baseinfo.Gend,
  37765. Naty: res.Output.Baseinfo.Naty,
  37766. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37767. PsnName: res.Output.Baseinfo.PsnName,
  37768. Idetinfo: idetinfoStr,
  37769. Insuinfo: infoStr,
  37770. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37771. CardInfo: card_info,
  37772. VerifyNumber: token,
  37773. }
  37774. service.CreateHisPsn(psn)
  37775. return token
  37776. }
  37777. }
  37778. } else {
  37779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37780. return ""
  37781. }
  37782. } else { //读卡失败
  37783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37784. return ""
  37785. }
  37786. return token
  37787. }
  37788. func DeleteExtraSpaceTwo(s string) string {
  37789. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37790. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37791. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37792. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37793. s2 := make([]byte, len(s1)) //定义字符数组切片
  37794. copy(s2, s1) //将字符串复制到切片
  37795. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37796. for len(spc_index) > 0 { //找到适配项
  37797. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37798. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37799. }
  37800. return string(s2)
  37801. }
  37802. func Remove0000(s string) string {
  37803. str := make([]rune, 0, len(s))
  37804. for _, v := range []rune(s) {
  37805. if v == 0 {
  37806. continue
  37807. }
  37808. str = append(str, v)
  37809. }
  37810. return string(str)
  37811. }
  37812. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37813. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37814. readCard := DllDef.MustFindProc("EcQuery")
  37815. pCardInfo := make([]byte, 8192)
  37816. pBusiCardInfo := make([]byte, 8192)
  37817. data := make(map[string]interface{})
  37818. //pData := make(map[string]interface{})
  37819. inputData := make(map[string]interface{})
  37820. inputData["orgId"] = code
  37821. inputData["businessType"] = "01101"
  37822. inputData["operatorId"] = operator_id
  37823. inputData["operatorName"] = operator_name
  37824. inputData["officeId"] = "001"
  37825. inputData["officeName"] = "血透室"
  37826. //
  37827. data["data"] = inputData
  37828. data["transType"] = "ec.query"
  37829. data["orgId"] = code
  37830. bytesData, _ := json.Marshal(data)
  37831. pCardInfo = bytesData
  37832. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37833. fmt.Println(ret2)
  37834. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37835. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37836. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37837. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37838. if ret2 != 0 {
  37839. return "", ""
  37840. }
  37841. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37842. }
  37843. func DeleteExtraSpace(s string) string {
  37844. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37845. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37846. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37847. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37848. s2 := make([]byte, len(s1)) //定义字符数组切片
  37849. copy(s2, s1) //将字符串复制到切片
  37850. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37851. for len(spc_index) > 0 { //找到适配项
  37852. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37853. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37854. }
  37855. return string(s2)
  37856. }
  37857. // 对账
  37858. func (c *HisApiController) Post3202() {
  37859. start_time := c.GetString("start_time")
  37860. end_time := c.GetString("end_time")
  37861. //insutype := c.GetString("insutype")
  37862. clr_type := c.GetString("clr_type")
  37863. clr_org := c.GetString("clr_optins")
  37864. admin_user_id, _ := c.GetInt64("admin_user_id")
  37865. adminUser := c.GetAdminUserInfo()
  37866. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37867. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37868. if len(clr_org) == 0 {
  37869. clr_org = miConfig.MdtrtareaAdmvs
  37870. }
  37871. timeLayout := "2006-01-02"
  37872. loc, _ := time.LoadLocation("Local")
  37873. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37874. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37875. var orders []*models.HisOrder
  37876. if clr_org == "421300" {
  37877. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37878. } else if clr_org == "420902" {
  37879. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37880. } else {
  37881. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37882. }
  37883. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37884. //fixmedins_setl_cnt := int64(len(orders))
  37885. var medfee_sumamt float64
  37886. var acct_pay float64
  37887. var fund_pay_sumamt float64
  37888. for _, item := range orders {
  37889. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37890. acct_pay = acct_pay + item.AcctPay
  37891. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37892. }
  37893. //var medfee_sumamt_two float64
  37894. //var acct_pay_two float64
  37895. //var fund_pay_sumamt_two float64
  37896. //for _, item := range orders_two {
  37897. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37898. // acct_pay_two = acct_pay_two + item.AcctPay
  37899. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37900. //}
  37901. //var user_name string
  37902. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37903. //if role.ID == 0 {
  37904. // user_name = "xxx"
  37905. //} else {
  37906. // user_name = role.UserName
  37907. //}
  37908. var res ResultSix
  37909. if config.IsOpen == 1 {
  37910. var bps []*models.BusinessParamsTwo
  37911. var bp models.BusinessParamsTwo
  37912. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37913. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37914. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37915. bp.MedfeeSumamt = medfee_sumamt_str
  37916. bp.AcctPay = acct_pay_str
  37917. bp.FundPaySumamt = fund_pay_sumamt_str
  37918. bp.Insutype = ""
  37919. bp.StmtBegndate = start_time
  37920. bp.ClrType = clr_type
  37921. bp.SetlOptins = clr_org
  37922. bp.StmtEnddate = end_time
  37923. bps = append(bps, &bp)
  37924. data := make(map[string]interface{})
  37925. data["bps"] = bps
  37926. data["org_name"] = miConfig.OrgName
  37927. data["doctor"] = role.UserName
  37928. data["fixmedins_code"] = miConfig.Code
  37929. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37930. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37931. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37932. if miConfig.MdtrtareaAdmvs == "421300" {
  37933. client := &http.Client{}
  37934. bytesData, _ := json.Marshal(data)
  37935. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37936. resp, _ := client.Do(req)
  37937. defer resp.Body.Close()
  37938. body, ioErr := ioutil.ReadAll(resp.Body)
  37939. if ioErr != nil {
  37940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37942. return
  37943. }
  37944. var respJSON map[string]interface{}
  37945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37948. return
  37949. }
  37950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37951. userJSONBytes, _ := json.Marshal(respJSON)
  37952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37953. utils.ErrorLog("解析失败:%v", err)
  37954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37955. return
  37956. }
  37957. }
  37958. if miConfig.MdtrtareaAdmvs == "420200" {
  37959. client := &http.Client{}
  37960. bytesData, _ := json.Marshal(data)
  37961. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37962. resp, _ := client.Do(req)
  37963. defer resp.Body.Close()
  37964. body, ioErr := ioutil.ReadAll(resp.Body)
  37965. if ioErr != nil {
  37966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37968. return
  37969. }
  37970. var respJSON map[string]interface{}
  37971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37974. return
  37975. }
  37976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37977. userJSONBytes, _ := json.Marshal(respJSON)
  37978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37979. utils.ErrorLog("解析失败:%v", err)
  37980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37981. return
  37982. }
  37983. }
  37984. if miConfig.MdtrtareaAdmvs == "421182" {
  37985. client := &http.Client{}
  37986. bytesData, _ := json.Marshal(data)
  37987. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37988. resp, _ := client.Do(req)
  37989. defer resp.Body.Close()
  37990. body, ioErr := ioutil.ReadAll(resp.Body)
  37991. if ioErr != nil {
  37992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37994. return
  37995. }
  37996. var respJSON map[string]interface{}
  37997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38000. return
  38001. }
  38002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38003. userJSONBytes, _ := json.Marshal(respJSON)
  38004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38005. utils.ErrorLog("解析失败:%v", err)
  38006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38007. return
  38008. }
  38009. }
  38010. if miConfig.MdtrtareaAdmvs == "420902" {
  38011. client := &http.Client{}
  38012. bytesData, _ := json.Marshal(data)
  38013. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38014. resp, _ := client.Do(req)
  38015. defer resp.Body.Close()
  38016. body, ioErr := ioutil.ReadAll(resp.Body)
  38017. if ioErr != nil {
  38018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38020. return
  38021. }
  38022. var respJSON map[string]interface{}
  38023. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38026. return
  38027. }
  38028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38029. userJSONBytes, _ := json.Marshal(respJSON)
  38030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38031. utils.ErrorLog("解析失败:%v", err)
  38032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38033. return
  38034. }
  38035. }
  38036. if res.Infcode == 0 {
  38037. c.ServeSuccessJSON(map[string]interface{}{
  38038. "msg": "发起成功",
  38039. })
  38040. } else {
  38041. c.ServeSuccessJSON(map[string]interface{}{
  38042. "failed_code": -10,
  38043. "msg": res.ErrMsg,
  38044. })
  38045. }
  38046. }
  38047. }
  38048. func (c *HisApiController) Post3204a() {
  38049. start_time := c.GetString("start_time")
  38050. end_time := c.GetString("end_time")
  38051. //insutype := c.GetString("insutype")
  38052. clr_type := c.GetString("clr_type")
  38053. clr_org := c.GetString("clr_optins")
  38054. admin_user_id, _ := c.GetInt64("admin_user_id")
  38055. adminUser := c.GetAdminUserInfo()
  38056. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38057. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38058. if len(clr_org) == 0 {
  38059. clr_org = miConfig.MdtrtareaAdmvs
  38060. }
  38061. timeLayout := "2006-01-02"
  38062. loc, _ := time.LoadLocation("Local")
  38063. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38064. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38065. var orders []*models.HisOrder
  38066. if clr_org == "421300" {
  38067. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38068. } else if clr_org == "420902" {
  38069. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38070. } else {
  38071. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38072. }
  38073. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38074. //fixmedins_setl_cnt := int64(len(orders))
  38075. var medfee_sumamt float64
  38076. var acct_pay float64
  38077. var fund_pay_sumamt float64
  38078. for _, item := range orders {
  38079. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38080. acct_pay = acct_pay + item.AcctPay
  38081. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38082. }
  38083. //var medfee_sumamt_two float64
  38084. //var acct_pay_two float64
  38085. //var fund_pay_sumamt_two float64
  38086. //for _, item := range orders_two {
  38087. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38088. // acct_pay_two = acct_pay_two + item.AcctPay
  38089. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38090. //}
  38091. //var user_name string
  38092. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38093. //if role.ID == 0 {
  38094. // user_name = "xxx"
  38095. //} else {
  38096. // user_name = role.UserName
  38097. //}
  38098. var res ResultSix
  38099. if config.IsOpen == 1 {
  38100. var bps []*models.BusinessParamsTwo
  38101. var bp models.BusinessParamsTwo
  38102. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38103. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38104. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38105. bp.MedfeeSumamt = medfee_sumamt_str
  38106. bp.AcctPay = acct_pay_str
  38107. bp.FundPaySumamt = fund_pay_sumamt_str
  38108. bp.Insutype = ""
  38109. bp.StmtBegndate = start_time
  38110. bp.ClrType = clr_type
  38111. bp.SetlOptins = clr_org
  38112. bp.StmtEnddate = end_time
  38113. bps = append(bps, &bp)
  38114. data := make(map[string]interface{})
  38115. data["bps"] = bps
  38116. data["org_name"] = miConfig.OrgName
  38117. data["doctor"] = role.UserName
  38118. data["fixmedins_code"] = miConfig.Code
  38119. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38120. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38121. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38122. if miConfig.MdtrtareaAdmvs == "421300" {
  38123. client := &http.Client{}
  38124. bytesData, _ := json.Marshal(data)
  38125. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38126. resp, _ := client.Do(req)
  38127. defer resp.Body.Close()
  38128. body, ioErr := ioutil.ReadAll(resp.Body)
  38129. if ioErr != nil {
  38130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38132. return
  38133. }
  38134. var respJSON map[string]interface{}
  38135. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38138. return
  38139. }
  38140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38141. userJSONBytes, _ := json.Marshal(respJSON)
  38142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38143. utils.ErrorLog("解析失败:%v", err)
  38144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38145. return
  38146. }
  38147. }
  38148. if miConfig.MdtrtareaAdmvs == "420200" {
  38149. client := &http.Client{}
  38150. bytesData, _ := json.Marshal(data)
  38151. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38152. resp, _ := client.Do(req)
  38153. defer resp.Body.Close()
  38154. body, ioErr := ioutil.ReadAll(resp.Body)
  38155. if ioErr != nil {
  38156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38158. return
  38159. }
  38160. var respJSON map[string]interface{}
  38161. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38164. return
  38165. }
  38166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38167. userJSONBytes, _ := json.Marshal(respJSON)
  38168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38169. utils.ErrorLog("解析失败:%v", err)
  38170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38171. return
  38172. }
  38173. }
  38174. if miConfig.MdtrtareaAdmvs == "421182" {
  38175. client := &http.Client{}
  38176. bytesData, _ := json.Marshal(data)
  38177. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38178. resp, _ := client.Do(req)
  38179. defer resp.Body.Close()
  38180. body, ioErr := ioutil.ReadAll(resp.Body)
  38181. if ioErr != nil {
  38182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38184. return
  38185. }
  38186. var respJSON map[string]interface{}
  38187. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38190. return
  38191. }
  38192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38193. userJSONBytes, _ := json.Marshal(respJSON)
  38194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38195. utils.ErrorLog("解析失败:%v", err)
  38196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38197. return
  38198. }
  38199. }
  38200. if miConfig.MdtrtareaAdmvs == "420902" {
  38201. client := &http.Client{}
  38202. bytesData, _ := json.Marshal(data)
  38203. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38204. resp, _ := client.Do(req)
  38205. defer resp.Body.Close()
  38206. body, ioErr := ioutil.ReadAll(resp.Body)
  38207. if ioErr != nil {
  38208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38210. return
  38211. }
  38212. var respJSON map[string]interface{}
  38213. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38216. return
  38217. }
  38218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38219. userJSONBytes, _ := json.Marshal(respJSON)
  38220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38221. utils.ErrorLog("解析失败:%v", err)
  38222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38223. return
  38224. }
  38225. }
  38226. if res.Infcode == 0 {
  38227. c.ServeSuccessJSON(map[string]interface{}{
  38228. "msg": "撤销成功",
  38229. })
  38230. } else {
  38231. c.ServeSuccessJSON(map[string]interface{}{
  38232. "failed_code": -10,
  38233. "msg": res.ErrMsg,
  38234. })
  38235. }
  38236. }
  38237. }
  38238. func (c *HisApiController) Post3204() {
  38239. admin_user_id, _ := c.GetInt64("admin_user_id")
  38240. id := c.GetString("id")
  38241. adminUser := c.GetAdminUserInfo()
  38242. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38243. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38244. //clr_org := miConfig.MdtrtareaAdmvs
  38245. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38246. var res ResultSix
  38247. if config.IsOpen == 1 {
  38248. data := make(map[string]interface{})
  38249. data["id"] = id
  38250. data["org_name"] = miConfig.OrgName
  38251. data["doctor"] = role.UserName
  38252. data["fixmedins_code"] = miConfig.Code
  38253. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38254. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38255. client := &http.Client{}
  38256. bytesData, _ := json.Marshal(data)
  38257. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38258. resp, _ := client.Do(req)
  38259. defer resp.Body.Close()
  38260. body, ioErr := ioutil.ReadAll(resp.Body)
  38261. if ioErr != nil {
  38262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38264. return
  38265. }
  38266. var respJSON map[string]interface{}
  38267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38270. return
  38271. }
  38272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38273. userJSONBytes, _ := json.Marshal(respJSON)
  38274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38275. utils.ErrorLog("解析失败:%v", err)
  38276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38277. return
  38278. }
  38279. if res.Infcode == 0 {
  38280. c.ServeSuccessJSON(map[string]interface{}{
  38281. "msg": "发起成功",
  38282. })
  38283. } else {
  38284. c.ServeSuccessJSON(map[string]interface{}{
  38285. "failed_code": -10,
  38286. "msg": res.ErrMsg,
  38287. })
  38288. }
  38289. }
  38290. }
  38291. func (c *HisApiController) Post8404() {
  38292. admin_user_id, _ := c.GetInt64("admin_user_id")
  38293. month := c.GetString("month")
  38294. adminUser := c.GetAdminUserInfo()
  38295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38296. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38297. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38298. var res ResultSix
  38299. if config.IsOpen == 1 {
  38300. data := make(map[string]interface{})
  38301. data["month"] = month
  38302. data["org_name"] = miConfig.OrgName
  38303. data["doctor"] = role.UserName
  38304. data["fixmedins_code"] = miConfig.Code
  38305. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38306. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38307. client := &http.Client{}
  38308. bytesData, _ := json.Marshal(data)
  38309. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38310. resp, _ := client.Do(req)
  38311. defer resp.Body.Close()
  38312. body, ioErr := ioutil.ReadAll(resp.Body)
  38313. if ioErr != nil {
  38314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38316. return
  38317. }
  38318. var respJSON map[string]interface{}
  38319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38322. return
  38323. }
  38324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38325. userJSONBytes, _ := json.Marshal(respJSON)
  38326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38327. utils.ErrorLog("解析失败:%v", err)
  38328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38329. return
  38330. }
  38331. if res.Infcode == 0 {
  38332. c.ServeSuccessJSON(map[string]interface{}{
  38333. "msg": "查询成功",
  38334. })
  38335. } else {
  38336. c.ServeSuccessJSON(map[string]interface{}{
  38337. "failed_code": -10,
  38338. "msg": res.ErrMsg,
  38339. })
  38340. }
  38341. }
  38342. }
  38343. func (c *HisApiController) Post3202b() {
  38344. start_time := c.GetString("start_time")
  38345. end_time := c.GetString("end_time")
  38346. //insutype := c.GetString("insutype")
  38347. clr_type := c.GetString("clr_type")
  38348. clr_org := c.GetString("clr_optins")
  38349. admin_user_id, _ := c.GetInt64("admin_user_id")
  38350. adminUser := c.GetAdminUserInfo()
  38351. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38352. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38353. if len(clr_org) == 0 {
  38354. clr_org = miConfig.MdtrtareaAdmvs
  38355. }
  38356. timeLayout := "2006-01-02"
  38357. loc, _ := time.LoadLocation("Local")
  38358. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38359. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38360. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38361. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38362. //fixmedins_setl_cnt := int64(len(orders))
  38363. var medfee_sumamt float64
  38364. var acct_pay float64
  38365. var fund_pay_sumamt float64
  38366. for _, item := range orders {
  38367. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38368. acct_pay = acct_pay + item.AcctPay
  38369. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38370. }
  38371. //var medfee_sumamt_two float64
  38372. //var acct_pay_two float64
  38373. //var fund_pay_sumamt_two float64
  38374. //for _, item := range orders_two {
  38375. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38376. // acct_pay_two = acct_pay_two + item.AcctPay
  38377. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38378. //}
  38379. //var user_name string
  38380. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38381. //if role.ID == 0 {
  38382. // user_name = "xxx"
  38383. //} else {
  38384. // user_name = role.UserName
  38385. //}
  38386. var res ResultSix
  38387. if config.IsOpen == 1 {
  38388. var bps []*models.BusinessParamsTwo
  38389. var bp models.BusinessParamsTwo
  38390. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38391. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38392. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38393. bp.MedfeeSumamt = medfee_sumamt_str
  38394. bp.AcctPay = acct_pay_str
  38395. bp.FundPaySumamt = fund_pay_sumamt_str
  38396. bp.Insutype = "390"
  38397. bp.StmtBegndate = start_time
  38398. bp.ClrType = clr_type
  38399. bp.SetlOptins = clr_org
  38400. bp.StmtEnddate = end_time
  38401. bps = append(bps, &bp)
  38402. data := make(map[string]interface{})
  38403. data["bps"] = bps
  38404. data["org_name"] = miConfig.OrgName
  38405. data["doctor"] = role.UserName
  38406. data["fixmedins_code"] = miConfig.Code
  38407. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38408. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38409. if miConfig.MdtrtareaAdmvs == "421300" {
  38410. client := &http.Client{}
  38411. bytesData, _ := json.Marshal(data)
  38412. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38413. resp, _ := client.Do(req)
  38414. defer resp.Body.Close()
  38415. body, ioErr := ioutil.ReadAll(resp.Body)
  38416. if ioErr != nil {
  38417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38419. return
  38420. }
  38421. var respJSON map[string]interface{}
  38422. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38425. return
  38426. }
  38427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38428. userJSONBytes, _ := json.Marshal(respJSON)
  38429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38430. utils.ErrorLog("解析失败:%v", err)
  38431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38432. return
  38433. }
  38434. }
  38435. if miConfig.MdtrtareaAdmvs == "420200" {
  38436. client := &http.Client{}
  38437. bytesData, _ := json.Marshal(data)
  38438. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38439. resp, _ := client.Do(req)
  38440. defer resp.Body.Close()
  38441. body, ioErr := ioutil.ReadAll(resp.Body)
  38442. if ioErr != nil {
  38443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38445. return
  38446. }
  38447. var respJSON map[string]interface{}
  38448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38451. return
  38452. }
  38453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38454. userJSONBytes, _ := json.Marshal(respJSON)
  38455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38456. utils.ErrorLog("解析失败:%v", err)
  38457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38458. return
  38459. }
  38460. }
  38461. if miConfig.MdtrtareaAdmvs == "421182" {
  38462. client := &http.Client{}
  38463. bytesData, _ := json.Marshal(data)
  38464. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38465. resp, _ := client.Do(req)
  38466. defer resp.Body.Close()
  38467. body, ioErr := ioutil.ReadAll(resp.Body)
  38468. if ioErr != nil {
  38469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38471. return
  38472. }
  38473. var respJSON map[string]interface{}
  38474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38477. return
  38478. }
  38479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38480. userJSONBytes, _ := json.Marshal(respJSON)
  38481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38482. utils.ErrorLog("解析失败:%v", err)
  38483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38484. return
  38485. }
  38486. }
  38487. if res.Infcode == 0 {
  38488. c.ServeSuccessJSON(map[string]interface{}{
  38489. "msg": "发起成功",
  38490. })
  38491. } else {
  38492. c.ServeSuccessJSON(map[string]interface{}{
  38493. "failed_code": -10,
  38494. "msg": res.ErrMsg,
  38495. })
  38496. }
  38497. }
  38498. }
  38499. func (c *HisApiController) Post1608() {
  38500. start_time := c.GetString("start_time")
  38501. end_time := c.GetString("end_time")
  38502. admin_user_id, _ := c.GetInt64("admin_user_id")
  38503. adminUser := c.GetAdminUserInfo()
  38504. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38505. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38506. timeLayout := "2006-01-02"
  38507. loc, _ := time.LoadLocation("Local")
  38508. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38509. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38510. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38511. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38512. fixmedins_setl_cnt := int64(len(orders))
  38513. var medfee_sumamt float64
  38514. var func_smamt float64
  38515. for _, item := range orders {
  38516. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38517. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38518. }
  38519. times := strings.Split(start_time, "-")
  38520. time_tows := strings.Split(end_time, "-")
  38521. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38522. var res ResultSix
  38523. if config.IsOpen == 1 {
  38524. //var bps []*models.BusinessParamsTwo
  38525. //var bp models.BusinessParamsTwo
  38526. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38527. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38528. data := make(map[string]interface{})
  38529. data["org_name"] = miConfig.OrgName
  38530. data["doctor"] = role.UserName
  38531. data["func_smamt"] = func_smamt_str
  38532. data["fixmedins_code"] = miConfig.Code
  38533. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38534. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38535. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38536. data["medfee_sumamt"] = medfee_sumamt_str
  38537. data["start_time"] = times[0] + times[1] + times[2]
  38538. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38539. if miConfig.MdtrtareaAdmvs == "421300" {
  38540. client := &http.Client{}
  38541. bytesData, _ := json.Marshal(data)
  38542. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38543. resp, _ := client.Do(req)
  38544. defer resp.Body.Close()
  38545. body, ioErr := ioutil.ReadAll(resp.Body)
  38546. if ioErr != nil {
  38547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38549. return
  38550. }
  38551. var respJSON map[string]interface{}
  38552. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38555. return
  38556. }
  38557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38558. userJSONBytes, _ := json.Marshal(respJSON)
  38559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38560. utils.ErrorLog("解析失败:%v", err)
  38561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38562. return
  38563. }
  38564. }
  38565. if miConfig.MdtrtareaAdmvs == "420200" {
  38566. client := &http.Client{}
  38567. bytesData, _ := json.Marshal(data)
  38568. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38569. resp, _ := client.Do(req)
  38570. defer resp.Body.Close()
  38571. body, ioErr := ioutil.ReadAll(resp.Body)
  38572. if ioErr != nil {
  38573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38575. return
  38576. }
  38577. var respJSON map[string]interface{}
  38578. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38581. return
  38582. }
  38583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38584. userJSONBytes, _ := json.Marshal(respJSON)
  38585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38586. utils.ErrorLog("解析失败:%v", err)
  38587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38588. return
  38589. }
  38590. }
  38591. if miConfig.MdtrtareaAdmvs == "421182" {
  38592. client := &http.Client{}
  38593. bytesData, _ := json.Marshal(data)
  38594. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38595. resp, _ := client.Do(req)
  38596. defer resp.Body.Close()
  38597. body, ioErr := ioutil.ReadAll(resp.Body)
  38598. if ioErr != nil {
  38599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38601. return
  38602. }
  38603. var respJSON map[string]interface{}
  38604. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38607. return
  38608. }
  38609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38610. userJSONBytes, _ := json.Marshal(respJSON)
  38611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38612. utils.ErrorLog("解析失败:%v", err)
  38613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38614. return
  38615. }
  38616. }
  38617. if res.Infcode == 0 {
  38618. c.ServeSuccessJSON(map[string]interface{}{
  38619. "msg": "发起成功",
  38620. })
  38621. } else {
  38622. c.ServeSuccessJSON(map[string]interface{}{
  38623. "failed_code": -10,
  38624. "msg": res.ErrMsg,
  38625. })
  38626. }
  38627. }
  38628. }
  38629. // 5.11.1.1【5262】结算信息按时间段查询
  38630. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38631. admin_user_id, _ := c.GetInt64("admin_user_id")
  38632. adminUser := c.GetAdminUserInfo()
  38633. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38634. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38635. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38636. var res Result5262
  38637. if config.IsOpen == 1 {
  38638. if miConfig.MdtrtareaAdmvs == "421300" {
  38639. data := make(map[string]interface{})
  38640. data["bps"] = bp
  38641. data["org_name"] = miConfig.OrgName
  38642. data["doctor"] = role.UserName
  38643. data["fixmedins_code"] = miConfig.Code
  38644. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38645. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38646. data["page"] = strconv.FormatInt(page, 10)
  38647. data["limit"] = strconv.FormatInt(limit, 10)
  38648. fmt.Println(data)
  38649. client := &http.Client{}
  38650. bytesData, _ := json.Marshal(data)
  38651. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38652. resp, _ := client.Do(req)
  38653. defer resp.Body.Close()
  38654. body, ioErr := ioutil.ReadAll(resp.Body)
  38655. if ioErr != nil {
  38656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38658. return
  38659. }
  38660. var respJSON map[string]interface{}
  38661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38664. return
  38665. }
  38666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38667. userJSONBytes, _ := json.Marshal(respJSON)
  38668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38669. utils.ErrorLog("解析失败:%v", err)
  38670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38671. return
  38672. }
  38673. }
  38674. if miConfig.MdtrtareaAdmvs == "420200" {
  38675. data := make(map[string]interface{})
  38676. data["bps"] = bp
  38677. data["org_name"] = miConfig.OrgName
  38678. data["doctor"] = role.UserName
  38679. data["fixmedins_code"] = miConfig.Code
  38680. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38681. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38682. data["page"] = strconv.FormatInt(page, 10)
  38683. data["limit"] = strconv.FormatInt(limit, 10)
  38684. fmt.Println(data)
  38685. client := &http.Client{}
  38686. bytesData, _ := json.Marshal(data)
  38687. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38688. resp, _ := client.Do(req)
  38689. defer resp.Body.Close()
  38690. body, ioErr := ioutil.ReadAll(resp.Body)
  38691. if ioErr != nil {
  38692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38694. return
  38695. }
  38696. var respJSON map[string]interface{}
  38697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38700. return
  38701. }
  38702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38703. userJSONBytes, _ := json.Marshal(respJSON)
  38704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38705. utils.ErrorLog("解析失败:%v", err)
  38706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38707. return
  38708. }
  38709. }
  38710. if miConfig.MdtrtareaAdmvs == "421182" {
  38711. data := make(map[string]interface{})
  38712. data["bps"] = bp
  38713. data["org_name"] = miConfig.OrgName
  38714. data["doctor"] = role.UserName
  38715. data["fixmedins_code"] = miConfig.Code
  38716. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38717. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38718. data["page"] = strconv.FormatInt(page, 10)
  38719. data["limit"] = strconv.FormatInt(limit, 10)
  38720. fmt.Println(data)
  38721. client := &http.Client{}
  38722. bytesData, _ := json.Marshal(data)
  38723. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38724. resp, _ := client.Do(req)
  38725. defer resp.Body.Close()
  38726. body, ioErr := ioutil.ReadAll(resp.Body)
  38727. if ioErr != nil {
  38728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38730. return
  38731. }
  38732. var respJSON map[string]interface{}
  38733. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38736. return
  38737. }
  38738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38739. userJSONBytes, _ := json.Marshal(respJSON)
  38740. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38741. utils.ErrorLog("解析失败:%v", err)
  38742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38743. return
  38744. }
  38745. }
  38746. if miConfig.MdtrtareaAdmvs == "420902" {
  38747. data := make(map[string]interface{})
  38748. data["bps"] = bp
  38749. data["org_name"] = miConfig.OrgName
  38750. data["doctor"] = role.UserName
  38751. data["fixmedins_code"] = miConfig.Code
  38752. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38753. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38754. data["page"] = strconv.FormatInt(page, 10)
  38755. data["limit"] = strconv.FormatInt(limit, 10)
  38756. fmt.Println(data)
  38757. client := &http.Client{}
  38758. bytesData, _ := json.Marshal(data)
  38759. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38760. resp, _ := client.Do(req)
  38761. defer resp.Body.Close()
  38762. body, ioErr := ioutil.ReadAll(resp.Body)
  38763. if ioErr != nil {
  38764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38766. return
  38767. }
  38768. var respJSON map[string]interface{}
  38769. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38772. return
  38773. }
  38774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38775. userJSONBytes, _ := json.Marshal(respJSON)
  38776. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38777. utils.ErrorLog("解析失败:%v", err)
  38778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38779. return
  38780. }
  38781. }
  38782. if res.Infcode == 0 {
  38783. c.ServeSuccessJSON(map[string]interface{}{
  38784. "order": res.Output.Result,
  38785. "total": res.Output.PageInfo.RecordCounts,
  38786. })
  38787. } else {
  38788. c.ServeSuccessJSON(map[string]interface{}{
  38789. "failed_code": -10,
  38790. "msg": res.ErrMsg,
  38791. })
  38792. }
  38793. }
  38794. }
  38795. // 5.11.1.2【5267】异地结算信息时间段查询
  38796. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38797. admin_user_id, _ := c.GetInt64("admin_user_id")
  38798. adminUser := c.GetAdminUserInfo()
  38799. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38800. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38801. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38802. var res Result5267
  38803. if config.IsOpen == 1 {
  38804. if miConfig.MdtrtareaAdmvs == "421300" {
  38805. data := make(map[string]interface{})
  38806. data["bps"] = bp
  38807. data["org_name"] = miConfig.OrgName
  38808. data["doctor"] = role.UserName
  38809. data["fixmedins_code"] = miConfig.Code
  38810. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38811. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38812. data["page"] = page
  38813. data["limit"] = limit
  38814. fmt.Println(data)
  38815. client := &http.Client{}
  38816. bytesData, _ := json.Marshal(data)
  38817. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38818. resp, _ := client.Do(req)
  38819. defer resp.Body.Close()
  38820. body, ioErr := ioutil.ReadAll(resp.Body)
  38821. if ioErr != nil {
  38822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38824. return
  38825. }
  38826. var respJSON map[string]interface{}
  38827. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38830. return
  38831. }
  38832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38833. userJSONBytes, _ := json.Marshal(respJSON)
  38834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38835. utils.ErrorLog("解析失败:%v", err)
  38836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38837. return
  38838. }
  38839. }
  38840. if miConfig.MdtrtareaAdmvs == "420200" {
  38841. data := make(map[string]interface{})
  38842. data["bps"] = bp
  38843. data["org_name"] = miConfig.OrgName
  38844. data["doctor"] = role.UserName
  38845. data["fixmedins_code"] = miConfig.Code
  38846. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38847. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38848. data["page"] = page
  38849. data["limit"] = limit
  38850. fmt.Println(data)
  38851. client := &http.Client{}
  38852. bytesData, _ := json.Marshal(data)
  38853. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38854. resp, _ := client.Do(req)
  38855. defer resp.Body.Close()
  38856. body, ioErr := ioutil.ReadAll(resp.Body)
  38857. if ioErr != nil {
  38858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38860. return
  38861. }
  38862. var respJSON map[string]interface{}
  38863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38866. return
  38867. }
  38868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38869. userJSONBytes, _ := json.Marshal(respJSON)
  38870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38871. utils.ErrorLog("解析失败:%v", err)
  38872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38873. return
  38874. }
  38875. }
  38876. if miConfig.MdtrtareaAdmvs == "421182" {
  38877. data := make(map[string]interface{})
  38878. data["bps"] = bp
  38879. data["org_name"] = miConfig.OrgName
  38880. data["doctor"] = role.UserName
  38881. data["fixmedins_code"] = miConfig.Code
  38882. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38884. data["page"] = page
  38885. data["limit"] = limit
  38886. fmt.Println(data)
  38887. client := &http.Client{}
  38888. bytesData, _ := json.Marshal(data)
  38889. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38890. resp, _ := client.Do(req)
  38891. defer resp.Body.Close()
  38892. body, ioErr := ioutil.ReadAll(resp.Body)
  38893. if ioErr != nil {
  38894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38896. return
  38897. }
  38898. var respJSON map[string]interface{}
  38899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38902. return
  38903. }
  38904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38905. userJSONBytes, _ := json.Marshal(respJSON)
  38906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38907. utils.ErrorLog("解析失败:%v", err)
  38908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38909. return
  38910. }
  38911. }
  38912. if res.Infcode == 0 {
  38913. c.ServeSuccessJSON(map[string]interface{}{
  38914. "order": res.Output.Result,
  38915. "total": res.Output.PageInfo.RecordCounts,
  38916. })
  38917. } else {
  38918. c.ServeSuccessJSON(map[string]interface{}{
  38919. "failed_code": -10,
  38920. "msg": res.ErrMsg,
  38921. })
  38922. }
  38923. }
  38924. }
  38925. func (c *HisApiController) Post3501() {
  38926. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38927. data := make(map[string]interface{})
  38928. var struct3501s []models.Struct3501
  38929. var struct3501 models.Struct3501
  38930. struct3501.OrgName = miConfig.OrgName
  38931. struct3501.AccessKey = miConfig.AccessKey
  38932. struct3501.RequestUrl = miConfig.Url
  38933. struct3501.SecretKey = miConfig.SecretKey
  38934. struct3501.ManuDate = "2022-08-17"
  38935. struct3501.FixmedinsBchno = ""
  38936. struct3501.ManuLotnum = ""
  38937. struct3501.RxFlag = "0"
  38938. struct3501.ExpyEnd = "2022-08-17"
  38939. struct3501.Invdate = "2022-08-17"
  38940. struct3501.InvCnt = "20.25"
  38941. struct3501.Memo = ""
  38942. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38943. struct3501.FixmedinsHilistId = miConfig.Code
  38944. struct3501.FixmedinsHilistName = miConfig.OrgName
  38945. struct3501s = append(struct3501s, struct3501)
  38946. data["struct_3501s"] = struct3501s
  38947. client := &http.Client{}
  38948. bytesData, _ := json.Marshal(data)
  38949. var req *http.Request
  38950. if miConfig.MdtrtareaAdmvs == "320921" {
  38951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38952. } else {
  38953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38954. }
  38955. resp, _ := client.Do(req)
  38956. defer resp.Body.Close()
  38957. body, ioErr := ioutil.ReadAll(resp.Body)
  38958. if ioErr != nil {
  38959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38961. return
  38962. }
  38963. var respJSON map[string]interface{}
  38964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38967. return
  38968. }
  38969. var res ResultSix
  38970. var resSix10265 ResultSix10265 //1101结果
  38971. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38972. result, _ := json.Marshal(respJSON)
  38973. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38974. utils.ErrorLog("解析失败:%v", err)
  38975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38976. return
  38977. }
  38978. res.InfRefmsgid = resSix10265.InfRefmsgid
  38979. res.Output = resSix10265.Output
  38980. res.ErrMsg = resSix10265.ErrMsg
  38981. res.Cainfo = resSix10265.Cainfo
  38982. res.WarnMsg = resSix10265.WarnMsg
  38983. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38984. res.Infcode = infocode
  38985. if infocode == 0 {
  38986. c.ServeSuccessJSON(map[string]interface{}{
  38987. "msg": "上传成功",
  38988. })
  38989. return
  38990. } else {
  38991. c.ServeSuccessJSON(map[string]interface{}{
  38992. "failed_code": -10,
  38993. "msg": res.ErrMsg,
  38994. })
  38995. return
  38996. }
  38997. }
  38998. func (c *HisApiController) Post3502() {
  38999. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39000. data := make(map[string]interface{})
  39001. var struct3502s []models.Struct3502
  39002. var struct3502 models.Struct3502
  39003. struct3502.OrgName = miConfig.OrgName
  39004. struct3502.AccessKey = miConfig.AccessKey
  39005. struct3502.RequestUrl = miConfig.Url
  39006. struct3502.SecretKey = miConfig.SecretKey
  39007. struct3502.ManuDate = "2022-08-15"
  39008. struct3502.FixmedinsBchno = ""
  39009. struct3502.ManuLotnum = ""
  39010. struct3502.RxFlag = "0"
  39011. struct3502.ExpyEnd = "2022-08-15"
  39012. struct3502.Invdate = "2022-08-15"
  39013. struct3502.InvCnt = "20.25"
  39014. struct3502.Memo = ""
  39015. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39016. struct3502.FixmedinsHilistId = miConfig.Code
  39017. struct3502.FixmedinsHilistName = miConfig.OrgName
  39018. struct3502s = append(struct3502s, struct3502)
  39019. data["struct_3502s"] = struct3502s
  39020. client := &http.Client{}
  39021. bytesData, _ := json.Marshal(data)
  39022. var req *http.Request
  39023. if miConfig.MdtrtareaAdmvs == "320921" {
  39024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39025. } else {
  39026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39027. }
  39028. resp, _ := client.Do(req)
  39029. defer resp.Body.Close()
  39030. body, ioErr := ioutil.ReadAll(resp.Body)
  39031. if ioErr != nil {
  39032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39034. return
  39035. }
  39036. var respJSON map[string]interface{}
  39037. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39040. return
  39041. }
  39042. var res ResultSix
  39043. var resSix10265 ResultSix10265 //1101结果
  39044. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39045. result, _ := json.Marshal(respJSON)
  39046. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39047. utils.ErrorLog("解析失败:%v", err)
  39048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39049. return
  39050. }
  39051. res.InfRefmsgid = resSix10265.InfRefmsgid
  39052. res.Output = resSix10265.Output
  39053. res.ErrMsg = resSix10265.ErrMsg
  39054. res.Cainfo = resSix10265.Cainfo
  39055. res.WarnMsg = resSix10265.WarnMsg
  39056. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39057. res.Infcode = infocode
  39058. if infocode == 0 {
  39059. c.ServeSuccessJSON(map[string]interface{}{
  39060. "msg": "上传成功",
  39061. })
  39062. return
  39063. } else {
  39064. c.ServeSuccessJSON(map[string]interface{}{
  39065. "failed_code": -10,
  39066. "msg": res.ErrMsg,
  39067. })
  39068. return
  39069. }
  39070. }
  39071. func (c *HisApiController) Post3503() {
  39072. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39073. data := make(map[string]interface{})
  39074. var struct3501s []models.Struct3501
  39075. var struct3501 models.Struct3501
  39076. struct3501.OrgName = miConfig.OrgName
  39077. struct3501.AccessKey = miConfig.AccessKey
  39078. struct3501.RequestUrl = miConfig.Url
  39079. struct3501.SecretKey = miConfig.SecretKey
  39080. struct3501.ManuDate = "2022-08-15"
  39081. struct3501.FixmedinsBchno = ""
  39082. struct3501.ManuLotnum = ""
  39083. struct3501.RxFlag = "0"
  39084. struct3501.ExpyEnd = "2022-08-15"
  39085. struct3501.Invdate = "2022-08-15"
  39086. struct3501.InvCnt = "20.25"
  39087. struct3501.Memo = ""
  39088. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39089. struct3501.FixmedinsHilistId = miConfig.Code
  39090. struct3501.FixmedinsHilistName = miConfig.OrgName
  39091. struct3501s = append(struct3501s, struct3501)
  39092. data["struct_3501s"] = struct3501s
  39093. client := &http.Client{}
  39094. bytesData, _ := json.Marshal(data)
  39095. var req *http.Request
  39096. if miConfig.MdtrtareaAdmvs == "320921" {
  39097. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39098. } else {
  39099. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39100. }
  39101. resp, _ := client.Do(req)
  39102. defer resp.Body.Close()
  39103. body, ioErr := ioutil.ReadAll(resp.Body)
  39104. if ioErr != nil {
  39105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39107. return
  39108. }
  39109. var respJSON map[string]interface{}
  39110. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39113. return
  39114. }
  39115. var res ResultSix
  39116. var resSix10265 ResultSix10265 //1101结果
  39117. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39118. result, _ := json.Marshal(respJSON)
  39119. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39120. utils.ErrorLog("解析失败:%v", err)
  39121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39122. return
  39123. }
  39124. res.InfRefmsgid = resSix10265.InfRefmsgid
  39125. res.Output = resSix10265.Output
  39126. res.ErrMsg = resSix10265.ErrMsg
  39127. res.Cainfo = resSix10265.Cainfo
  39128. res.WarnMsg = resSix10265.WarnMsg
  39129. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39130. res.Infcode = infocode
  39131. if infocode == 0 {
  39132. c.ServeSuccessJSON(map[string]interface{}{
  39133. "msg": "上传成功",
  39134. })
  39135. return
  39136. } else {
  39137. c.ServeSuccessJSON(map[string]interface{}{
  39138. "failed_code": -10,
  39139. "msg": res.ErrMsg,
  39140. })
  39141. return
  39142. }
  39143. }
  39144. func (c *HisApiController) Post3504() {
  39145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39146. data := make(map[string]interface{})
  39147. var struct3501s []models.Struct3501
  39148. var struct3501 models.Struct3501
  39149. struct3501.OrgName = miConfig.OrgName
  39150. struct3501.AccessKey = miConfig.AccessKey
  39151. struct3501.RequestUrl = miConfig.Url
  39152. struct3501.SecretKey = miConfig.SecretKey
  39153. struct3501.ManuDate = "2022-08-15"
  39154. struct3501.FixmedinsBchno = ""
  39155. struct3501.ManuLotnum = ""
  39156. struct3501.RxFlag = "0"
  39157. struct3501.ExpyEnd = "2022-08-15"
  39158. struct3501.Invdate = "2022-08-15"
  39159. struct3501.InvCnt = "20.25"
  39160. struct3501.Memo = ""
  39161. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39162. struct3501.FixmedinsHilistId = miConfig.Code
  39163. struct3501.FixmedinsHilistName = miConfig.OrgName
  39164. struct3501s = append(struct3501s, struct3501)
  39165. data["struct_3501s"] = struct3501s
  39166. client := &http.Client{}
  39167. bytesData, _ := json.Marshal(data)
  39168. var req *http.Request
  39169. if miConfig.MdtrtareaAdmvs == "320921" {
  39170. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39171. } else {
  39172. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39173. }
  39174. resp, _ := client.Do(req)
  39175. defer resp.Body.Close()
  39176. body, ioErr := ioutil.ReadAll(resp.Body)
  39177. if ioErr != nil {
  39178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39180. return
  39181. }
  39182. var respJSON map[string]interface{}
  39183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39186. return
  39187. }
  39188. var res ResultSix
  39189. var resSix10265 ResultSix10265 //1101结果
  39190. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39191. result, _ := json.Marshal(respJSON)
  39192. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39193. utils.ErrorLog("解析失败:%v", err)
  39194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39195. return
  39196. }
  39197. res.InfRefmsgid = resSix10265.InfRefmsgid
  39198. res.Output = resSix10265.Output
  39199. res.ErrMsg = resSix10265.ErrMsg
  39200. res.Cainfo = resSix10265.Cainfo
  39201. res.WarnMsg = resSix10265.WarnMsg
  39202. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39203. res.Infcode = infocode
  39204. if infocode == 0 {
  39205. c.ServeSuccessJSON(map[string]interface{}{
  39206. "msg": "上传成功",
  39207. })
  39208. return
  39209. } else {
  39210. c.ServeSuccessJSON(map[string]interface{}{
  39211. "failed_code": -10,
  39212. "msg": res.ErrMsg,
  39213. })
  39214. return
  39215. }
  39216. }
  39217. func (c *HisApiController) Post3505() {
  39218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39219. data := make(map[string]interface{})
  39220. var struct3501s []models.Struct3501
  39221. var struct3501 models.Struct3501
  39222. struct3501.OrgName = miConfig.OrgName
  39223. struct3501.AccessKey = miConfig.AccessKey
  39224. struct3501.RequestUrl = miConfig.Url
  39225. struct3501.SecretKey = miConfig.SecretKey
  39226. struct3501.ManuDate = "2022-08-15"
  39227. struct3501.FixmedinsBchno = ""
  39228. struct3501.ManuLotnum = ""
  39229. struct3501.RxFlag = "0"
  39230. struct3501.ExpyEnd = "2022-08-15"
  39231. struct3501.Invdate = "2022-08-15"
  39232. struct3501.InvCnt = "20.25"
  39233. struct3501.Memo = ""
  39234. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39235. struct3501.FixmedinsHilistId = miConfig.Code
  39236. struct3501.FixmedinsHilistName = miConfig.OrgName
  39237. struct3501s = append(struct3501s, struct3501)
  39238. data["struct_3501s"] = struct3501s
  39239. client := &http.Client{}
  39240. bytesData, _ := json.Marshal(data)
  39241. var req *http.Request
  39242. if miConfig.MdtrtareaAdmvs == "320921" {
  39243. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39244. } else {
  39245. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39246. }
  39247. resp, _ := client.Do(req)
  39248. defer resp.Body.Close()
  39249. body, ioErr := ioutil.ReadAll(resp.Body)
  39250. if ioErr != nil {
  39251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39253. return
  39254. }
  39255. var respJSON map[string]interface{}
  39256. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39259. return
  39260. }
  39261. var res ResultSix
  39262. var resSix10265 ResultSix10265 //1101结果
  39263. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39264. result, _ := json.Marshal(respJSON)
  39265. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39266. utils.ErrorLog("解析失败:%v", err)
  39267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39268. return
  39269. }
  39270. res.InfRefmsgid = resSix10265.InfRefmsgid
  39271. res.Output = resSix10265.Output
  39272. res.ErrMsg = resSix10265.ErrMsg
  39273. res.Cainfo = resSix10265.Cainfo
  39274. res.WarnMsg = resSix10265.WarnMsg
  39275. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39276. res.Infcode = infocode
  39277. if infocode == 0 {
  39278. c.ServeSuccessJSON(map[string]interface{}{
  39279. "msg": "上传成功",
  39280. })
  39281. return
  39282. } else {
  39283. c.ServeSuccessJSON(map[string]interface{}{
  39284. "failed_code": -10,
  39285. "msg": res.ErrMsg,
  39286. })
  39287. return
  39288. }
  39289. }
  39290. func (c *HisApiController) Post3506() {
  39291. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39292. data := make(map[string]interface{})
  39293. var struct3501s []models.Struct3501
  39294. var struct3501 models.Struct3501
  39295. struct3501.OrgName = miConfig.OrgName
  39296. struct3501.AccessKey = miConfig.AccessKey
  39297. struct3501.RequestUrl = miConfig.Url
  39298. struct3501.SecretKey = miConfig.SecretKey
  39299. struct3501.ManuDate = "2022-08-15"
  39300. struct3501.FixmedinsBchno = ""
  39301. struct3501.ManuLotnum = ""
  39302. struct3501.RxFlag = "0"
  39303. struct3501.ExpyEnd = "2022-08-15"
  39304. struct3501.Invdate = "2022-08-15"
  39305. struct3501.InvCnt = "20.25"
  39306. struct3501.Memo = ""
  39307. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39308. struct3501.FixmedinsHilistId = miConfig.Code
  39309. struct3501.FixmedinsHilistName = miConfig.OrgName
  39310. struct3501s = append(struct3501s, struct3501)
  39311. data["struct_3501s"] = struct3501s
  39312. client := &http.Client{}
  39313. bytesData, _ := json.Marshal(data)
  39314. var req *http.Request
  39315. if miConfig.MdtrtareaAdmvs == "320921" {
  39316. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39317. } else {
  39318. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39319. }
  39320. resp, _ := client.Do(req)
  39321. defer resp.Body.Close()
  39322. body, ioErr := ioutil.ReadAll(resp.Body)
  39323. if ioErr != nil {
  39324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39326. return
  39327. }
  39328. var respJSON map[string]interface{}
  39329. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39332. return
  39333. }
  39334. var res ResultSix
  39335. var resSix10265 ResultSix10265 //1101结果
  39336. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39337. result, _ := json.Marshal(respJSON)
  39338. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39339. utils.ErrorLog("解析失败:%v", err)
  39340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39341. return
  39342. }
  39343. res.InfRefmsgid = resSix10265.InfRefmsgid
  39344. res.Output = resSix10265.Output
  39345. res.ErrMsg = resSix10265.ErrMsg
  39346. res.Cainfo = resSix10265.Cainfo
  39347. res.WarnMsg = resSix10265.WarnMsg
  39348. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39349. res.Infcode = infocode
  39350. if infocode == 0 {
  39351. c.ServeSuccessJSON(map[string]interface{}{
  39352. "msg": "上传成功",
  39353. })
  39354. return
  39355. } else {
  39356. c.ServeSuccessJSON(map[string]interface{}{
  39357. "failed_code": -10,
  39358. "msg": res.ErrMsg,
  39359. })
  39360. return
  39361. }
  39362. }
  39363. func (c *HisApiController) Post3507() {
  39364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39365. data := make(map[string]interface{})
  39366. var struct3501s []models.Struct3501
  39367. var struct3501 models.Struct3501
  39368. struct3501.OrgName = miConfig.OrgName
  39369. struct3501.AccessKey = miConfig.AccessKey
  39370. struct3501.RequestUrl = miConfig.Url
  39371. struct3501.SecretKey = miConfig.SecretKey
  39372. struct3501.ManuDate = "2022-08-15"
  39373. struct3501.FixmedinsBchno = ""
  39374. struct3501.ManuLotnum = ""
  39375. struct3501.RxFlag = "0"
  39376. struct3501.ExpyEnd = "2022-08-15"
  39377. struct3501.Invdate = "2022-08-15"
  39378. struct3501.InvCnt = "20.25"
  39379. struct3501.Memo = ""
  39380. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39381. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39382. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39383. struct3501s = append(struct3501s, struct3501)
  39384. data["struct_3501s"] = struct3501s
  39385. client := &http.Client{}
  39386. bytesData, _ := json.Marshal(data)
  39387. var req *http.Request
  39388. if miConfig.MdtrtareaAdmvs == "320921" {
  39389. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39390. } else {
  39391. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39392. }
  39393. resp, _ := client.Do(req)
  39394. defer resp.Body.Close()
  39395. body, ioErr := ioutil.ReadAll(resp.Body)
  39396. if ioErr != nil {
  39397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39399. return
  39400. }
  39401. var respJSON map[string]interface{}
  39402. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39405. return
  39406. }
  39407. var res ResultSix
  39408. var resSix10265 ResultSix10265 //1101结果
  39409. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39410. result, _ := json.Marshal(respJSON)
  39411. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39412. utils.ErrorLog("解析失败:%v", err)
  39413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39414. return
  39415. }
  39416. res.InfRefmsgid = resSix10265.InfRefmsgid
  39417. res.Output = resSix10265.Output
  39418. res.ErrMsg = resSix10265.ErrMsg
  39419. res.Cainfo = resSix10265.Cainfo
  39420. res.WarnMsg = resSix10265.WarnMsg
  39421. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39422. res.Infcode = infocode
  39423. if infocode == 0 {
  39424. c.ServeSuccessJSON(map[string]interface{}{
  39425. "msg": "上传成功",
  39426. })
  39427. return
  39428. } else {
  39429. c.ServeSuccessJSON(map[string]interface{}{
  39430. "failed_code": -10,
  39431. "msg": res.ErrMsg,
  39432. })
  39433. return
  39434. }
  39435. }
  39436. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39437. // WebSocket服务器地址
  39438. serverURL := "ws://127.0.0.1:8899"
  39439. // 解析WebSocket服务器地址
  39440. u, err := url.Parse(serverURL)
  39441. if err != nil {
  39442. }
  39443. // 建立WebSocket连接
  39444. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39445. if err != nil {
  39446. }
  39447. defer conn.Close()
  39448. input2 := make(map[string]interface{})
  39449. input := make(map[string]interface{})
  39450. inputData := make(map[string]interface{})
  39451. inputData["orgId"] = code
  39452. inputData["businessType"] = "01101"
  39453. inputData["operatorId"] = operator_id
  39454. inputData["operatorName"] = operator_name
  39455. inputData["officeId"] = "001"
  39456. inputData["officeName"] = "血透室"
  39457. inputData["deviceType"] = ""
  39458. input["data"] = inputData
  39459. input["orgId"] = code
  39460. input["transType"] = "ec.query"
  39461. //if md == ""
  39462. if md[:4] == "4403" {
  39463. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39464. } else if md[:4] == "4401" {
  39465. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39466. } else {
  39467. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39468. }
  39469. input2["indata"] = input
  39470. fmt.Println(input2)
  39471. bytesData, _ := json.Marshal(input2)
  39472. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39473. if err != nil {
  39474. fmt.Println(err)
  39475. }
  39476. // 接收消息
  39477. _, receivedMessage, err := conn.ReadMessage()
  39478. if err != nil {
  39479. fmt.Println(err)
  39480. }
  39481. return "", string(receivedMessage)
  39482. }
  39483. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39484. // WebSocket服务器地址
  39485. serverURL := "ws://127.0.0.1:8899"
  39486. // 解析WebSocket服务器地址
  39487. u, err := url.Parse(serverURL)
  39488. if err != nil {
  39489. }
  39490. // 建立WebSocket连接
  39491. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39492. if err != nil {
  39493. }
  39494. defer conn.Close()
  39495. input2 := make(map[string]interface{})
  39496. input := make(map[string]interface{})
  39497. inputData := make(map[string]interface{})
  39498. inputData["orgId"] = code
  39499. inputData["businessType"] = "01101"
  39500. inputData["operatorId"] = operator_id
  39501. inputData["operatorName"] = operator_name
  39502. inputData["officeId"] = "001"
  39503. inputData["officeName"] = "血透室"
  39504. inputData["deviceType"] = ""
  39505. input["data"] = inputData
  39506. input["orgId"] = code
  39507. input["transType"] = "ec.query"
  39508. //if md == ""
  39509. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39510. input2["indata"] = input
  39511. fmt.Println(input2)
  39512. bytesData, _ := json.Marshal(input2)
  39513. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39514. if err != nil {
  39515. fmt.Println(err)
  39516. }
  39517. // 接收消息
  39518. _, receivedMessage, err := conn.ReadMessage()
  39519. if err != nil {
  39520. fmt.Println(err)
  39521. }
  39522. return "", string(receivedMessage)
  39523. }
  39524. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39525. // WebSocket服务器地址
  39526. serverURL := "ws://127.0.0.1:8899"
  39527. // 解析WebSocket服务器地址
  39528. u, err := url.Parse(serverURL)
  39529. if err != nil {
  39530. }
  39531. // 建立WebSocket连接
  39532. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39533. if err != nil {
  39534. }
  39535. defer conn.Close()
  39536. input2 := make(map[string]interface{})
  39537. input := make(map[string]interface{})
  39538. inputData := make(map[string]interface{})
  39539. inputData["orgId"] = code
  39540. inputData["businessType"] = "01301"
  39541. inputData["operatorId"] = operator_id
  39542. inputData["operatorName"] = operator_name
  39543. inputData["officeId"] = "001"
  39544. inputData["officeName"] = "血透室"
  39545. inputData["deviceType"] = ""
  39546. input["data"] = inputData
  39547. input["orgId"] = code
  39548. input["transType"] = "ec.query"
  39549. //if md == ""
  39550. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39551. input2["indata"] = input
  39552. fmt.Println(input2)
  39553. bytesData, _ := json.Marshal(input2)
  39554. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39555. if err != nil {
  39556. fmt.Println(err)
  39557. }
  39558. // 接收消息
  39559. _, receivedMessage, err := conn.ReadMessage()
  39560. if err != nil {
  39561. fmt.Println(err)
  39562. }
  39563. return "", string(receivedMessage)
  39564. }
  39565. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39566. // WebSocket服务器地址
  39567. serverURL := "ws://127.0.0.1:8899"
  39568. // 解析WebSocket服务器地址
  39569. u, err := url.Parse(serverURL)
  39570. if err != nil {
  39571. }
  39572. // 建立WebSocket连接
  39573. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39574. if err != nil {
  39575. }
  39576. defer conn.Close()
  39577. input2 := make(map[string]interface{})
  39578. input := make(map[string]interface{})
  39579. inputData := make(map[string]interface{})
  39580. inputData["orgId"] = code
  39581. inputData["businessType"] = "01103"
  39582. inputData["operatorId"] = operator_id
  39583. inputData["operatorName"] = operator_name
  39584. inputData["officeId"] = "001"
  39585. inputData["officeName"] = "血透室"
  39586. inputData["deviceType"] = ""
  39587. input["data"] = inputData
  39588. input["orgId"] = code
  39589. input["transType"] = "ec.query"
  39590. //if md ==
  39591. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39592. input2["indata"] = input
  39593. fmt.Println(input2)
  39594. bytesData, _ := json.Marshal(input2)
  39595. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39596. if err != nil {
  39597. fmt.Println(err)
  39598. }
  39599. // 接收消息
  39600. _, receivedMessage, err := conn.ReadMessage()
  39601. if err != nil {
  39602. fmt.Println(err)
  39603. }
  39604. return "", string(receivedMessage)
  39605. }
  39606. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39607. // WebSocket服务器地址
  39608. serverURL := "ws://127.0.0.1:8899"
  39609. // 解析WebSocket服务器地址
  39610. u, err := url.Parse(serverURL)
  39611. if err != nil {
  39612. }
  39613. // 建立WebSocket连接
  39614. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39615. if err != nil {
  39616. }
  39617. defer conn.Close()
  39618. input2 := make(map[string]interface{})
  39619. input := make(map[string]interface{})
  39620. inputData := make(map[string]interface{})
  39621. inputData["orgId"] = code
  39622. inputData["businessType"] = "01101"
  39623. inputData["operatorId"] = operator_id
  39624. inputData["operatorName"] = operator_name
  39625. inputData["officeId"] = "001"
  39626. inputData["officeName"] = "血透室"
  39627. inputData["deviceType"] = ""
  39628. input["data"] = inputData
  39629. input["orgId"] = code
  39630. input["transType"] = "ec.query"
  39631. //if md == ""
  39632. if md[:4] == "4403" {
  39633. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39634. } else if md[:4] == "4401" {
  39635. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39636. } else {
  39637. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39638. }
  39639. input2["indata"] = input
  39640. fmt.Println(input2)
  39641. bytesData, _ := json.Marshal(input2)
  39642. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39643. if err != nil {
  39644. fmt.Println(err)
  39645. }
  39646. // 接收消息
  39647. _, receivedMessage, err := conn.ReadMessage()
  39648. if err != nil {
  39649. fmt.Println(err)
  39650. }
  39651. return "", string(receivedMessage)
  39652. }
  39653. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39654. // WebSocket服务器地址
  39655. serverURL := "ws://127.0.0.1:8899"
  39656. // 解析WebSocket服务器地址
  39657. u, err := url.Parse(serverURL)
  39658. if err != nil {
  39659. }
  39660. // 建立WebSocket连接
  39661. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39662. if err != nil {
  39663. }
  39664. defer conn.Close()
  39665. input2 := make(map[string]interface{})
  39666. input := make(map[string]interface{})
  39667. inputData := make(map[string]interface{})
  39668. inputData["orgId"] = code
  39669. inputData["businessType"] = "01301"
  39670. inputData["operatorId"] = operator_id
  39671. inputData["operatorName"] = operator_name
  39672. inputData["officeId"] = "001"
  39673. inputData["officeName"] = "血透室"
  39674. inputData["deviceType"] = ""
  39675. input["data"] = inputData
  39676. input["orgId"] = code
  39677. input["transType"] = "ec.query"
  39678. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39679. input2["indata"] = input
  39680. bytesData, _ := json.Marshal(input2)
  39681. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39682. if err != nil {
  39683. fmt.Println(err)
  39684. }
  39685. // 接收消息
  39686. _, receivedMessage, err := conn.ReadMessage()
  39687. if err != nil {
  39688. fmt.Println(err)
  39689. }
  39690. return "", string(receivedMessage)
  39691. }
  39692. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39693. newArr = make([]string, 0)
  39694. for i := 0; i < len(arr); i++ {
  39695. repeat := false
  39696. for j := i + 1; j < len(arr); j++ {
  39697. if arr[i] == arr[j] {
  39698. repeat = true
  39699. break
  39700. }
  39701. }
  39702. if !repeat {
  39703. newArr = append(newArr, arr[i])
  39704. }
  39705. }
  39706. return
  39707. }
  39708. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39709. if len(idNumber) != 18 {
  39710. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39711. }
  39712. // 提取出生日期
  39713. year, err := strconv.Atoi(idNumber[6:10])
  39714. if err != nil {
  39715. return "", 0, err
  39716. }
  39717. month, err := strconv.Atoi(idNumber[10:12])
  39718. if err != nil {
  39719. return "", 0, err
  39720. }
  39721. day, err := strconv.Atoi(idNumber[12:14])
  39722. if err != nil {
  39723. return "", 0, err
  39724. }
  39725. // 格式化生日字符串
  39726. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39727. birthdateFormatted := birthdate.Format("2006-01-02")
  39728. // 计算年龄
  39729. today := time.Now()
  39730. age := today.Year() - birthdate.Year()
  39731. if today.YearDay() < birthdate.YearDay() {
  39732. age--
  39733. }
  39734. return birthdateFormatted, age, nil
  39735. }
  39736. // 从身份证号码中提取出生年月日
  39737. func getBirthDateFromIDCard(idCard string) (string, error) {
  39738. // 身份证号码长度应为18位
  39739. if len(idCard) != 18 {
  39740. return "", fmt.Errorf("身份证号码长度应为18位")
  39741. }
  39742. // 提取出生日期部分 (YYYYMMDD)
  39743. birthDateStr := idCard[6:14]
  39744. // 解析出生日期
  39745. birthDate, err := time.Parse("20060102", birthDateStr)
  39746. if err != nil {
  39747. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39748. }
  39749. // 格式化出生日期为 YYYY-MM-DD
  39750. formattedDate := birthDate.Format("2006-01-02")
  39751. return formattedDate, nil
  39752. }