his_api_controller.go 1.3MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/gorilla/websocket"
  20. "github.com/jinzhu/gorm"
  21. "github.com/shopspring/decimal"
  22. "github.com/go-ole/go-ole"
  23. "github.com/go-ole/go-ole/oleutil"
  24. "io"
  25. "io/ioutil"
  26. //"math"
  27. "math/rand"
  28. "net/http"
  29. "net/url"
  30. "os"
  31. "path/filepath"
  32. "regexp"
  33. "strconv"
  34. "strings"
  35. "syscall"
  36. "time"
  37. "unsafe"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  84. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  85. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  86. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  87. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  88. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  89. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. }
  159. func (c *HisApiController) FJ3501AND3502() {
  160. ids := c.GetString("ids")
  161. admin_user_id, _ := c.GetInt64("admin_user_id")
  162. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  163. id_arr := strings.Split(ids, ",")
  164. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  165. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  166. //库盘
  167. var errs []string
  168. for _, drug := range drugs {
  169. if drug.IsPc == 0 && drug.IsBg == 0 {
  170. var res2 ResultSix
  171. var res3 ResultSix
  172. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  173. var struct3501 models.Struct3501
  174. struct3501.OrgName = miConfig.OrgName
  175. struct3501.AccessKey = miConfig.AccessKey
  176. struct3501.Opter = roles.UserName
  177. struct3501.RequestUrl = miConfig.Url
  178. struct3501.Url = miConfig.Url
  179. struct3501.AppId = miConfig.Cainfo
  180. struct3501.AppSecret = miConfig.AppSecret
  181. struct3501.Enckey = miConfig.EncKey
  182. struct3501.SignKey = miConfig.SignKey
  183. struct3501.SecretKey = miConfig.SecretKey
  184. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  185. struct3501.FixmedinsHilistId = miConfig.Code
  186. struct3501.FixmedinsHilistName = miConfig.OrgName
  187. struct3501.RxFlag = "0"
  188. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  189. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  190. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  191. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  192. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  193. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  194. struct3501.FixmedinsBchno = number
  195. memo := make(map[string]interface{})
  196. memo["pric"] = drug.Price
  197. bytesData, _ := json.Marshal(memo)
  198. struct3501.Memo = string(bytesData)
  199. result1, result2, _ := service.FJyb3501(struct3501)
  200. saveLog(result1, result2, "3501", "3501")
  201. //saveLog(result, requestLog, "2201", "挂号")
  202. var respJSON2 map[string]interface{}
  203. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  206. return
  207. }
  208. userJSONBytes2, _ := json.Marshal(respJSON2)
  209. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res2.Infcode != -1 {
  215. drug.IsPc = 1
  216. drug.Bchno = number
  217. drug.PcDate = time.Now().Format("2006-01-02")
  218. err := service.SaveW(drug)
  219. if err == nil {
  220. var struct3502 models.Struct3502
  221. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  222. struct3502.FixmedinsHilistId = miConfig.Code
  223. struct3502.FixmedinsHilistName = miConfig.OrgName
  224. struct3502.FixmedinsCode = miConfig.Code
  225. struct3502.RxFlag = "0"
  226. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  227. struct3502.OrgName = miConfig.OrgName
  228. struct3501.Opter = roles.UserName
  229. struct3502.AccessKey = miConfig.AccessKey
  230. struct3502.RequestUrl = miConfig.Url
  231. struct3502.SecretKey = miConfig.SecretKey
  232. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  233. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  234. struct3502.Url = miConfig.Url
  235. struct3502.AppId = miConfig.Cainfo
  236. struct3502.AppSecret = miConfig.AppSecret
  237. struct3502.Enckey = miConfig.EncKey
  238. struct3502.SignKey = miConfig.SignKey
  239. struct3502.SecretKey = miConfig.SecretKey
  240. struct3502.Memo = ""
  241. struct3502.InvChgType = "108"
  242. struct3502.FixmedinsBchno = drug.Bchno
  243. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  244. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  245. result11, result22, _ := service.FJyb3502(struct3502)
  246. saveLog(result11, result22, "3502", "3502")
  247. var respJSON3 map[string]interface{}
  248. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  251. return
  252. }
  253. userJSONBytes3, _ := json.Marshal(respJSON3)
  254. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  255. utils.ErrorLog("解析失败:%v", err)
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. if res3.Infcode == -1 {
  260. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "failed_code": -10,
  263. "msg": res3.ErrMsg,
  264. })
  265. } else {
  266. drug.IsBg = 1
  267. service.SaveW(drug)
  268. }
  269. }
  270. } else {
  271. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  272. }
  273. }
  274. //变更
  275. if drug.IsPc == 1 && drug.IsBg == 0 {
  276. var res3 ResultSix
  277. var struct3502 models.Struct3502
  278. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  279. struct3502.FixmedinsHilistId = miConfig.Code
  280. struct3502.FixmedinsHilistName = miConfig.OrgName
  281. struct3502.FixmedinsCode = miConfig.Code
  282. struct3502.Opter = roles.UserName
  283. struct3502.RxFlag = "0"
  284. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  285. struct3502.OrgName = miConfig.OrgName
  286. struct3502.AccessKey = miConfig.AccessKey
  287. struct3502.RequestUrl = miConfig.Url
  288. struct3502.SecretKey = miConfig.SecretKey
  289. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  290. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  291. struct3502.InvChgType = "108"
  292. struct3502.Url = miConfig.Url
  293. struct3502.AppId = miConfig.Cainfo
  294. struct3502.AppSecret = miConfig.AppSecret
  295. struct3502.Enckey = miConfig.EncKey
  296. struct3502.SignKey = miConfig.SignKey
  297. struct3502.SecretKey = miConfig.SecretKey
  298. struct3502.FixmedinsBchno = drug.Bchno
  299. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  300. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  301. result1, result2, _ := service.FJyb3502(struct3502)
  302. saveLog(result1, result2, "3502", "3502")
  303. var respJSON3 map[string]interface{}
  304. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  307. return
  308. }
  309. userJSONBytes3, _ := json.Marshal(respJSON3)
  310. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  311. utils.ErrorLog("解析失败:%v", err)
  312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  313. return
  314. }
  315. if res3.Infcode == -1 {
  316. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  317. } else {
  318. drug.IsBg = 1
  319. //drug.Bchno = number
  320. //drug.PcDate = time.Now().Format("2006-01-02")
  321. service.SaveW(drug)
  322. }
  323. }
  324. }
  325. if len(errs) == 0 {
  326. c.ServeSuccessJSON(map[string]interface{}{
  327. "msg": "盘存变更成功",
  328. })
  329. } else {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": errs,
  333. })
  334. }
  335. }
  336. func (c *HisApiController) DeletePCandBG() {
  337. ids := c.GetString("ids")
  338. id_arr := strings.Split(ids, ",")
  339. admin_user_id, _ := c.GetInt64("admin_user_id")
  340. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  341. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  342. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  343. var err []string
  344. for _, item := range drugs {
  345. if item.IsPc == 1 && item.IsBg == 1 {
  346. var res FJ3507Result
  347. var res2 FJ3507Result
  348. var struct3507 models.Struct3507
  349. struct3507.FixmedinsBchno = item.Bchno
  350. struct3507.InvDataType = "1"
  351. struct3507.Opter = roles.UserName
  352. struct3507.OrgName = miConfig.OrgName
  353. struct3507.AccessKey = miConfig.AccessKey
  354. struct3507.RequestUrl = miConfig.Url
  355. struct3507.SecretKey = miConfig.SecretKey
  356. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  357. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  358. struct3507.Url = miConfig.Url
  359. struct3507.AppId = miConfig.Cainfo
  360. struct3507.AppSecret = miConfig.AppSecret
  361. struct3507.Enckey = miConfig.EncKey
  362. struct3507.SignKey = miConfig.SignKey
  363. struct3507.SecretKey = miConfig.SecretKey
  364. result, result1, _ := service.FJyb3507(struct3507)
  365. saveLog(result, result1, "3507", "3507")
  366. var respJSON2 map[string]interface{}
  367. if err := json.Unmarshal([]byte(string(result)), &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. item.IsPc = 0
  380. err2 := service.SaveW(item)
  381. if err2 == nil {
  382. var struct3507_2 models.Struct3507
  383. struct3507_2.OrgName = miConfig.OrgName
  384. struct3507_2.AccessKey = miConfig.AccessKey
  385. struct3507_2.RequestUrl = miConfig.Url
  386. struct3507_2.Opter = roles.UserName
  387. struct3507_2.SecretKey = miConfig.SecretKey
  388. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  389. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  390. struct3507_2.Url = miConfig.Url
  391. struct3507_2.AppId = miConfig.Cainfo
  392. struct3507_2.AppSecret = miConfig.AppSecret
  393. struct3507_2.Enckey = miConfig.EncKey
  394. struct3507_2.SignKey = miConfig.SignKey
  395. struct3507_2.SecretKey = miConfig.SecretKey
  396. struct3507_2.FixmedinsBchno = item.Bchno
  397. struct3507_2.InvDataType = "2"
  398. result11, result22, _ := service.FJyb3507(struct3507_2)
  399. saveLog(result11, result22, "3507", "3507")
  400. var respJSON3 map[string]interface{}
  401. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  404. return
  405. }
  406. userJSONBytes3, _ := json.Marshal(respJSON3)
  407. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. return
  411. }
  412. if res2.Infcode != -1 {
  413. item.IsBg = 0
  414. item.Bchno = ""
  415. item.PcDate = ""
  416. service.SaveW(item)
  417. } else {
  418. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  419. }
  420. }
  421. } else {
  422. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  423. }
  424. }
  425. if item.IsPc == 1 && item.IsBg == 0 {
  426. var res FJ3507Result
  427. var struct3507 models.Struct3507
  428. struct3507.FixmedinsBchno = item.Bchno
  429. struct3507.InvDataType = "2"
  430. struct3507.Opter = roles.UserName
  431. struct3507.OrgName = miConfig.OrgName
  432. struct3507.AccessKey = miConfig.AccessKey
  433. struct3507.RequestUrl = miConfig.Url
  434. struct3507.SecretKey = miConfig.SecretKey
  435. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  436. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  437. struct3507.Url = miConfig.Url
  438. struct3507.AppId = miConfig.Cainfo
  439. struct3507.AppSecret = miConfig.AppSecret
  440. struct3507.Enckey = miConfig.EncKey
  441. struct3507.SignKey = miConfig.SignKey
  442. struct3507.SecretKey = miConfig.SecretKey
  443. result, result1, _ := service.FJyb3507(struct3507)
  444. saveLog(result, result1, "3507", "3507")
  445. var respJSON3 map[string]interface{}
  446. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  449. return
  450. }
  451. userJSONBytes3, _ := json.Marshal(respJSON3)
  452. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  453. utils.ErrorLog("解析失败:%v", err)
  454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  455. return
  456. }
  457. if res.Infcode != -1 {
  458. item.IsBg = 0
  459. item.Bchno = ""
  460. item.PcDate = ""
  461. service.SaveW(item)
  462. } else {
  463. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  464. }
  465. }
  466. }
  467. if len(err) == 0 {
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "msg": "删除盘存变更成功",
  470. })
  471. } else {
  472. c.ServeSuccessJSON(map[string]interface{}{
  473. "failed_code": -10,
  474. "msg": err,
  475. })
  476. }
  477. }
  478. func (c *HisApiController) DeleteXSandBG() {
  479. ids := c.GetString("ids")
  480. id_arr := strings.Split(ids, ",")
  481. admin_user_id, _ := c.GetInt64("admin_user_id")
  482. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  483. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  484. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  485. for _, item := range drugs {
  486. if item.IsPc == 1 && item.IsBg == 1 {
  487. var struct3507 models.Struct3507
  488. struct3507.FixmedinsBchno = ""
  489. struct3507.InvDataType = "1"
  490. struct3507.Opter = roles.UserName
  491. struct3507.OrgName = miConfig.OrgName
  492. struct3507.AccessKey = miConfig.AccessKey
  493. struct3507.RequestUrl = miConfig.Url
  494. struct3507.SecretKey = miConfig.SecretKey
  495. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  496. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  497. struct3507.Url = miConfig.Url
  498. struct3507.AppId = miConfig.Cainfo
  499. struct3507.AppSecret = miConfig.AppSecret
  500. struct3507.Enckey = miConfig.EncKey
  501. struct3507.SignKey = miConfig.SignKey
  502. struct3507.SecretKey = miConfig.SecretKey
  503. struct3507.FixmedinsBchno = ""
  504. struct3507.InvDataType = "1"
  505. service.FJyb3507(struct3507)
  506. var struct3507_2 models.Struct3507
  507. struct3507_2.OrgName = miConfig.OrgName
  508. struct3507_2.AccessKey = miConfig.AccessKey
  509. struct3507_2.RequestUrl = miConfig.Url
  510. struct3507_2.SecretKey = miConfig.SecretKey
  511. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  512. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  513. struct3507_2.FixmedinsBchno = ""
  514. struct3507_2.InvDataType = "2"
  515. struct3507_2.Url = miConfig.Url
  516. struct3507_2.AppId = miConfig.Cainfo
  517. struct3507_2.AppSecret = miConfig.AppSecret
  518. struct3507_2.Enckey = miConfig.EncKey
  519. struct3507_2.SignKey = miConfig.SignKey
  520. struct3507_2.SecretKey = miConfig.SecretKey
  521. struct3507_2.FixmedinsBchno = ""
  522. struct3507_2.InvDataType = "1"
  523. service.FJyb3507(struct3507_2)
  524. }
  525. if item.IsPc == 1 && item.IsBg == 0 {
  526. var struct3507 models.Struct3507
  527. struct3507.OrgName = miConfig.OrgName
  528. struct3507.AccessKey = miConfig.AccessKey
  529. struct3507.RequestUrl = miConfig.Url
  530. struct3507.SecretKey = miConfig.SecretKey
  531. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  532. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  533. struct3507.FixmedinsBchno = ""
  534. struct3507.InvDataType = "1"
  535. service.FJyb3507(struct3507)
  536. }
  537. }
  538. }
  539. func (c *HisApiController) ChangeDrug() {
  540. ids := c.GetString("ids")
  541. id_arr := strings.Split(ids, ",")
  542. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  543. admin_user_id, _ := c.GetInt64("admin_user_id")
  544. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  545. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  546. for _, item := range flows {
  547. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  548. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  549. if prescription.OrderStatus == 2 { //已经结算
  550. //判断是否已经销售
  551. if item.IsSale == 1 { //是否已经销售,1是 0否
  552. //是否已经变更 1是 0否
  553. if item.IsChange == 0 { //没变更,进行变更操作
  554. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  555. }
  556. } else { //没销售,
  557. //进行商品销售接口
  558. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "", roles)
  559. if item.IsChange == 0 { //没变更,进行变更操作
  560. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  561. }
  562. }
  563. } else { //还没结算
  564. if item.IsChange == 0 { //没变更,进行变更操作
  565. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  566. }
  567. }
  568. } else if item.ConsumableType == 7 {
  569. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  570. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  571. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  572. //判断是否已经销售
  573. if item.IsSale == 1 { //是否已经销售,1是 0否
  574. //是否已经变更 1是 0否
  575. if item.IsChange == 0 { //没变更,进行变更操作
  576. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  577. }
  578. } else { //没销售,
  579. //进行商品销售退货接口
  580. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  581. if item.IsChange == 0 { //没变更,进行变更操作
  582. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  583. }
  584. }
  585. } else { //还没结算
  586. if item.IsChange == 0 { //没变更,进行变更操作
  587. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  588. }
  589. }
  590. } else { //其他方式
  591. if item.IsChange == 0 { //没变更,进行变更操作
  592. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  593. }
  594. }
  595. }
  596. }
  597. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  598. var struct3502 models.Struct3502
  599. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  600. struct3502.FixmedinsHilistId = miConfig.Code
  601. struct3502.FixmedinsHilistName = miConfig.OrgName
  602. struct3502.FixmedinsCode = miConfig.Code
  603. struct3502.Opter = role.UserName
  604. struct3502.RxFlag = "0"
  605. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  606. struct3502.OrgName = miConfig.OrgName
  607. struct3502.AccessKey = miConfig.AccessKey
  608. struct3502.RequestUrl = miConfig.Url
  609. struct3502.SecretKey = miConfig.SecretKey
  610. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  611. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  612. struct3502.Url = miConfig.Url
  613. struct3502.AppId = miConfig.Cainfo
  614. struct3502.AppSecret = miConfig.AppSecret
  615. struct3502.Enckey = miConfig.EncKey
  616. struct3502.SignKey = miConfig.SignKey
  617. struct3502.SecretKey = miConfig.SecretKey
  618. struct3502.InvChgType = chgType
  619. struct3502.FixmedinsBchno = ""
  620. struct3502.Cnt = strconv.FormatInt(count, 10)
  621. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  622. result1, result2, result3 := service.FJyb3502(struct3502)
  623. fmt.Println(result1)
  624. fmt.Println(result2)
  625. fmt.Println(result3)
  626. }
  627. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  628. var struct3505 models.Struct3505
  629. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  630. struct3505.FixmedinsHilistId = miConfig.Code
  631. struct3505.FixmedinsHilistName = miConfig.OrgName
  632. struct3505.FixmedinsCode = miConfig.Code
  633. struct3505.FixmedinsBchno = ""
  634. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  635. struct3505.PrscDrName = roles.UserName
  636. struct3505.PharName = ""
  637. struct3505.PharPracCertNo = ""
  638. order := service.GetHisOrderByNumber(pre.BatchNumber)
  639. struct3505.SetlId = order.SetlId
  640. struct3505.MdtrtSn = order.MdtrtId
  641. struct3505.ManuLotnum = ""
  642. struct3505.ManuDate = ""
  643. struct3505.ExpyEnd = ""
  644. struct3505.RxFlag = "0"
  645. struct3505.TrdnFlag = "1"
  646. struct3505.Url = miConfig.Url
  647. struct3505.AppId = miConfig.Cainfo
  648. struct3505.AppSecret = miConfig.AppSecret
  649. struct3505.Enckey = miConfig.EncKey
  650. struct3505.SignKey = miConfig.SignKey
  651. struct3505.SecretKey = miConfig.SecretKey
  652. struct3505.RtalDocno = order.Number
  653. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  654. struct3505.SelRetnCnt = strValue
  655. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  656. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  657. struct3505.SelRetnOpterName = roles_two.UserName
  658. if order.IsMedicineInsurance == 1 {
  659. struct3505.MdtrtSetlType = "1"
  660. } else {
  661. struct3505.MdtrtSetlType = "2"
  662. }
  663. struct3505.OrgName = miConfig.OrgName
  664. struct3505.AccessKey = miConfig.AccessKey
  665. struct3505.RequestUrl = miConfig.Url
  666. struct3505.SecretKey = miConfig.SecretKey
  667. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  668. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  669. result1, result2, result3 := service.FJyb3505(struct3505)
  670. fmt.Println(result1)
  671. fmt.Println(result2)
  672. fmt.Println(result3)
  673. }
  674. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  675. var struct3506 models.Struct3506
  676. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  677. struct3506.FixmedinsHilistId = miConfig.Code
  678. struct3506.FixmedinsHilistName = miConfig.OrgName
  679. struct3506.FixmedinsCode = miConfig.Code
  680. struct3506.FixmedinsBchno = ""
  681. order := service.GetHisOrderByNumber(pre.BatchNumber)
  682. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  683. struct3506.ManuLotnum = ""
  684. struct3506.ManuDate = ""
  685. struct3506.MdtrtSn = order.MdtrtId
  686. struct3506.ExpyEnd = ""
  687. struct3506.RxFlag = "0"
  688. struct3506.TrdnFlag = "1"
  689. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  690. struct3506.SelRetnCnt = strValue
  691. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  692. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  693. struct3506.SelRetnOpterName = roles_two.UserName
  694. struct3506.OrgName = miConfig.OrgName
  695. struct3506.AccessKey = miConfig.AccessKey
  696. struct3506.RequestUrl = miConfig.Url
  697. struct3506.SecretKey = miConfig.SecretKey
  698. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  699. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  700. struct3506.Url = miConfig.Url
  701. struct3506.AppId = miConfig.Cainfo
  702. struct3506.AppSecret = miConfig.AppSecret
  703. struct3506.Enckey = miConfig.EncKey
  704. struct3506.SignKey = miConfig.SignKey
  705. struct3506.SecretKey = miConfig.SecretKey
  706. result1, result2, result3 := service.FJyb3506(struct3506)
  707. fmt.Println(result1)
  708. fmt.Println(result2)
  709. fmt.Println(result3)
  710. }
  711. func (c *HisApiController) Get1318() {
  712. adminUser := c.GetAdminUserInfo()
  713. admin_user_id, _ := c.GetInt64("admin_user_id")
  714. code := c.GetString("code")
  715. code = ""
  716. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  717. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  718. api := ""
  719. if miConfig.MdtrtareaAdmvs == "320921" {
  720. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  721. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  722. } else {
  723. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  724. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  725. }
  726. resp, requestErr := http.Get(api)
  727. if requestErr != nil {
  728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  729. return
  730. }
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  735. return
  736. }
  737. var respJSON map[string]interface{}
  738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  741. return
  742. }
  743. //var res Result2406
  744. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  745. result, _ := json.Marshal(respJSON)
  746. if err := json.Unmarshal([]byte(result), &res); err != nil {
  747. utils.ErrorLog("解析失败:%v", err)
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  749. return
  750. }
  751. if res.Infcode == "0" {
  752. c.ServeSuccessJSON(map[string]interface{}{
  753. "result": "",
  754. })
  755. } else {
  756. c.ServeSuccessJSON(map[string]interface{}{
  757. "failed_code": -10,
  758. "msg": res.ErrMsg,
  759. })
  760. */return
  761. //}
  762. }
  763. func (c *HisApiController) Get2503() {
  764. adminUser := c.GetAdminUserInfo()
  765. admin_user_id, _ := c.GetInt64("admin_user_id")
  766. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  767. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  768. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  769. }
  770. func (c *HisApiController) Get2406() {
  771. id, _ := c.GetInt64("id")
  772. record_time := c.GetString("record_time")
  773. his_patient_id, _ := c.GetInt64("his_patient_id")
  774. admin_user_id, _ := c.GetInt64("admin_user_id")
  775. diagnosis_id := c.GetString("diagnosis")
  776. timeLayout := "2006-01-02"
  777. loc, _ := time.LoadLocation("Local")
  778. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  779. if err != nil {
  780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  781. return
  782. }
  783. recordDateTime := theTime.Unix()
  784. adminUser := c.GetAdminUserInfo()
  785. diagnosis_ids := strings.Split(diagnosis_id, ",")
  786. var config []*models.HisXtDiagnoseConfig
  787. for _, item := range diagnosis_ids {
  788. id, _ := strconv.ParseInt(item, 10, 64)
  789. diagnosisConfig, _ := service.FindDiagnoseById(id)
  790. config = append(config, &diagnosisConfig)
  791. }
  792. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  793. fmt.Println(his_patient_id)
  794. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  795. //timestamp := time.Now().Unix()
  796. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  797. var patientPrescription models.HisPrescriptionInfo
  798. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  799. if patientPrescription.ID == 0 {
  800. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  801. }
  802. var res2 Result2406
  803. if miConfig.MdtrtareaAdmvs == "341203" {
  804. data := make(map[string]interface{})
  805. client := &http.Client{}
  806. data["psn_no"] = his.PsnNo
  807. data["mdtrt_id"] = his.Number
  808. data["operator"] = roles.UserName
  809. data["cert_no"] = his.IdCardNo
  810. data["org_name"] = miConfig.OrgName
  811. data["psn_name"] = his.Name
  812. data["ipt_otp_no"] = his.IptOtpNo
  813. data["ipt_psn_sp_flag_type"] = "0901"
  814. data["ipt_psn_sp_flag"] = "1"
  815. data["fixmedins_code"] = miConfig.Code
  816. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  817. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  818. data["url"] = miConfig.Url
  819. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  820. bytesData, _ := json.Marshal(data)
  821. var req *http.Request
  822. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  823. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  824. resp, _ := client.Do(req)
  825. defer resp.Body.Close()
  826. body, ioErr := ioutil.ReadAll(resp.Body)
  827. if ioErr != nil {
  828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return
  831. }
  832. var respJSON map[string]interface{}
  833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  836. return
  837. }
  838. status := respJSON["data"].(map[string]interface{})["status"].(string)
  839. if status == "0" {
  840. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  841. c.ServeSuccessJSON(map[string]interface{}{
  842. "failed_code": -10,
  843. "msg": err_msg,
  844. })
  845. return
  846. }
  847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  848. userJSONBytes, _ := json.Marshal(respJSON)
  849. fmt.Println("log")
  850. fmt.Println(string(userJSONBytes))
  851. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  852. utils.ErrorLog("解析失败:%v", err)
  853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  854. return
  855. }
  856. }
  857. if res2.Infcode != 0 {
  858. adminUser := c.GetAdminUserInfo()
  859. errlog := &models.HisOrderError{
  860. UserOrgId: adminUser.CurrentOrgId,
  861. Ctime: time.Now().Unix(),
  862. Mtime: time.Now().Unix(),
  863. ErrMsg: res2.ErrMsg,
  864. Status: 1,
  865. PatientId: id,
  866. RecordTime: recordDateTime,
  867. Stage: 3,
  868. }
  869. service.CreateErrMsgLog(errlog)
  870. c.ServeSuccessJSON(map[string]interface{}{
  871. "failed_code": -10,
  872. "msg": res2.ErrMsg,
  873. })
  874. return
  875. } else {
  876. c.ServeSuccessJSON(map[string]interface{}{
  877. "msg": "上传成功",
  878. })
  879. return
  880. }
  881. }
  882. func (c *HisApiController) Get4105() {
  883. }
  884. func (c *HisApiController) Post5302() {
  885. patient_id, _ := c.GetInt64("id")
  886. admin_user_id, _ := c.GetInt64("admin_user_id")
  887. p, _ := service.GetHisPatientById(patient_id)
  888. adminUser := c.GetAdminUserInfo()
  889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  890. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  891. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  892. }
  893. func (c *HisApiController) Get4104() {
  894. }
  895. type Output struct {
  896. CertNo string `json:"certno"`
  897. PsnName string `json:"psn_name"`
  898. CardNo string `json:"card_no"`
  899. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  900. CardSN string `json:"card_sn"`
  901. PsnCertType string `json:"psn_cert_type"`
  902. MdtrtCertNo string `json:"mdtrt_cert_no"`
  903. MdtrtCertType string `json:"mdtrt_cert_type"`
  904. QRCode string `json:"qrCode"`
  905. EcToken string `json:"ecToken"`
  906. }
  907. type AHResponse struct {
  908. Body AHBody `json:"body"`
  909. Code int `json:"code"`
  910. CSBCode int `json:"csbCode"`
  911. Message string `json:"message"`
  912. RequestID string `json:"requestId"`
  913. State struct{} `json:"state"`
  914. }
  915. type AHBody struct {
  916. ErrMsg string `json:"err_msg"`
  917. InfRefMsgID string `json:"inf_refmsgid"`
  918. InfCode int `json:"infcode"`
  919. Output struct {
  920. Result []struct {
  921. BasMednFlag string `json:"bas_medn_flag"`
  922. ChldMedcFlag string `json:"chld_medc_flag"`
  923. ChrgitmLv string `json:"chrgitm_lv"`
  924. Cnt float64 `json:"cnt"`
  925. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  926. DrtReimFlag string `json:"drt_reim_flag"`
  927. FeedetlSn string `json:"feedetl_sn"`
  928. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  929. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  930. InscpScpAmt float64 `json:"inscp_scp_amt"`
  931. ListSpItemFlag string `json:"list_sp_item_flag"`
  932. LmtUsedFlag string `json:"lmt_used_flag"`
  933. MedChrgitmType string `json:"med_chrgitm_type"`
  934. Memo string `json:"memo"`
  935. OverlmtAmt float64 `json:"overlmt_amt"`
  936. PreselfpayAmt float64 `json:"preselfpay_amt"`
  937. Pric float64 `json:"pric"`
  938. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  939. SelfpayProp float64 `json:"selfpay_prop"`
  940. } `json:"result"`
  941. } `json:"output"`
  942. }
  943. type Response struct {
  944. Output Output `json:"output"`
  945. Infcode int `json:"infcode"`
  946. InfRefMsgID string `json:"inf_refmsgid"`
  947. RefMsgTime string `json:"refmsg_time"`
  948. RespondTime string `json:"respond_time"`
  949. ErrMsg string `json:"err_msg"`
  950. WarnMsg string `json:"warn_msg"`
  951. SignType string `json:"signtype"`
  952. CAInfo string `json:"cainfo"`
  953. }
  954. func (c *HisApiController) Getquerydata() {
  955. query_type, _ := c.GetInt64("type")
  956. refd_setl_flag := c.GetString("refd_setl_flag")
  957. med_type := c.GetString("med_type")
  958. //admin_user_id,_ := c.GetInt64("admin_user_id")
  959. cert_no := c.GetString("cert_no")
  960. psn_no := c.GetString("psn_no")
  961. start_time := c.GetString("start_time")
  962. end_time := c.GetString("end_time")
  963. page, _ := c.GetInt64("page")
  964. limit, _ := c.GetInt64("limit")
  965. var bp models.BusinessParams5262
  966. bp.RefdSetlFlag = refd_setl_flag
  967. bp.MedType = med_type
  968. bp.Certno = cert_no
  969. bp.Psnno = psn_no
  970. bp.QBegntime = start_time
  971. bp.QEndtime = end_time
  972. if query_type == 1 { //本地
  973. Post5262(c, bp, page, limit)
  974. } else { //异地
  975. Post5267(c, bp, page, limit)
  976. }
  977. }
  978. func (c *HisApiController) Drugscheck() {
  979. admin_user_id, _ := c.GetInt64("admin_user_id")
  980. adminUser := c.GetAdminUserInfo()
  981. var queryResult []QueryResult
  982. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  983. for _, item := range drugs {
  984. result := QueryResult{
  985. ID: item.ID,
  986. Name: item.DrugName,
  987. Code: item.MedicalInsuranceNumber,
  988. List_type_code: "101",
  989. }
  990. queryResult = append(queryResult, result)
  991. }
  992. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  993. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  994. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  995. for _, item := range queryResult {
  996. 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)
  997. }
  998. }
  999. func (c *HisApiController) Goodcheck() {
  1000. admin_user_id, _ := c.GetInt64("admin_user_id")
  1001. adminUser := c.GetAdminUserInfo()
  1002. var queryResult []QueryResult
  1003. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  1004. for _, item := range goods {
  1005. result := QueryResult{
  1006. ID: item.ID,
  1007. Name: item.GoodName,
  1008. Code: item.SocialSecurityDirectoryCode,
  1009. List_type_code: "301",
  1010. }
  1011. queryResult = append(queryResult, result)
  1012. }
  1013. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1014. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1015. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1016. for _, item := range queryResult {
  1017. 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)
  1018. //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)
  1019. }
  1020. }
  1021. func (c *HisApiController) Projectcheck() {
  1022. admin_user_id, _ := c.GetInt64("admin_user_id")
  1023. adminUser := c.GetAdminUserInfo()
  1024. var queryResult []QueryResult
  1025. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  1026. for _, item := range projects {
  1027. result := QueryResult{
  1028. ID: item.ID,
  1029. Name: item.ProjectName,
  1030. Code: item.MedicalCode,
  1031. List_type_code: "201",
  1032. }
  1033. queryResult = append(queryResult, result)
  1034. }
  1035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1036. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1037. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1038. for _, item := range queryResult {
  1039. 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)
  1040. }
  1041. }
  1042. //func (c *HisApiController)CancleDia(){
  1043. //
  1044. // id, _ := c.GetInt64("id")
  1045. // record_time := c.GetString("record_time")
  1046. // his_patient_id, _ := c.GetInt64("his_patient_id")
  1047. //
  1048. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1049. //
  1050. // diagnosis_id := c.GetString("diagnosis")
  1051. // sick_type, _ := c.GetInt64("sick_type")
  1052. // reg_type, _ := c.GetInt64("p_type")
  1053. // begin_time := c.GetString("begin_time")
  1054. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  1055. //
  1056. //
  1057. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  1058. //
  1059. // fmt.Println(acct_used_flag)
  1060. //
  1061. //
  1062. // timeLayout := "2006-01-02"
  1063. // loc, _ := time.LoadLocation("Local")
  1064. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1065. // if err != nil {
  1066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1067. // return
  1068. // }
  1069. // recordDateTime := theTime.Unix()
  1070. // adminUser := c.GetAdminUserInfo()
  1071. //
  1072. //
  1073. //
  1074. //
  1075. //
  1076. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1077. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1078. // var patientPrescription models.HisPrescriptionInfo
  1079. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1080. // if patientPrescription.ID == 0 {
  1081. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1082. // }
  1083. // //if patientPrescription.Do
  1084. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1085. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1086. //
  1087. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1088. //
  1089. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  1090. //
  1091. // var config []*models.HisXtDiagnoseConfig
  1092. // for _, item := range diagnosis_ids {
  1093. // id, _ := strconv.ParseInt(item, 10, 64)
  1094. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  1095. // config = append(config, &diagnosisConfig)
  1096. // }
  1097. //
  1098. // sickConfig, _ := service.FindSickById(sick_type)
  1099. //
  1100. //
  1101. // data := make(map[string]interface{})
  1102. // client := &http.Client{}
  1103. // data["psn_no"] = his.PsnNo
  1104. // data["mdtrt_id"] = his.Number
  1105. // data["doctor"] = roles.UserName
  1106. // data["department"] = department.Name
  1107. // data["org_name"] = miConfig.OrgName
  1108. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  1109. // data["doctor_id"] = doctor_info.DoctorNumber
  1110. // data["new_doctor_name"] = doctor_info.UserName
  1111. // data["fixmedins_code"] = miConfig.Code
  1112. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1113. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1114. // data["secret_key"] = miConfig.SecretKey
  1115. // data["sick_code"] = sickConfig.CountryCode
  1116. // data["sick_name"] = sickConfig.ClassName
  1117. // data["url"] = miConfig.Url
  1118. // data["ak"] = miConfig.AccessKey
  1119. // data["begin_time"] = begin_time
  1120. // data["cainfo"] = miConfig.Cainfo
  1121. // data["is_vaild"] = "0"
  1122. //
  1123. // data["dept"] = strconv.FormatInt(department.ID, 10)
  1124. // data["config"] = config
  1125. // bytesData, _ := json.Marshal(data)
  1126. //
  1127. // var req *http.Request
  1128. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  1129. // resp, _ := client.Do(req)
  1130. // defer resp.Body.Close()
  1131. // body, ioErr := ioutil.ReadAll(resp.Body)
  1132. // if ioErr != nil {
  1133. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1135. // return
  1136. // }
  1137. // var respJSON map[string]interface{}
  1138. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1139. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1141. // return
  1142. // }
  1143. //
  1144. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1145. // userJSONBytes, _ := json.Marshal(respJSON)
  1146. // fmt.Println("log")
  1147. // fmt.Println(string(userJSONBytes))
  1148. //
  1149. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  1150. // utils.ErrorLog("解析失败:%v", err)
  1151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1152. // return
  1153. // }
  1154. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  1155. // res2.Output = ressix10265.Output
  1156. // res2.ErrMsg = ressix10265.ErrMsg
  1157. // res2.Cainfo = ressix10265.Cainfo
  1158. // res2.WarnMsg = ressix10265.WarnMsg
  1159. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1160. // res2.Infcode = infocode
  1161. //
  1162. //}
  1163. func (c *HisApiController) Get4102() {
  1164. order_id, _ := c.GetInt64("order_id")
  1165. admin_user_id, _ := c.GetInt64("admin_user_id")
  1166. stas_type := c.GetString("stas_type")
  1167. order, _ := service.GetHisOrderByIDTwo(order_id)
  1168. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1169. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1170. var pp models.PublicParams
  1171. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1172. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1173. pp.FixmedinsName = miConfig.OrgName
  1174. pp.FixmedinsCode = miConfig.Code
  1175. pp.RequestUrl = miConfig.Url
  1176. pp.Cainfo = miConfig.Cainfo
  1177. pp.SecretKey = miConfig.SecretKey
  1178. pp.AccessKey = miConfig.AccessKey
  1179. pp.OpterName = curRoles.UserName
  1180. if miConfig.MdtrtareaAdmvs == "350500" {
  1181. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1182. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1183. saveLog(result, request, "4102", "清单确认")
  1184. var dat map[string]interface{}
  1185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1186. fmt.Println(dat)
  1187. } else {
  1188. fmt.Println(err)
  1189. }
  1190. var empty ResultFourteen
  1191. userJSONBytes, _ := json.Marshal(dat)
  1192. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1193. utils.ErrorLog("解析失败:%v", err)
  1194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. return
  1196. }
  1197. if empty.Infcode == 0 {
  1198. c.ServeSuccessJSON(map[string]interface{}{
  1199. "msg": "确认成功",
  1200. })
  1201. return
  1202. }
  1203. } else {
  1204. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1205. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1206. result3, request3 := service.Jxyb4105(pp)
  1207. saveLog(result, request, "4102", "清单确认")
  1208. saveLog(result2, request2, "4103", "清单确认")
  1209. saveLog(result3, request3, "4105", "清单统计")
  1210. var dat map[string]interface{}
  1211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1212. fmt.Println(dat)
  1213. } else {
  1214. fmt.Println(err)
  1215. }
  1216. var empty ResultFourteen
  1217. userJSONBytes, _ := json.Marshal(dat)
  1218. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1219. utils.ErrorLog("解析失败:%v", err)
  1220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1221. return
  1222. }
  1223. if empty.Infcode == 0 {
  1224. c.ServeSuccessJSON(map[string]interface{}{
  1225. "msg": "确认成功",
  1226. })
  1227. return
  1228. }
  1229. }
  1230. }
  1231. // 对账权限查询
  1232. func (c *HisApiController) Get3260() {
  1233. admin_user_id, _ := c.GetInt64("admin_user_id")
  1234. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1235. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1236. var api string
  1237. var res models.JSResult3260
  1238. if miConfig.MdtrtareaAdmvs == "320921" {
  1239. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1240. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1241. } else {
  1242. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1243. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1244. }
  1245. resp, requestErr := http.Get(api)
  1246. if requestErr != nil {
  1247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1248. return
  1249. }
  1250. body, ioErr := ioutil.ReadAll(resp.Body)
  1251. if ioErr != nil {
  1252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1254. return
  1255. }
  1256. var respJSON map[string]interface{}
  1257. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1263. result, _ := json.Marshal(respJSON)
  1264. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. if res.Infcode == "0" {
  1270. c.ServeSuccessJSON(map[string]interface{}{
  1271. "result": res.Output.Data,
  1272. })
  1273. } else {
  1274. c.ServeSuccessJSON(map[string]interface{}{
  1275. "failed_code": -10,
  1276. "msg": res.ErrMsg,
  1277. })
  1278. return
  1279. }
  1280. }
  1281. func (c *HisApiController) Get3261() {
  1282. admin_user_id, _ := c.GetInt64("admin_user_id")
  1283. //month := c.GetString("month")
  1284. startTime := c.GetString("start_time")
  1285. //endTime, _ := c.GetString("end_time")
  1286. times := strings.Split(startTime, "-")
  1287. stmt_mon := times[0] + times[1]
  1288. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1289. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1290. var api string
  1291. var res models.JSResult3261
  1292. //var res10265 Result5301For10265
  1293. if miConfig.MdtrtareaAdmvs == "320921" {
  1294. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1295. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1296. } else {
  1297. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1298. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1299. }
  1300. resp, requestErr := http.Get(api)
  1301. if requestErr != nil {
  1302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1303. return
  1304. }
  1305. body, ioErr := ioutil.ReadAll(resp.Body)
  1306. if ioErr != nil {
  1307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1309. return
  1310. }
  1311. var respJSON map[string]interface{}
  1312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1315. return
  1316. }
  1317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1318. result, _ := json.Marshal(respJSON)
  1319. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1320. utils.ErrorLog("解析失败:%v", err)
  1321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1322. return
  1323. }
  1324. if res.Infcode == "0" {
  1325. c.ServeSuccessJSON(map[string]interface{}{
  1326. "result": res.Output,
  1327. })
  1328. } else {
  1329. c.ServeSuccessJSON(map[string]interface{}{
  1330. "failed_code": -10,
  1331. "msg": res.ErrMsg,
  1332. })
  1333. return
  1334. }
  1335. }
  1336. type TempFun struct {
  1337. FundKey string
  1338. FundCode string
  1339. }
  1340. func (c *HisApiController) Get3262() {
  1341. admin_user_id, _ := c.GetInt64("admin_user_id")
  1342. startTime := c.GetString("start_time")
  1343. endTime := c.GetString("end_time")
  1344. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1345. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1346. //timeLayout := "2006-01-02"
  1347. //loc, _ := time.LoadLocation("Local")
  1348. //var theStartTIme int64
  1349. //if len(startTime) > 0 {
  1350. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1351. // if err != nil {
  1352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1353. // return
  1354. // }
  1355. // theStartTIme = theTime.Unix()
  1356. //}
  1357. //var theEndtTIme int64
  1358. //if len(endTime) > 0 {
  1359. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1360. // if err != nil {
  1361. // utils.ErrorLog(err.Error())
  1362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1363. // return
  1364. // }
  1365. // theEndtTIme = theTime.Unix()
  1366. //}
  1367. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1368. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1369. for _, team := range datas {
  1370. fmt.Println(team.PsnTime)
  1371. for _, team_two := range datas_two {
  1372. fmt.Println(team_two.PsnTime)
  1373. if team.FundKey == team_two.FundKey {
  1374. fmt.Println(team_two.PsnTime)
  1375. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1376. fmt.Println(team.PsnTime)
  1377. }
  1378. }
  1379. }
  1380. fmt.Println("1111")
  1381. fmt.Println(datas)
  1382. fmt.Println("1111")
  1383. var twos []models.FixMonRecDetailFileInTwo
  1384. for _, team := range datas {
  1385. var two models.FixMonRecDetailFileInTwo
  1386. two.MedType = team.MedType
  1387. two.Insutype = team.Insutype
  1388. two.PsnType = team.PsnType
  1389. two.MedType = team.MedType
  1390. two.FixBlngAdmdvs = "999999"
  1391. two.InsuAdmdvs = "555555"
  1392. two.PsnTime = team.PsnTime
  1393. two.PsnCnt = team.PsnCnt
  1394. two.FundKey = team.FundKey
  1395. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1396. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1397. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1398. two.MedfeeSumAmt = ms
  1399. two.InscpAmt = ia
  1400. two.FundPaySumAmt = fps
  1401. twos = append(twos, two)
  1402. }
  1403. //startTime := c.GetString("start_time")
  1404. //endTime, _ := c.GetString("end_time")
  1405. times := strings.Split(startTime, "-")
  1406. stmt_mon := times[0] + times[1]
  1407. var funs []models.FundDetail
  1408. for _, item := range datas {
  1409. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1410. funs = append(funs, fun...)
  1411. }
  1412. var funInfos []models.Fund
  1413. //for _, item := range funs {
  1414. // var rf []models.FundInfo
  1415. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1416. // for _, subitem := range rf {
  1417. // var fund models.Fund
  1418. // fund.FundCode = subitem.FundPayType
  1419. // fund.FundName = subitem.FundPayTypeName
  1420. // fund.FundAmt = subitem.FundPayAmt
  1421. // fund.FundKey = item.FundKey
  1422. // fund.InsuAdmdvs = "555555"
  1423. // fund.FixBlngAdmdvs = "999999"
  1424. // funInfos = append(funInfos, fund)
  1425. // }
  1426. //}
  1427. var tempFuns []TempFun
  1428. for _, funInfo := range funInfos {
  1429. var tempFun TempFun
  1430. tempFun.FundKey = funInfo.FundKey
  1431. tempFun.FundCode = funInfo.FundCode
  1432. tempFuns = append(tempFuns, tempFun)
  1433. }
  1434. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1435. fmt.Println(tempFuns)
  1436. var funInfosTwo []models.Fund
  1437. decimal.DivisionPrecision = 2
  1438. for _, item := range tempFuns {
  1439. var fund models.Fund
  1440. for _, subItem := range funInfos {
  1441. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1442. fund.FundKey = subItem.FundKey
  1443. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1444. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1445. fund.FundName = subItem.FundName
  1446. fund.FundCode = subItem.FundCode
  1447. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1448. }
  1449. }
  1450. funInfosTwo = append(funInfosTwo, fund)
  1451. }
  1452. fmt.Println("funInfosTwo")
  1453. fmt.Println(funInfosTwo)
  1454. var upld_btch string
  1455. var empty models.JSResultEmpty
  1456. data := make(map[string]interface{})
  1457. data["org_name"] = miConfig.OrgName
  1458. data["doctor"] = curRoles.UserName
  1459. data["doctor_name"] = curRoles.UserName
  1460. data["fixmedins_code"] = miConfig.Code
  1461. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1462. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1463. data["secret_key"] = miConfig.SecretKey
  1464. data["url"] = miConfig.Url
  1465. data["ak"] = miConfig.AccessKey
  1466. data["cainfo"] = miConfig.Cainfo
  1467. data["datas"] = twos
  1468. data["fund"] = funInfosTwo
  1469. fmt.Println(twos)
  1470. month := time.Unix(1557042972, 0).Format("1")
  1471. year := time.Now().Format("2006")
  1472. month = time.Now().Format("01")
  1473. day := time.Now().Format("02")
  1474. hour := time.Now().Format("15")
  1475. min := time.Now().Format("04")
  1476. sec := time.Now().Format("05")
  1477. fix_fill_date := year + month + day + hour + min + sec
  1478. data["fix_fill_dept"] = miConfig.OrgName
  1479. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1480. data["fix_fill_psn"] = curRoles.UserName
  1481. data["fix_fill_date"] = fix_fill_date
  1482. data["stmt_loc"] = "2"
  1483. data["setl_mon"] = stmt_mon
  1484. upld_btch = "0"
  1485. data["upld_btch"] = upld_btch
  1486. //fmt.Println(data)
  1487. client := &http.Client{}
  1488. bytesData, _ := json.Marshal(data)
  1489. var req *http.Request
  1490. if miConfig.MdtrtareaAdmvs == "320921" {
  1491. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1492. } else {
  1493. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1494. }
  1495. resp, _ := client.Do(req)
  1496. defer resp.Body.Close()
  1497. body, ioErr := ioutil.ReadAll(resp.Body)
  1498. if ioErr != nil {
  1499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1501. }
  1502. var respJSON map[string]interface{}
  1503. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1506. }
  1507. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1508. //fmt.Println(respJSON)
  1509. result, _ := json.Marshal(respJSON)
  1510. //fmt.Println(result)
  1511. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1512. utils.ErrorLog("解析失败:%v", err)
  1513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1514. }
  1515. if empty.Infcode != "0" {
  1516. c.ServeSuccessJSON(map[string]interface{}{
  1517. "failed_code": -10,
  1518. "msg": empty.ErrMsg,
  1519. })
  1520. return
  1521. } else {
  1522. c.ServeSuccessJSON(map[string]interface{}{
  1523. "msg": "上传成功",
  1524. })
  1525. return
  1526. }
  1527. }
  1528. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1529. newArr = make([]TempFun, 0)
  1530. for i := 0; i < len(arr); i++ {
  1531. repeat := false
  1532. for j := i + 1; j < len(arr); j++ {
  1533. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1534. repeat = true
  1535. break
  1536. }
  1537. }
  1538. if !repeat {
  1539. newArr = append(newArr, arr[i])
  1540. }
  1541. }
  1542. return
  1543. }
  1544. func (c *HisApiController) Get3263() {
  1545. admin_user_id, _ := c.GetInt64("admin_user_id")
  1546. startTime := c.GetString("start_time")
  1547. //endTime, _ := c.GetString("end_time")
  1548. times := strings.Split(startTime, "-")
  1549. setl_mon := times[0] + times[1]
  1550. upld_btch := "0"
  1551. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1552. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1553. var result3263 models.JSResult3263
  1554. data := make(map[string]interface{})
  1555. data["org_name"] = miConfig.OrgName
  1556. data["doctor"] = curRoles.UserName
  1557. data["doctor_name"] = curRoles.UserName
  1558. data["fixmedins_code"] = miConfig.Code
  1559. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1560. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1561. data["secret_key"] = miConfig.SecretKey
  1562. data["url"] = miConfig.Url
  1563. data["ak"] = miConfig.AccessKey
  1564. data["cainfo"] = miConfig.Cainfo
  1565. data["setl_mon"] = setl_mon
  1566. data["stmt_loc"] = "2"
  1567. data["upld_btch"] = upld_btch
  1568. client := &http.Client{}
  1569. bytesData, _ := json.Marshal(data)
  1570. var req *http.Request
  1571. if miConfig.MdtrtareaAdmvs == "320921" {
  1572. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1573. } else {
  1574. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1575. }
  1576. resp, _ := client.Do(req)
  1577. defer resp.Body.Close()
  1578. body, ioErr := ioutil.ReadAll(resp.Body)
  1579. if ioErr != nil {
  1580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1582. }
  1583. var respJSON map[string]interface{}
  1584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1587. }
  1588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1589. fmt.Println(respJSON)
  1590. result, _ := json.Marshal(respJSON)
  1591. fmt.Println(result)
  1592. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1593. utils.ErrorLog("解析失败:%v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. }
  1596. if result3263.Infcode != "0" {
  1597. c.ServeSuccessJSON(map[string]interface{}{
  1598. "failed_code": -10,
  1599. "msg": result3263.ErrMsg,
  1600. })
  1601. return
  1602. } else {
  1603. c.ServeSuccessJSON(map[string]interface{}{
  1604. "list": result3263.Output,
  1605. })
  1606. return
  1607. }
  1608. }
  1609. func (c *HisApiController) Get3264() {
  1610. admin_user_id, _ := c.GetInt64("admin_user_id")
  1611. startTime := c.GetString("start_time")
  1612. //endTime, _ := c.GetString("end_time")
  1613. times := strings.Split(startTime, "-")
  1614. setl_mon := times[0] + times[1]
  1615. upld_btch := "0"
  1616. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1617. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1618. //solidify_id := []
  1619. var result3263 models.JSResult3263
  1620. data := make(map[string]interface{})
  1621. data["org_name"] = miConfig.OrgName
  1622. data["doctor"] = curRoles.UserName
  1623. data["doctor_name"] = curRoles.UserName
  1624. data["fixmedins_code"] = miConfig.Code
  1625. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1626. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1627. data["secret_key"] = miConfig.SecretKey
  1628. data["url"] = miConfig.Url
  1629. data["ak"] = miConfig.AccessKey
  1630. data["cainfo"] = miConfig.Cainfo
  1631. data["setl_mon"] = setl_mon
  1632. data["stmt_loc"] = "2"
  1633. data["upld_btch"] = upld_btch
  1634. client := &http.Client{}
  1635. bytesData, _ := json.Marshal(data)
  1636. var req3263 *http.Request
  1637. if miConfig.MdtrtareaAdmvs == "320921" {
  1638. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1639. } else {
  1640. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1641. }
  1642. resp, _ := client.Do(req3263)
  1643. defer resp.Body.Close()
  1644. body, ioErr := ioutil.ReadAll(resp.Body)
  1645. if ioErr != nil {
  1646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1648. }
  1649. var respJSON3263 map[string]interface{}
  1650. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1653. }
  1654. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1655. fmt.Println(respJSON3263)
  1656. result, _ := json.Marshal(respJSON3263)
  1657. fmt.Println(result)
  1658. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1659. utils.ErrorLog("解析失败:%v", err)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. }
  1662. var ids []string
  1663. for _, item := range result3263.Output {
  1664. ids = append(ids, item.SolidifyID)
  1665. }
  1666. var empty models.JSResultEmpty
  1667. data2 := make(map[string]interface{})
  1668. data2["org_name"] = miConfig.OrgName
  1669. data2["doctor"] = curRoles.UserName
  1670. data2["doctor_name"] = curRoles.UserName
  1671. data2["fixmedins_code"] = miConfig.Code
  1672. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1673. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1674. data2["secret_key"] = miConfig.SecretKey
  1675. data2["url"] = miConfig.Url
  1676. data2["ak"] = miConfig.AccessKey
  1677. data2["cainfo"] = miConfig.Cainfo
  1678. data2["setl_mon"] = setl_mon
  1679. data2["stmt_loc"] = "2"
  1680. data2["upld_btch"] = upld_btch
  1681. data2["solidify_id"] = ids
  1682. client2 := &http.Client{}
  1683. bytesData2, _ := json.Marshal(data2)
  1684. var req *http.Request
  1685. if miConfig.MdtrtareaAdmvs == "320921" {
  1686. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1687. } else {
  1688. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1689. }
  1690. resp2, _ := client2.Do(req)
  1691. defer resp.Body.Close()
  1692. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1693. if ioErr2 != nil {
  1694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1696. }
  1697. var respJSON map[string]interface{}
  1698. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1701. }
  1702. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1703. fmt.Println(respJSON)
  1704. result2, _ := json.Marshal(respJSON)
  1705. fmt.Println(result2)
  1706. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1707. utils.ErrorLog("解析失败:%v", err)
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1709. }
  1710. if empty.Infcode != "0" {
  1711. c.ServeSuccessJSON(map[string]interface{}{
  1712. "failed_code": -10,
  1713. "msg": empty.ErrMsg,
  1714. })
  1715. return
  1716. } else {
  1717. c.ServeSuccessJSON(map[string]interface{}{
  1718. "msg": "",
  1719. })
  1720. return
  1721. }
  1722. }
  1723. func (c *HisApiController) Get3265() {
  1724. admin_user_id, _ := c.GetInt64("admin_user_id")
  1725. startTime := c.GetString("start_time")
  1726. //endTime, _ := c.GetString("end_time")
  1727. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1728. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1729. times := strings.Split(startTime, "-")
  1730. setl_mon := times[0] + times[1]
  1731. var upld_btch string
  1732. upld_btch = "0"
  1733. //var empty models.JSResultEmpty
  1734. var result3265 models.JSResult3264
  1735. var result3263 models.JSResult3263
  1736. data2 := make(map[string]interface{})
  1737. data2["org_name"] = miConfig.OrgName
  1738. data2["doctor"] = curRoles.UserName
  1739. data2["doctor_name"] = curRoles.UserName
  1740. data2["fixmedins_code"] = miConfig.Code
  1741. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1742. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1743. data2["secret_key"] = miConfig.SecretKey
  1744. data2["url"] = miConfig.Url
  1745. data2["ak"] = miConfig.AccessKey
  1746. data2["cainfo"] = miConfig.Cainfo
  1747. data2["setl_mon"] = setl_mon
  1748. data2["stmt_loc"] = "2"
  1749. data2["upld_btch"] = upld_btch
  1750. client2 := &http.Client{}
  1751. bytesData2, _ := json.Marshal(data2)
  1752. var req3263 *http.Request
  1753. if miConfig.MdtrtareaAdmvs == "320921" {
  1754. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1755. } else {
  1756. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1757. }
  1758. resp2, _ := client2.Do(req3263)
  1759. defer resp2.Body.Close()
  1760. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1761. if ioErr2 != nil {
  1762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1764. }
  1765. var respJSON3263 map[string]interface{}
  1766. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. }
  1770. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1771. fmt.Println(respJSON3263)
  1772. result2, _ := json.Marshal(respJSON3263)
  1773. fmt.Println(result2)
  1774. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. }
  1778. var ids []string
  1779. for _, item := range result3263.Output {
  1780. ids = append(ids, item.SolidifyID)
  1781. }
  1782. data := make(map[string]interface{})
  1783. data["org_name"] = miConfig.OrgName
  1784. data["doctor"] = curRoles.UserName
  1785. data["doctor_name"] = curRoles.UserName
  1786. data["fixmedins_code"] = miConfig.Code
  1787. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1788. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1789. data["secret_key"] = miConfig.SecretKey
  1790. data["url"] = miConfig.Url
  1791. data["ak"] = miConfig.AccessKey
  1792. data["cainfo"] = miConfig.Cainfo
  1793. data["setl_mon"] = setl_mon
  1794. data["solidify_id"] = ids
  1795. month := time.Unix(1557042972, 0).Format("1")
  1796. year := time.Now().Format("2006")
  1797. month = time.Now().Format("01")
  1798. day := time.Now().Format("02")
  1799. hour := time.Now().Format("15")
  1800. min := time.Now().Format("04")
  1801. sec := time.Now().Format("05")
  1802. fix_fill_date := year + month + day + hour + min + sec
  1803. data["fix_fill_dept"] = miConfig.OrgName
  1804. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1805. data["fix_fill_psn"] = curRoles.UserName
  1806. data["fix_fill_date"] = fix_fill_date
  1807. data["stmt_loc"] = "2"
  1808. data["upld_btch"] = upld_btch
  1809. client := &http.Client{}
  1810. bytesData, _ := json.Marshal(data)
  1811. var req *http.Request
  1812. if miConfig.MdtrtareaAdmvs == "320921" {
  1813. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1814. } else {
  1815. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1816. }
  1817. resp, _ := client.Do(req)
  1818. defer resp.Body.Close()
  1819. body, ioErr := ioutil.ReadAll(resp.Body)
  1820. if ioErr != nil {
  1821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. }
  1824. var respJSON map[string]interface{}
  1825. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. }
  1829. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1830. fmt.Println(respJSON)
  1831. result, _ := json.Marshal(respJSON)
  1832. fmt.Println(result)
  1833. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1834. utils.ErrorLog("解析失败:%v", err)
  1835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1836. }
  1837. if result3265.Infcode != "0" {
  1838. c.ServeSuccessJSON(map[string]interface{}{
  1839. "failed_code": -10,
  1840. "msg": result3265.ErrMsg,
  1841. })
  1842. return
  1843. } else {
  1844. c.ServeSuccessJSON(map[string]interface{}{
  1845. "info": result3265.Output,
  1846. })
  1847. return
  1848. }
  1849. }
  1850. func (c *HisApiController) Get3266() {
  1851. admin_user_id, _ := c.GetInt64("admin_user_id")
  1852. startTime := c.GetString("start_time")
  1853. //endTime, _ := c.GetString("end_time")
  1854. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1855. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1856. times := strings.Split(startTime, "-")
  1857. stmt_mon := times[0] + times[1]
  1858. var upld_btch string
  1859. //var empty models.JSResultEmpty
  1860. var result3265 models.JSResult3264
  1861. data := make(map[string]interface{})
  1862. data["org_name"] = miConfig.OrgName
  1863. data["doctor"] = curRoles.UserName
  1864. data["doctor_name"] = curRoles.UserName
  1865. data["fixmedins_code"] = miConfig.Code
  1866. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1867. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1868. data["secret_key"] = miConfig.SecretKey
  1869. data["url"] = miConfig.Url
  1870. data["ak"] = miConfig.AccessKey
  1871. data["cainfo"] = miConfig.Cainfo
  1872. data["setl_mon"] = stmt_mon
  1873. month := time.Unix(1557042972, 0).Format("1")
  1874. year := time.Now().Format("2006")
  1875. month = time.Now().Format("01")
  1876. day := time.Now().Format("02")
  1877. hour := time.Now().Format("15")
  1878. min := time.Now().Format("04")
  1879. sec := time.Now().Format("05")
  1880. fix_fill_date := year + month + day + hour + min + sec
  1881. data["fix_fill_dept"] = miConfig.OrgName
  1882. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1883. data["fix_fill_psn"] = curRoles.UserName
  1884. data["fix_fill_date"] = fix_fill_date
  1885. data["stmt_loc"] = "2"
  1886. upld_btch = "0"
  1887. data["upld_btch"] = upld_btch
  1888. client := &http.Client{}
  1889. bytesData, _ := json.Marshal(data)
  1890. var req *http.Request
  1891. if miConfig.MdtrtareaAdmvs == "320921" {
  1892. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1893. } else {
  1894. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1895. }
  1896. resp, _ := client.Do(req)
  1897. defer resp.Body.Close()
  1898. body, ioErr := ioutil.ReadAll(resp.Body)
  1899. if ioErr != nil {
  1900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1902. }
  1903. var respJSON map[string]interface{}
  1904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1907. }
  1908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1909. fmt.Println(respJSON)
  1910. result, _ := json.Marshal(respJSON)
  1911. fmt.Println(result)
  1912. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1913. utils.ErrorLog("解析失败:%v", err)
  1914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1915. }
  1916. if result3265.Infcode != "0" {
  1917. c.ServeSuccessJSON(map[string]interface{}{
  1918. "failed_code": -10,
  1919. "msg": result3265.ErrMsg,
  1920. })
  1921. return
  1922. } else {
  1923. c.ServeSuccessJSON(map[string]interface{}{
  1924. "info": result3265.Output,
  1925. })
  1926. return
  1927. }
  1928. }
  1929. func (c *HisApiController) Get3267() {
  1930. admin_user_id, _ := c.GetInt64("admin_user_id")
  1931. startTime := c.GetString("start_time")
  1932. //endTime, _ := c.GetString("end_time")
  1933. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1934. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1935. times := strings.Split(startTime, "-")
  1936. setl_mon := times[0] + times[1]
  1937. var upld_btch string
  1938. //var empty models.JSResultEmpty
  1939. var result3265 models.JSResult3264
  1940. upld_btch = "0"
  1941. data := make(map[string]interface{})
  1942. data["org_name"] = miConfig.OrgName
  1943. data["doctor"] = curRoles.UserName
  1944. data["doctor_name"] = curRoles.UserName
  1945. data["fixmedins_code"] = miConfig.Code
  1946. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1947. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1948. data["secret_key"] = miConfig.SecretKey
  1949. data["url"] = miConfig.Url
  1950. data["ak"] = miConfig.AccessKey
  1951. data["cainfo"] = miConfig.Cainfo
  1952. data["setl_mon"] = setl_mon
  1953. data["stmt_loc"] = "2"
  1954. data["upld_btch"] = upld_btch
  1955. client := &http.Client{}
  1956. bytesData, _ := json.Marshal(data)
  1957. var req *http.Request
  1958. if miConfig.MdtrtareaAdmvs == "320921" {
  1959. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1960. } else {
  1961. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1962. }
  1963. resp, _ := client.Do(req)
  1964. defer resp.Body.Close()
  1965. body, ioErr := ioutil.ReadAll(resp.Body)
  1966. if ioErr != nil {
  1967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1969. }
  1970. var respJSON map[string]interface{}
  1971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1974. }
  1975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1976. fmt.Println(respJSON)
  1977. result, _ := json.Marshal(respJSON)
  1978. fmt.Println(result)
  1979. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1980. utils.ErrorLog("解析失败:%v", err)
  1981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1982. }
  1983. if result3265.Infcode != "0" {
  1984. c.ServeSuccessJSON(map[string]interface{}{
  1985. "failed_code": -10,
  1986. "msg": result3265.ErrMsg,
  1987. })
  1988. return
  1989. } else {
  1990. c.ServeSuccessJSON(map[string]interface{}{
  1991. "info": result3265.Output.Data,
  1992. })
  1993. return
  1994. }
  1995. }
  1996. func (c *HisApiController) Get3268() {
  1997. admin_user_id, _ := c.GetInt64("admin_user_id")
  1998. startTime := c.GetString("start_time")
  1999. endTime := c.GetString("end_time")
  2000. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2001. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2002. times := strings.Split(startTime, "-")
  2003. setl_mon := times[0] + times[1]
  2004. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2005. var twos []models.FixMonRecDetailFileInTwo
  2006. var funs []models.FundDetail
  2007. for _, item := range datas {
  2008. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2009. funs = append(funs, fun...)
  2010. }
  2011. var funInfos []models.Fund
  2012. //for _, item := range funs {
  2013. // var rf []models.FundInfo
  2014. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2015. // for _, subitem := range rf {
  2016. // var fund models.Fund
  2017. // fund.FundCode = subitem.FundPayType
  2018. // fund.FundName = subitem.FundPayTypeName
  2019. // fund.FundAmt = subitem.FundPayAmt
  2020. // fund.FundKey = item.FundKey
  2021. // fund.InsuAdmdvs = "555555"
  2022. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  2023. // funInfos = append(funInfos, fund)
  2024. // }
  2025. //}
  2026. for _, team := range datas {
  2027. var two models.FixMonRecDetailFileInTwo
  2028. two.SetlDate = time.Now().Format("2006-01-02")
  2029. two.MedType = team.MedType
  2030. two.Insutype = team.Insutype
  2031. two.PsnType = team.PsnType
  2032. two.MedType = team.MedType
  2033. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  2034. two.InsuAdmdvs = team.InsuAdmdvs
  2035. two.PsnTime = team.PsnTime
  2036. two.PsnCnt = team.PsnCnt
  2037. two.FundKey = team.FundKey
  2038. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2039. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2040. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2041. two.MedfeeSumAmt = ms
  2042. two.InscpAmt = ia
  2043. two.FundPaySumAmt = fps
  2044. twos = append(twos, two)
  2045. }
  2046. var upld_btch string
  2047. upld_btch = "0"
  2048. var empty models.JSResultEmpty
  2049. data := make(map[string]interface{})
  2050. data["org_name"] = miConfig.OrgName
  2051. data["doctor"] = curRoles.UserName
  2052. data["doctor_name"] = curRoles.UserName
  2053. data["fixmedins_code"] = miConfig.Code
  2054. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2055. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2056. data["secret_key"] = miConfig.SecretKey
  2057. data["url"] = miConfig.Url
  2058. data["ak"] = miConfig.AccessKey
  2059. data["cainfo"] = miConfig.Cainfo
  2060. data["datas"] = twos
  2061. data["fund"] = funInfos
  2062. data["setl_mon"] = setl_mon
  2063. month := time.Unix(1557042972, 0).Format("1")
  2064. year := time.Now().Format("2006")
  2065. month = time.Now().Format("01")
  2066. day := time.Now().Format("02")
  2067. hour := time.Now().Format("15")
  2068. min := time.Now().Format("04")
  2069. sec := time.Now().Format("05")
  2070. fix_fill_date := year + month + day + hour + min + sec
  2071. data["fix_fill_dept"] = miConfig.OrgName
  2072. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2073. data["fix_fill_psn"] = curRoles.UserName
  2074. data["fix_fill_date"] = fix_fill_date
  2075. data["stmt_loc"] = "2"
  2076. data["upld_btch"] = upld_btch
  2077. client := &http.Client{}
  2078. bytesData, _ := json.Marshal(data)
  2079. var req *http.Request
  2080. if miConfig.MdtrtareaAdmvs == "320921" {
  2081. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2082. } else {
  2083. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2084. }
  2085. resp, _ := client.Do(req)
  2086. defer resp.Body.Close()
  2087. body, ioErr := ioutil.ReadAll(resp.Body)
  2088. if ioErr != nil {
  2089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2091. }
  2092. var respJSON map[string]interface{}
  2093. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2096. }
  2097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2098. fmt.Println(respJSON)
  2099. result, _ := json.Marshal(respJSON)
  2100. fmt.Println(result)
  2101. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2102. utils.ErrorLog("解析失败:%v", err)
  2103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2104. }
  2105. if empty.Infcode != "0" {
  2106. c.ServeSuccessJSON(map[string]interface{}{
  2107. "failed_code": -10,
  2108. "msg": empty.ErrMsg,
  2109. })
  2110. return
  2111. } else {
  2112. c.ServeSuccessJSON(map[string]interface{}{
  2113. "msg": "上传成功",
  2114. })
  2115. return
  2116. }
  2117. }
  2118. func (c *HisApiController) Get3269() {
  2119. admin_user_id, _ := c.GetInt64("admin_user_id")
  2120. startTime := c.GetString("start_time")
  2121. //endTime, _ := c.GetString("end_time")
  2122. times := strings.Split(startTime, "-")
  2123. setl_mon := times[0] + times[1]
  2124. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2125. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2126. var result3263 models.JSResult3263
  2127. data := make(map[string]interface{})
  2128. data["org_name"] = miConfig.OrgName
  2129. data["doctor"] = curRoles.UserName
  2130. data["doctor_name"] = curRoles.UserName
  2131. data["fixmedins_code"] = miConfig.Code
  2132. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2133. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2134. data["secret_key"] = miConfig.SecretKey
  2135. data["url"] = miConfig.Url
  2136. data["ak"] = miConfig.AccessKey
  2137. data["cainfo"] = miConfig.Cainfo
  2138. data["setl_mon"] = setl_mon
  2139. data["stmt_loc"] = "2"
  2140. client := &http.Client{}
  2141. bytesData, _ := json.Marshal(data)
  2142. var req *http.Request
  2143. if miConfig.MdtrtareaAdmvs == "320921" {
  2144. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2145. } else {
  2146. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2147. }
  2148. resp, _ := client.Do(req)
  2149. defer resp.Body.Close()
  2150. body, ioErr := ioutil.ReadAll(resp.Body)
  2151. if ioErr != nil {
  2152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2154. }
  2155. var respJSON map[string]interface{}
  2156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. }
  2160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2161. fmt.Println(respJSON)
  2162. result, _ := json.Marshal(respJSON)
  2163. fmt.Println(result)
  2164. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2165. utils.ErrorLog("解析失败:%v", err)
  2166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. }
  2168. if result3263.Infcode != "0" {
  2169. c.ServeSuccessJSON(map[string]interface{}{
  2170. "failed_code": -10,
  2171. "msg": result3263.ErrMsg,
  2172. })
  2173. return
  2174. } else {
  2175. c.ServeSuccessJSON(map[string]interface{}{
  2176. "msg": "上传成功",
  2177. })
  2178. return
  2179. }
  2180. }
  2181. func (c *HisApiController) Get3270() {
  2182. admin_user_id, _ := c.GetInt64("admin_user_id")
  2183. startTime := c.GetString("start_time")
  2184. //endTime, _ := c.GetString("end_time")
  2185. times := strings.Split(startTime, "-")
  2186. setl_mon := times[0] + times[1]
  2187. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2189. var result3263 models.JSResult3263
  2190. data2 := make(map[string]interface{})
  2191. data2["org_name"] = miConfig.OrgName
  2192. data2["doctor"] = curRoles.UserName
  2193. data2["doctor_name"] = curRoles.UserName
  2194. data2["fixmedins_code"] = miConfig.Code
  2195. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2196. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2197. data2["secret_key"] = miConfig.SecretKey
  2198. data2["url"] = miConfig.Url
  2199. data2["ak"] = miConfig.AccessKey
  2200. data2["cainfo"] = miConfig.Cainfo
  2201. data2["setl_mon"] = setl_mon
  2202. data2["stmt_loc"] = "2"
  2203. client2 := &http.Client{}
  2204. bytesData2, _ := json.Marshal(data2)
  2205. var req3263 *http.Request
  2206. if miConfig.MdtrtareaAdmvs == "320921" {
  2207. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2208. } else {
  2209. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2210. }
  2211. resp2, _ := client2.Do(req3263)
  2212. defer resp2.Body.Close()
  2213. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2214. if ioErr2 != nil {
  2215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2217. }
  2218. var respJSON3263 map[string]interface{}
  2219. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2222. }
  2223. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2224. fmt.Println(respJSON3263)
  2225. result2, _ := json.Marshal(respJSON3263)
  2226. fmt.Println(result2)
  2227. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2228. utils.ErrorLog("解析失败:%v", err)
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2230. }
  2231. var ids []string
  2232. for _, item := range result3263.Output {
  2233. ids = append(ids, item.SolidifyID)
  2234. }
  2235. var result3264 models.JSResult3264
  2236. data := make(map[string]interface{})
  2237. data["org_name"] = miConfig.OrgName
  2238. data["doctor"] = curRoles.UserName
  2239. data["doctor_name"] = curRoles.UserName
  2240. data["fixmedins_code"] = miConfig.Code
  2241. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2242. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2243. data["secret_key"] = miConfig.SecretKey
  2244. data["url"] = miConfig.Url
  2245. data["ak"] = miConfig.AccessKey
  2246. data["cainfo"] = miConfig.Cainfo
  2247. data["setl_mon"] = setl_mon
  2248. data["stmt_loc"] = "2"
  2249. data["solidify_id"] = ids
  2250. client := &http.Client{}
  2251. bytesData, _ := json.Marshal(data)
  2252. var req *http.Request
  2253. if miConfig.MdtrtareaAdmvs == "320921" {
  2254. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2255. } else {
  2256. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2257. }
  2258. resp, _ := client.Do(req)
  2259. defer resp.Body.Close()
  2260. body, ioErr := ioutil.ReadAll(resp.Body)
  2261. if ioErr != nil {
  2262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2264. }
  2265. var respJSON map[string]interface{}
  2266. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2269. }
  2270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2271. fmt.Println(respJSON)
  2272. result, _ := json.Marshal(respJSON)
  2273. fmt.Println(result)
  2274. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2275. utils.ErrorLog("解析失败:%v", err)
  2276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2277. }
  2278. if result3264.Infcode != "0" {
  2279. c.ServeSuccessJSON(map[string]interface{}{
  2280. "failed_code": -10,
  2281. "msg": result3264.ErrMsg,
  2282. })
  2283. return
  2284. } else {
  2285. c.ServeSuccessJSON(map[string]interface{}{
  2286. "info": result3264.Output,
  2287. })
  2288. return
  2289. }
  2290. }
  2291. func (c *HisApiController) Get3271() {
  2292. admin_user_id, _ := c.GetInt64("admin_user_id")
  2293. startTime := c.GetString("start_time")
  2294. //endTime, _ := c.GetString("end_time")
  2295. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2297. times := strings.Split(startTime, "-")
  2298. setl_mon := times[0] + times[1]
  2299. //var empty models.JSResultEmpty
  2300. var result3265 models.JSResult3264
  2301. var result3263 models.JSResult3263
  2302. data2 := make(map[string]interface{})
  2303. data2["org_name"] = miConfig.OrgName
  2304. data2["doctor"] = curRoles.UserName
  2305. data2["doctor_name"] = curRoles.UserName
  2306. data2["fixmedins_code"] = miConfig.Code
  2307. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2308. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2309. data2["secret_key"] = miConfig.SecretKey
  2310. data2["url"] = miConfig.Url
  2311. data2["ak"] = miConfig.AccessKey
  2312. data2["cainfo"] = miConfig.Cainfo
  2313. data2["setl_mon"] = setl_mon
  2314. data2["stmt_loc"] = "2"
  2315. client2 := &http.Client{}
  2316. bytesData2, _ := json.Marshal(data2)
  2317. var req3263 *http.Request
  2318. if miConfig.MdtrtareaAdmvs == "320921" {
  2319. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2320. } else {
  2321. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2322. }
  2323. resp2, _ := client2.Do(req3263)
  2324. defer resp2.Body.Close()
  2325. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2326. if ioErr2 != nil {
  2327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2329. }
  2330. var respJSON3263 map[string]interface{}
  2331. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2334. }
  2335. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2336. fmt.Println(respJSON3263)
  2337. result2, _ := json.Marshal(respJSON3263)
  2338. fmt.Println(result2)
  2339. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2340. utils.ErrorLog("解析失败:%v", err)
  2341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2342. }
  2343. var ids []string
  2344. for _, item := range result3263.Output {
  2345. ids = append(ids, item.SolidifyID)
  2346. }
  2347. data := make(map[string]interface{})
  2348. data["org_name"] = miConfig.OrgName
  2349. data["doctor"] = curRoles.UserName
  2350. data["doctor_name"] = curRoles.UserName
  2351. data["fixmedins_code"] = miConfig.Code
  2352. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2353. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2354. data["secret_key"] = miConfig.SecretKey
  2355. data["url"] = miConfig.Url
  2356. data["ak"] = miConfig.AccessKey
  2357. data["cainfo"] = miConfig.Cainfo
  2358. data["setl_mon"] = setl_mon
  2359. data["solidify_id"] = ids
  2360. month := time.Unix(1557042972, 0).Format("1")
  2361. year := time.Now().Format("2006")
  2362. month = time.Now().Format("01")
  2363. day := time.Now().Format("02")
  2364. hour := time.Now().Format("15")
  2365. min := time.Now().Format("04")
  2366. sec := time.Now().Format("05")
  2367. fix_fill_date := year + month + day + hour + min + sec
  2368. data["fix_fill_dept"] = miConfig.OrgName
  2369. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2370. data["fix_fill_psn"] = curRoles.UserName
  2371. data["fix_fill_date"] = fix_fill_date
  2372. data["stmt_loc"] = "2"
  2373. client := &http.Client{}
  2374. bytesData, _ := json.Marshal(data)
  2375. var req *http.Request
  2376. if miConfig.MdtrtareaAdmvs == "320921" {
  2377. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2378. } else {
  2379. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2380. }
  2381. resp, _ := client.Do(req)
  2382. defer resp.Body.Close()
  2383. body, ioErr := ioutil.ReadAll(resp.Body)
  2384. if ioErr != nil {
  2385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2387. }
  2388. var respJSON map[string]interface{}
  2389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2392. }
  2393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2394. fmt.Println(respJSON)
  2395. result, _ := json.Marshal(respJSON)
  2396. fmt.Println(result)
  2397. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2398. utils.ErrorLog("解析失败:%v", err)
  2399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2400. }
  2401. if result3265.Infcode != "0" {
  2402. c.ServeSuccessJSON(map[string]interface{}{
  2403. "failed_code": -10,
  2404. "msg": result3265.ErrMsg,
  2405. })
  2406. return
  2407. } else {
  2408. c.ServeSuccessJSON(map[string]interface{}{
  2409. "info": result3265.Output.Data,
  2410. })
  2411. return
  2412. }
  2413. }
  2414. func (c *HisApiController) Get3272() {
  2415. admin_user_id, _ := c.GetInt64("admin_user_id")
  2416. startTime := c.GetString("start_time")
  2417. //endTime, _ := c.GetString("end_time")
  2418. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2419. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2420. times := strings.Split(startTime, "-")
  2421. setl_mon := times[0] + times[1]
  2422. var upld_btch string
  2423. //var empty models.JSResultEmpty
  2424. var result3265 models.JSResult3264
  2425. data := make(map[string]interface{})
  2426. data["org_name"] = miConfig.OrgName
  2427. data["doctor"] = curRoles.UserName
  2428. data["doctor_name"] = curRoles.UserName
  2429. data["fixmedins_code"] = miConfig.Code
  2430. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2431. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2432. data["secret_key"] = miConfig.SecretKey
  2433. data["url"] = miConfig.Url
  2434. data["ak"] = miConfig.AccessKey
  2435. data["cainfo"] = miConfig.Cainfo
  2436. data["setl_mon"] = setl_mon
  2437. month := time.Unix(1557042972, 0).Format("1")
  2438. year := time.Now().Format("2006")
  2439. month = time.Now().Format("01")
  2440. day := time.Now().Format("02")
  2441. hour := time.Now().Format("15")
  2442. min := time.Now().Format("04")
  2443. sec := time.Now().Format("05")
  2444. fix_fill_date := year + month + day + hour + min + sec
  2445. data["fix_fill_dept"] = miConfig.OrgName
  2446. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2447. data["fix_fill_psn"] = curRoles.UserName
  2448. data["fix_fill_date"] = fix_fill_date
  2449. data["stmt_loc"] = "2"
  2450. data["upld_btch"] = upld_btch
  2451. client := &http.Client{}
  2452. bytesData, _ := json.Marshal(data)
  2453. var req *http.Request
  2454. if miConfig.MdtrtareaAdmvs == "320921" {
  2455. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2456. } else {
  2457. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2458. }
  2459. resp, _ := client.Do(req)
  2460. defer resp.Body.Close()
  2461. body, ioErr := ioutil.ReadAll(resp.Body)
  2462. if ioErr != nil {
  2463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2465. }
  2466. var respJSON map[string]interface{}
  2467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2470. }
  2471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2472. fmt.Println(respJSON)
  2473. result, _ := json.Marshal(respJSON)
  2474. fmt.Println(result)
  2475. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2476. utils.ErrorLog("解析失败:%v", err)
  2477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. }
  2479. if result3265.Infcode != "0" {
  2480. c.ServeSuccessJSON(map[string]interface{}{
  2481. "failed_code": -10,
  2482. "msg": result3265.ErrMsg,
  2483. })
  2484. return
  2485. } else {
  2486. c.ServeSuccessJSON(map[string]interface{}{
  2487. "info": result3265.Output,
  2488. })
  2489. return
  2490. }
  2491. }
  2492. func (c *HisApiController) Get3273() {
  2493. admin_user_id, _ := c.GetInt64("admin_user_id")
  2494. startTime := c.GetString("start_time")
  2495. //endTime, _ := c.GetString("end_time")
  2496. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2497. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2498. times := strings.Split(startTime, "-")
  2499. setl_mon := times[0] + times[1]
  2500. var result3265 models.JSResult3264
  2501. data := make(map[string]interface{})
  2502. data["org_name"] = miConfig.OrgName
  2503. data["doctor"] = curRoles.UserName
  2504. data["doctor_name"] = curRoles.UserName
  2505. data["fixmedins_code"] = miConfig.Code
  2506. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2507. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2508. data["secret_key"] = miConfig.SecretKey
  2509. data["url"] = miConfig.Url
  2510. data["ak"] = miConfig.AccessKey
  2511. data["cainfo"] = miConfig.Cainfo
  2512. data["setl_mon"] = setl_mon
  2513. data["stmt_loc"] = "2"
  2514. client := &http.Client{}
  2515. bytesData, _ := json.Marshal(data)
  2516. var req *http.Request
  2517. if miConfig.MdtrtareaAdmvs == "320921" {
  2518. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2519. } else {
  2520. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2521. }
  2522. resp, _ := client.Do(req)
  2523. defer resp.Body.Close()
  2524. body, ioErr := ioutil.ReadAll(resp.Body)
  2525. if ioErr != nil {
  2526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2528. }
  2529. var respJSON map[string]interface{}
  2530. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. }
  2534. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2535. fmt.Println(respJSON)
  2536. result, _ := json.Marshal(respJSON)
  2537. fmt.Println(result)
  2538. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2539. utils.ErrorLog("解析失败:%v", err)
  2540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2541. }
  2542. if result3265.Infcode != "0" {
  2543. c.ServeSuccessJSON(map[string]interface{}{
  2544. "failed_code": -10,
  2545. "msg": result3265.ErrMsg,
  2546. })
  2547. return
  2548. } else {
  2549. c.ServeSuccessJSON(map[string]interface{}{
  2550. "info": result3265.Output.Data,
  2551. })
  2552. return
  2553. }
  2554. }
  2555. func (c *HisApiController) Get3274() {
  2556. //if miConfig.MdtrtareaAdmvs == "320921" {
  2557. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2558. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2559. // "&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
  2560. //
  2561. //} else {
  2562. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2563. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2564. // "&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
  2565. //
  2566. //}
  2567. }
  2568. func (c *HisApiController) Get3275() {
  2569. //if miConfig.MdtrtareaAdmvs == "320921" {
  2570. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2571. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2572. // "&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
  2573. //
  2574. //} else {
  2575. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2576. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2577. // "&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
  2578. //
  2579. //}
  2580. }
  2581. func (c *HisApiController) Get3276() {
  2582. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2583. //month := c.GetString("month")
  2584. //
  2585. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2586. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2587. //var api string
  2588. //var res Result5301
  2589. //
  2590. //if miConfig.MdtrtareaAdmvs == "320921" {
  2591. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2592. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2593. //} else {
  2594. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2595. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2596. //}
  2597. //
  2598. //resp, requestErr := http.Get(api)
  2599. //if requestErr != nil {
  2600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2601. // return
  2602. //}
  2603. //
  2604. //body, ioErr := ioutil.ReadAll(resp.Body)
  2605. //if ioErr != nil {
  2606. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2608. // return
  2609. //}
  2610. //var respJSON map[string]interface{}
  2611. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2612. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2614. // return
  2615. //}
  2616. //
  2617. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2618. //result, _ := json.Marshal(respJSON)
  2619. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2620. // utils.ErrorLog("解析失败:%v", err)
  2621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2622. // return
  2623. //}
  2624. }
  2625. func (c *HisApiController) Get3277() {
  2626. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2627. //month := c.GetString("month")
  2628. //
  2629. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2630. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2631. //var api string
  2632. //var res Result5301
  2633. //
  2634. //if miConfig.MdtrtareaAdmvs == "320921" {
  2635. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2636. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2637. //} else {
  2638. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2639. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2640. //}
  2641. //
  2642. //resp, requestErr := http.Get(api)
  2643. //if requestErr != nil {
  2644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2645. // return
  2646. //}
  2647. //
  2648. //body, ioErr := ioutil.ReadAll(resp.Body)
  2649. //if ioErr != nil {
  2650. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2652. // return
  2653. //}
  2654. //var respJSON map[string]interface{}
  2655. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2656. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. // return
  2659. //}
  2660. //
  2661. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2662. //result, _ := json.Marshal(respJSON)
  2663. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2664. // utils.ErrorLog("解析失败:%v", err)
  2665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2666. // return
  2667. //}
  2668. }
  2669. func (c *HisApiController) GetCFYLJG001() {
  2670. admin_user_id, _ := c.GetInt64("admin_user_id")
  2671. patient_id, _ := c.GetInt64("patient_id")
  2672. his_patient_id, _ := c.GetInt64("his_patient_id")
  2673. record_time := c.GetString("record_time")
  2674. admin_user_id = 3626
  2675. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2676. psn, _ := service.GetPsnByPatientId(patient_id)
  2677. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2678. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2679. var cFYLJG001 models.CFYLJG001
  2680. timeLayout := "2006-01-02"
  2681. loc, _ := time.LoadLocation("Local")
  2682. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2683. if err != nil {
  2684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2685. return
  2686. }
  2687. recordDateTime := theTime.Unix()
  2688. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2689. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2690. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2691. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2692. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2693. for _, item := range prescriptions {
  2694. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2695. if his.IdCardType == 1 {
  2696. bas := strings.Split(psn.CardInfo, "|")
  2697. basNumber := bas[1]
  2698. fmt.Println(basNumber)
  2699. card_sn := bas[3]
  2700. card_no := bas[2]
  2701. cFYLJG001.MdtrtCertType = "03"
  2702. cFYLJG001.CardSn = card_sn
  2703. cFYLJG001.MdtrtCertNo = card_no
  2704. cFYLJG001.EcToken = ""
  2705. cFYLJG001.AuthNo = ""
  2706. } else if his.IdCardType == 2 {
  2707. cFYLJG001.MdtrtCertType = "02"
  2708. cFYLJG001.CardSn = ""
  2709. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2710. cFYLJG001.EcToken = ""
  2711. cFYLJG001.AuthNo = ""
  2712. } else if his.IdCardType == 4 {
  2713. cFYLJG001.MdtrtCertType = "01"
  2714. cFYLJG001.CardSn = ""
  2715. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2716. cFYLJG001.EcToken = psn.VerifyNumber
  2717. cFYLJG001.AuthNo = ""
  2718. }
  2719. cFYLJG001.BizTypeCode = "01"
  2720. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2721. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2722. cFYLJG001.RxTypeCode = "1"
  2723. tempTime := time.Unix(item.PreTime, 0)
  2724. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2725. cFYLJG001.PrscTime = timeFormatOne
  2726. var count float64
  2727. if item.Type == 1 {
  2728. for _, sumItem := range item.HisDoctorAdviceInfo {
  2729. count = count + sumItem.PrescribingNumber
  2730. }
  2731. }
  2732. cFYLJG001.RxDrugCnt = count
  2733. cFYLJG001.ValiDays = "5"
  2734. ts := time.Unix(item.PreTime, 0)
  2735. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2736. tempTime3 := time.Unix(record_time2, 0)
  2737. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2738. cFYLJG001.ValiEndTime = timeFormat3
  2739. cFYLJG001.RxCotnFlag = "0"
  2740. for _, subItem := range item.HisDoctorAdviceInfo {
  2741. var drug models.RxDrug
  2742. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2743. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2744. drug.RxItemTypeCode = "11"
  2745. drug.DrugDosform = "乳膏剂" //TODO
  2746. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2747. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2748. }
  2749. drug.MedcWayDscr = subItem.DeliveryWay
  2750. tempTime2 := time.Unix(subItem.StartTime, 0)
  2751. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2752. drug.MedcBegntime = timeFormatTwo
  2753. if subItem.Day > 0 {
  2754. ts := time.Unix(subItem.StartTime, 0)
  2755. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2756. tempTime4 := time.Unix(record_time, 0)
  2757. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2758. drug.MedcEndtime = timeFormat5
  2759. } else {
  2760. tempTime2 := time.Unix(subItem.StartTime, 0)
  2761. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2762. drug.MedcEndtime = timeFormatTwo
  2763. }
  2764. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2765. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2766. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2767. drug.DrugCnt = subItem.PrescribingNumber
  2768. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2769. drug.DrugGenname = subItem.AdviceName
  2770. drug.MedcWayCodg = subItem.DeliveryWay
  2771. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2772. drug.SinDoscnt = subItem.SingleDose
  2773. drug.SinDosunt = subItem.SingleDoseUnit
  2774. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2775. drug.UsedFrquName = subItem.ExecutionFrequency
  2776. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2777. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2778. drug.HospApprFlag = "1"
  2779. cFYLJG001.List = append(cFYLJG001.List, drug)
  2780. }
  2781. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2782. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2783. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2784. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2785. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2786. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2787. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2788. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2789. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2790. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2791. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2792. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2793. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2794. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2795. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2796. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2797. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2798. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2799. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2800. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2801. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2802. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2803. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2804. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2805. tempTime2 := time.Now().Unix()
  2806. tempTime6 := time.Unix(tempTime2, 0)
  2807. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2808. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2809. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2810. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2811. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2812. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2813. //memo := make(map[string]interface{})
  2814. //inputData := make(map[string]interface{}, 0)
  2815. //type MyData struct {
  2816. // Insutype string `json:"insutype"`
  2817. //}
  2818. //
  2819. // data := MyData{
  2820. // Insutype: his.Insutype,
  2821. //}
  2822. //
  2823. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2824. var config []*models.HisXtDiagnoseConfig
  2825. for _, item := range diagnosis_ids {
  2826. id, _ := strconv.ParseInt(item, 10, 64)
  2827. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2828. config = append(config, &diagnosisConfig)
  2829. }
  2830. for index, subitem := range config {
  2831. if index == 0 {
  2832. var dia models.DiseInfo
  2833. dia.DiagType = "1"
  2834. dia.MaindiagFlag = "1"
  2835. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2836. dia.DiagCode = subitem.CountryCode
  2837. dia.DiagName = subitem.ClassName
  2838. dia.DiagDept = "肾内科"
  2839. dia.DiagDrNo = doctor.DoctorNumber
  2840. dia.DiagDrName = doctor.UserName
  2841. tempTime3 := time.Unix(item.PreTime, 0)
  2842. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2843. dia.DiagTime = timeFormatTwo
  2844. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2845. } else {
  2846. var dia models.DiseInfo
  2847. dia.DiagType = "1"
  2848. dia.MaindiagFlag = "0"
  2849. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2850. dia.DiagCode = subitem.CountryCode
  2851. dia.DiagName = subitem.ClassName
  2852. dia.DiagDept = "肾内科"
  2853. dia.DiagDrNo = doctor.DoctorNumber
  2854. dia.DiagDrName = doctor.UserName
  2855. tempTime3 := time.Unix(item.PreTime, 0)
  2856. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2857. dia.DiagTime = timeFormatTwo
  2858. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2859. }
  2860. }
  2861. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2862. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2863. var res ResultCFYLJG001
  2864. var respJSON2 map[string]interface{}
  2865. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. userJSONBytes2, _ := json.Marshal(respJSON2)
  2871. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2872. utils.ErrorLog("解析失败:%v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. if res.Infcode == -1 {
  2877. c.ServeSuccessJSON(map[string]interface{}{
  2878. "failed_code": -10,
  2879. "msg": res.ErrMsg,
  2880. })
  2881. return
  2882. } else {
  2883. var flow models.HisPrescriptionFlow
  2884. flow.Ctime = time.Now().Unix()
  2885. flow.SignDigest = ""
  2886. flow.RxTraceCode = res.Output.RxTraceCode
  2887. flow.HiRxno = res.Output.HiRxno
  2888. flow.MID = his.Number
  2889. flow.Status = 1
  2890. flow.DCode = doctor_info.DoctorNumber
  2891. flow.OriginalRxFile = ""
  2892. flow.OriginalValue = ""
  2893. flow.SignCertDn = ""
  2894. flow.UserOrgId = 10454
  2895. flow.SignCertSn = ""
  2896. flow.Mtime = time.Now().Unix()
  2897. service.Createflow(&flow)
  2898. c.ServeSuccessJSON(map[string]interface{}{
  2899. "msg": "上传成功",
  2900. })
  2901. }
  2902. }
  2903. }
  2904. func (c *HisApiController) GetCFYLJG002() {
  2905. admin_user_id, _ := c.GetInt64("admin_user_id")
  2906. his_patient_id, _ := c.GetInt64("his_patient_id")
  2907. record_time := c.GetString("record_time")
  2908. admin_user_id = 3626
  2909. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2910. //id, _ := c.GetInt64("id")
  2911. admin_user_id = 3626
  2912. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2913. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2914. flow, _ := service.Getflowtwo(his.Number)
  2915. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2916. //record_time := c.GetString("record_time")
  2917. patient_id, _ := c.GetInt64("patient_id")
  2918. //patient_id = 23834
  2919. //record_time = "2023-09-18"
  2920. timeLayout := "2006-01-02"
  2921. loc, _ := time.LoadLocation("Local")
  2922. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2923. if err != nil {
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2925. return
  2926. }
  2927. recordDateTime := theTime.Unix()
  2928. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2929. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2930. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2931. dept, _ := service.GetDepartMentDetail(info.Departments)
  2932. inputData := make(map[string]interface{})
  2933. inputData["rxTraceCode"] = flow.RxTraceCode
  2934. inputData["hiRxno"] = flow.HiRxno
  2935. inputData["mdtrtId"] = flow.MID
  2936. inputData["patnName"] = his.PsnName
  2937. inputData["psnCertType"] = his.PsnCertType
  2938. inputData["certno"] = his.Certno
  2939. inputData["fixmedinsName"] = miConfig.OrgName
  2940. inputData["fixmedinsCode"] = miConfig.Code
  2941. inputData["drCode"] = doctor_info.DoctorNumber
  2942. inputData["prscDrName"] = doctor_info.UserName
  2943. inputData["pharDeptName"] = dept.Name
  2944. inputData["pharDeptCode"] = dept.Number
  2945. inputData["pharProfttlCodg"] = dept.Name
  2946. inputData["pharProfttlName"] = ""
  2947. inputData["pharCode"] = "HY440309002107"
  2948. inputData["pharCertType"] = "01"
  2949. inputData["pharCertno"] = "430482199408260023"
  2950. inputData["pharName"] = "彭斯遥"
  2951. inputData["pharPracCertNo"] = ""
  2952. tempTime2 := time.Unix(info.Ctime, 0)
  2953. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2954. inputData["pharChkTime"] = timeFormatTwo
  2955. bytesData, _ := json.Marshal(inputData)
  2956. fmt.Println(string(bytesData))
  2957. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2958. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2959. if err != nil {
  2960. fmt.Println("Error reading PDF file:", err)
  2961. return
  2962. }
  2963. // 将 PDF 文件内容进行 Base64 编码
  2964. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2965. fmt.Println(err)
  2966. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2967. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2968. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2969. var res2 Result002
  2970. var respJSON2 map[string]interface{}
  2971. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2974. return
  2975. }
  2976. userJSONBytes2, _ := json.Marshal(respJSON2)
  2977. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2978. utils.ErrorLog("解析失败:%v", err)
  2979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2980. return
  2981. }
  2982. if res2.Infcode == 0 {
  2983. flow.Ctime = time.Now().Unix()
  2984. flow.SignDigest = res2.Output.SignDigest
  2985. flow.RxFile = res2.Output.RxFile
  2986. flow.MID = his.Number
  2987. flow.Status = 1
  2988. flow.DCode = doctor_info.DoctorNumber
  2989. flow.OriginalRxFile = rx_encoded
  2990. flow.OriginalValue = encoded
  2991. flow.SignCertDn = res2.Output.SignCertDn
  2992. flow.SignCertSn = res2.Output.SignCertSn
  2993. flow.Mtime = time.Now().Unix()
  2994. service.Saveflow(flow)
  2995. c.ServeSuccessJSON(map[string]interface{}{
  2996. "msg": "预签名成功",
  2997. })
  2998. } else {
  2999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3000. return
  3001. }
  3002. }
  3003. func (c *HisApiController) GetCFYLJG003() {
  3004. admin_user_id, _ := c.GetInt64("admin_user_id")
  3005. his_patient_id, _ := c.GetInt64("his_patient_id")
  3006. record_time := c.GetString("record_time")
  3007. admin_user_id = 3626
  3008. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3009. //id, _ := c.GetInt64("id")
  3010. admin_user_id = 3626
  3011. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3013. flow, _ := service.Getflowtwo(his.Number)
  3014. //id = 3
  3015. patient_id, _ := c.GetInt64("patient_id")
  3016. //patient_id = 23834
  3017. //record_time = "2023-09-18"
  3018. timeLayout := "2006-01-02"
  3019. loc, _ := time.LoadLocation("Local")
  3020. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3021. if err != nil {
  3022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3023. return
  3024. }
  3025. recordDateTime := theTime.Unix()
  3026. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3027. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3028. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3029. dept, _ := service.GetDepartMentDetail(info.Departments)
  3030. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  3031. var cFYLJG003 models.CFYLJG003
  3032. cFYLJG003.RxTraceCode = flow.RxTraceCode
  3033. cFYLJG003.HiRxno = flow.HiRxno
  3034. cFYLJG003.MdtrtID = flow.MID
  3035. cFYLJG003.PatnName = his.Name
  3036. cFYLJG003.Certno = his.Certno
  3037. cFYLJG003.FixmedinsName = miConfig.OrgName
  3038. cFYLJG003.FixmedinsCode = miConfig.Code
  3039. cFYLJG003.DrCode = doctor_info.DoctorNumber
  3040. cFYLJG003.PrscDrName = doctor_info.UserName
  3041. cFYLJG003.PharDeptName = dept.Name
  3042. cFYLJG003.PharDeptCode = dept.Number
  3043. cFYLJG003.PharCode = "HY440309002107"
  3044. cFYLJG003.PharCertType = "01"
  3045. cFYLJG003.PharCertno = "430482199408260023"
  3046. cFYLJG003.PharName = "彭斯遥"
  3047. cFYLJG003.PsnCertType = "01"
  3048. cFYLJG003.RxFile = flow.RxFile
  3049. cFYLJG003.SignDigest = flow.SignDigest
  3050. cFYLJG003.FixmedinsCode = miConfig.Code
  3051. cFYLJG003.PsnCertType = "01"
  3052. cFYLJG003.PharProfttlCodg = dept.Name
  3053. //inputData["pharProfttlCodg"] =dept.Name
  3054. tempTime2 := time.Unix(info.Ctime, 0)
  3055. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3056. cFYLJG003.PharChkTime = timeFormatTwo
  3057. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  3058. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  3059. var res ResultCFYLJG003
  3060. var respJSON2 map[string]interface{}
  3061. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3064. return
  3065. }
  3066. userJSONBytes2, _ := json.Marshal(respJSON2)
  3067. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3068. utils.ErrorLog("解析失败:%v", err)
  3069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3070. return
  3071. }
  3072. if res.Infcode == -1 {
  3073. c.ServeSuccessJSON(map[string]interface{}{
  3074. "failed_code": -10,
  3075. "msg": res.ErrMsg,
  3076. })
  3077. return
  3078. } else {
  3079. c.ServeSuccessJSON(map[string]interface{}{
  3080. "info": res.Output,
  3081. })
  3082. }
  3083. }
  3084. func (c *HisApiController) GetCFYLJG004() {
  3085. admin_user_id, _ := c.GetInt64("admin_user_id")
  3086. his_patient_id, _ := c.GetInt64("his_patient_id")
  3087. record_time := c.GetString("record_time")
  3088. admin_user_id = 3626
  3089. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3090. //id, _ := c.GetInt64("id")
  3091. admin_user_id = 3626
  3092. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3094. flow, _ := service.Getflowtwo(his.Number)
  3095. //id = 3
  3096. patient_id, _ := c.GetInt64("patient_id")
  3097. //patient_id = 23834
  3098. //record_time = "2023-09-18"
  3099. timeLayout := "2006-01-02"
  3100. loc, _ := time.LoadLocation("Local")
  3101. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3102. if err != nil {
  3103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3104. return
  3105. }
  3106. recordDateTime := theTime.Unix()
  3107. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3108. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3109. var cFYLJG004 models.CFYLJG004
  3110. cFYLJG004.HiRxno = flow.HiRxno
  3111. cFYLJG004.FixmedinsCode = miConfig.Code
  3112. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  3113. cFYLJG004.UndoDrCertType = "01"
  3114. cFYLJG004.UndoRea = "撤销处方"
  3115. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  3116. cFYLJG004.UndoDrName = doctor_info.UserName
  3117. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  3118. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  3119. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  3120. var res ResultCFYLJG004
  3121. var respJSON2 map[string]interface{}
  3122. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3125. return
  3126. }
  3127. userJSONBytes2, _ := json.Marshal(respJSON2)
  3128. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3129. utils.ErrorLog("解析失败:%v", err)
  3130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3131. return
  3132. }
  3133. if res.Infcode == -1 {
  3134. c.ServeSuccessJSON(map[string]interface{}{
  3135. "failed_code": -10,
  3136. "msg": res.ErrMsg,
  3137. })
  3138. return
  3139. } else {
  3140. flow.Status = 0
  3141. service.Saveflow(flow)
  3142. c.ServeSuccessJSON(map[string]interface{}{
  3143. "msg": "撤销成功",
  3144. })
  3145. return
  3146. }
  3147. }
  3148. func (c *HisApiController) GetCFYLJG005() {
  3149. admin_user_id, _ := c.GetInt64("admin_user_id")
  3150. his_patient_id, _ := c.GetInt64("his_patient_id")
  3151. //record_time := c.GetString("record_time")
  3152. admin_user_id = 3626
  3153. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3154. //id, _ := c.GetInt64("id")
  3155. admin_user_id = 3626
  3156. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3157. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3158. flow, _ := service.Getflowtwo(his.Number)
  3159. //id = 3
  3160. var cFYLJG005 models.CFYLJG005
  3161. //patient_id, _ := c.GetInt64("patient_id")
  3162. cFYLJG005.HiRxno = flow.HiRxno
  3163. cFYLJG005.MdtrtID = flow.MID
  3164. cFYLJG005.EcToken = ""
  3165. cFYLJG005.PsnName = his.Name
  3166. cFYLJG005.PsnCertType = "01"
  3167. cFYLJG005.Certno = his.IdCardNo
  3168. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3169. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3170. var res ResultCFYLJG005
  3171. var respJSON2 map[string]interface{}
  3172. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3175. return
  3176. }
  3177. userJSONBytes2, _ := json.Marshal(respJSON2)
  3178. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3179. utils.ErrorLog("解析失败:%v", err)
  3180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. return
  3182. }
  3183. if res.Infcode == -1 {
  3184. c.ServeSuccessJSON(map[string]interface{}{
  3185. "failed_code": -10,
  3186. "msg": res.ErrMsg,
  3187. })
  3188. return
  3189. } else {
  3190. c.ServeSuccessJSON(map[string]interface{}{
  3191. "info": res.Output,
  3192. })
  3193. return
  3194. }
  3195. }
  3196. func (c *HisApiController) GetCFYLJG006() {
  3197. admin_user_id, _ := c.GetInt64("admin_user_id")
  3198. his_patient_id, _ := c.GetInt64("his_patient_id")
  3199. admin_user_id = 3626
  3200. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3201. //id, _ := c.GetInt64("id")
  3202. admin_user_id = 3626
  3203. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3204. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3205. flow, _ := service.Getflowtwo(his.Number)
  3206. //id = 3
  3207. patient_id, _ := c.GetInt64("patient_id")
  3208. var cFYLJG006 models.CFYLJG006
  3209. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3210. cFYLJG006.HiRxno = flow.HiRxno
  3211. cFYLJG006.MdtrtID = flow.MID
  3212. cFYLJG006.PsnName = patient.Name
  3213. cFYLJG006.PsnCertType = "01"
  3214. cFYLJG006.Certno = patient.IdCardNo
  3215. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3216. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3217. var res ResultCFYLJG006
  3218. var respJSON2 map[string]interface{}
  3219. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3222. return
  3223. }
  3224. userJSONBytes2, _ := json.Marshal(respJSON2)
  3225. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3226. utils.ErrorLog("解析失败:%v", err)
  3227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3228. return
  3229. }
  3230. if res.Infcode == -1 {
  3231. c.ServeSuccessJSON(map[string]interface{}{
  3232. "failed_code": -10,
  3233. "msg": res.ErrMsg,
  3234. })
  3235. return
  3236. } else {
  3237. c.ServeSuccessJSON(map[string]interface{}{
  3238. "info": res.Output,
  3239. })
  3240. return
  3241. }
  3242. }
  3243. func (c *HisApiController) GetCFYLJG007() {
  3244. admin_user_id, _ := c.GetInt64("admin_user_id")
  3245. his_patient_id, _ := c.GetInt64("his_patient_id")
  3246. admin_user_id = 3626
  3247. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3248. //id, _ := c.GetInt64("id")
  3249. admin_user_id = 3626
  3250. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3251. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3252. flow, _ := service.Getflowtwo(his.Number)
  3253. //id = 3
  3254. patient_id, _ := c.GetInt64("patient_id")
  3255. var cFYLJG007 models.CFYLJG007
  3256. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3257. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3258. cFYLJG007.HiRxno = flow.HiRxno
  3259. cFYLJG007.MdtrtID = flow.MID
  3260. cFYLJG007.PsnNo = his.PsnNo
  3261. cFYLJG007.PsnCertType = "01"
  3262. cFYLJG007.Certno = patient.IdCardNo
  3263. cFYLJG007.PsnName = patient.Name
  3264. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3265. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3266. var res ResultCFYLJG007
  3267. var respJSON2 map[string]interface{}
  3268. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3271. return
  3272. }
  3273. userJSONBytes2, _ := json.Marshal(respJSON2)
  3274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3275. utils.ErrorLog("解析失败:%v", err)
  3276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3277. return
  3278. }
  3279. if res.Infcode == -1 {
  3280. c.ServeSuccessJSON(map[string]interface{}{
  3281. "failed_code": -10,
  3282. "msg": res.ErrMsg,
  3283. })
  3284. return
  3285. } else {
  3286. c.ServeSuccessJSON(map[string]interface{}{
  3287. "info": res,
  3288. })
  3289. return
  3290. }
  3291. }
  3292. func (c *HisApiController) GetCFYLJG008() {
  3293. admin_user_id, _ := c.GetInt64("admin_user_id")
  3294. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3295. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3296. var cFYLJG008 models.CFYLJG008
  3297. //id, _ := c.GetInt64("id")
  3298. patient_id, _ := c.GetInt64("patient_id")
  3299. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3300. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3301. //id = 3
  3302. //flow, _ := service.Getflow(id)
  3303. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3304. //
  3305. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3306. //patient_id, _ := c.GetInt64("patient_id")
  3307. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3308. record_time := c.GetString("record_time")
  3309. admin_user_id = 3626
  3310. patient_id = 19424
  3311. //his_patient_id = 263947
  3312. record_time = "2023-08-29"
  3313. timeLayout := "2006-01-02"
  3314. loc, _ := time.LoadLocation("Local")
  3315. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3316. if err != nil {
  3317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3318. return
  3319. }
  3320. recordDateTime := theTime.Unix()
  3321. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3322. cFYLJG008.FixmedinsName = ""
  3323. cFYLJG008.Lat = ""
  3324. cFYLJG008.Lng = ""
  3325. cFYLJG008.OrderType = "1"
  3326. cFYLJG008.PoolareaNo = ""
  3327. cFYLJG008.Lng = ""
  3328. cFYLJG008.PageNum = 1
  3329. cFYLJG008.PageSize = 10
  3330. var MPI models.MedinsProdInvChgDDTO
  3331. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3332. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3333. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3334. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3335. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3336. var res ResultCFYLJG008
  3337. var respJSON2 map[string]interface{}
  3338. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3341. return
  3342. }
  3343. userJSONBytes2, _ := json.Marshal(respJSON2)
  3344. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3345. utils.ErrorLog("解析失败:%v", err)
  3346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3347. return
  3348. }
  3349. if res.Infcode == -1 {
  3350. c.ServeSuccessJSON(map[string]interface{}{
  3351. "failed_code": -10,
  3352. "msg": res.ErrMsg,
  3353. })
  3354. return
  3355. } else {
  3356. c.ServeSuccessJSON(map[string]interface{}{
  3357. "info": res.Output,
  3358. })
  3359. return
  3360. }
  3361. }
  3362. func (c *HisApiController) GetBL4201A() {
  3363. order_id, _ := c.GetInt64("order_id")
  3364. admin_user_id, _ := c.GetInt64("admin_user_id")
  3365. order, _ := service.GetHisOrderByIDTwo(order_id)
  3366. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3367. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3368. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3369. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3371. department, _ := service.GetDepartMentDetail(his.Departments)
  3372. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3373. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3374. if order.ID == 0 {
  3375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3376. return
  3377. }
  3378. var struct4201A models.Struct4201A
  3379. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3380. for _, items := range order_info {
  3381. memo := make(map[string]interface{})
  3382. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3383. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3384. fsiOPFLD.MedType = "14"
  3385. fsiOPFLD.BkkpSn = items.FeedetlSn
  3386. fsiOPFLD.FixmedinsCode = miConfig.Code
  3387. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3388. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3389. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3390. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3391. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3392. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3393. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3394. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3395. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3396. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3397. fsiOPFLD.BilgDeptName = department.Name
  3398. fsiOPFLD.BilgDeptCodg = department.Number
  3399. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3400. fsiOPFLD.BilgDrName = doctor.UserName
  3401. fsiOPFLD.MedChrgitmType = "09"
  3402. memo["hosp_appr_flag"] = "1"
  3403. memo["invoice_no"] = order.MdtrtId
  3404. memo["memo"] = "自费"
  3405. bytesData, _ := json.Marshal(memo)
  3406. fsiOPFLD.Memo = string(bytesData)
  3407. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3408. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3409. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3410. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3411. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3412. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3413. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3414. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3415. fsiOPFLD.BilgDeptName = department.Name
  3416. fsiOPFLD.BilgDeptCodg = department.Number
  3417. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3418. fsiOPFLD.BilgDrName = doctor.UserName
  3419. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3420. case 0:
  3421. break
  3422. case 1:
  3423. fsiOPFLD.MedChrgitmType = "14"
  3424. break
  3425. case 2:
  3426. fsiOPFLD.MedChrgitmType = "05"
  3427. break
  3428. case 3:
  3429. fsiOPFLD.MedChrgitmType = "03"
  3430. break
  3431. case 4:
  3432. fsiOPFLD.MedChrgitmType = "03"
  3433. break
  3434. case 5:
  3435. fsiOPFLD.MedChrgitmType = "08"
  3436. break
  3437. case 6:
  3438. fsiOPFLD.MedChrgitmType = "14"
  3439. break
  3440. case 7:
  3441. fsiOPFLD.MedChrgitmType = "14"
  3442. break
  3443. case 8:
  3444. fsiOPFLD.MedChrgitmType = "03"
  3445. break
  3446. case 9:
  3447. fsiOPFLD.MedChrgitmType = "14"
  3448. break
  3449. case 10:
  3450. fsiOPFLD.MedChrgitmType = "14"
  3451. break
  3452. case 11:
  3453. fsiOPFLD.MedChrgitmType = "06"
  3454. break
  3455. case 12:
  3456. fsiOPFLD.MedChrgitmType = "12"
  3457. break
  3458. case 13:
  3459. fsiOPFLD.MedChrgitmType = "01"
  3460. break
  3461. case 14:
  3462. fsiOPFLD.MedChrgitmType = "04"
  3463. break
  3464. case 15:
  3465. fsiOPFLD.MedChrgitmType = "14"
  3466. break
  3467. }
  3468. memo["hosp_appr_flag"] = "1"
  3469. memo["invoice_no"] = order.MdtrtId
  3470. memo["memo"] = "自费"
  3471. bytesData, _ := json.Marshal(memo)
  3472. fsiOPFLD.Memo = string(bytesData)
  3473. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3474. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3475. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3476. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3477. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3478. fsiOPFLD.BilgDeptName = department.Name
  3479. fsiOPFLD.BilgDeptCodg = department.Number
  3480. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3481. fsiOPFLD.BilgDrName = doctor.UserName
  3482. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3483. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3484. fsiOPFLD.MedChrgitmType = "08"
  3485. memo["hosp_appr_flag"] = "1"
  3486. memo["invoice_no"] = order.MdtrtId
  3487. memo["memo"] = "自费"
  3488. bytesData, _ := json.Marshal(memo)
  3489. fsiOPFLD.Memo = string(bytesData)
  3490. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3491. }
  3492. }
  3493. }
  3494. for _, items := range order_info_two {
  3495. memo := make(map[string]interface{})
  3496. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3497. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3498. fsiOPFLD.MedType = "14"
  3499. fsiOPFLD.BkkpSn = items.FeedetlSn
  3500. fsiOPFLD.FixmedinsCode = miConfig.Code
  3501. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3502. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3503. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3504. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3505. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3506. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3507. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3508. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3509. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3510. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3511. fsiOPFLD.BilgDeptName = department.Name
  3512. fsiOPFLD.BilgDeptCodg = department.Number
  3513. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3514. fsiOPFLD.BilgDrName = doctor.UserName
  3515. fsiOPFLD.MedChrgitmType = "09"
  3516. memo["hosp_appr_flag"] = "1"
  3517. memo["invoice_no"] = order.MdtrtId
  3518. memo["memo"] = "自费"
  3519. bytesData, _ := json.Marshal(memo)
  3520. fsiOPFLD.Memo = string(bytesData)
  3521. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3522. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3523. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3524. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3525. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3526. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3527. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3528. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3529. fsiOPFLD.BilgDeptName = department.Name
  3530. fsiOPFLD.BilgDeptCodg = department.Number
  3531. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3532. fsiOPFLD.BilgDrName = doctor.UserName
  3533. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3534. case 0:
  3535. break
  3536. case 1:
  3537. fsiOPFLD.MedChrgitmType = "14"
  3538. break
  3539. case 2:
  3540. fsiOPFLD.MedChrgitmType = "05"
  3541. break
  3542. case 3:
  3543. fsiOPFLD.MedChrgitmType = "03"
  3544. break
  3545. case 4:
  3546. fsiOPFLD.MedChrgitmType = "03"
  3547. break
  3548. case 5:
  3549. fsiOPFLD.MedChrgitmType = "08"
  3550. break
  3551. case 6:
  3552. fsiOPFLD.MedChrgitmType = "14"
  3553. break
  3554. case 7:
  3555. fsiOPFLD.MedChrgitmType = "14"
  3556. break
  3557. case 8:
  3558. fsiOPFLD.MedChrgitmType = "03"
  3559. break
  3560. case 9:
  3561. fsiOPFLD.MedChrgitmType = "14"
  3562. break
  3563. case 10:
  3564. fsiOPFLD.MedChrgitmType = "14"
  3565. break
  3566. case 11:
  3567. fsiOPFLD.MedChrgitmType = "06"
  3568. break
  3569. case 12:
  3570. fsiOPFLD.MedChrgitmType = "12"
  3571. break
  3572. case 13:
  3573. fsiOPFLD.MedChrgitmType = "01"
  3574. break
  3575. case 14:
  3576. fsiOPFLD.MedChrgitmType = "04"
  3577. break
  3578. case 15:
  3579. fsiOPFLD.MedChrgitmType = "14"
  3580. break
  3581. }
  3582. memo["hosp_appr_flag"] = "1"
  3583. memo["invoice_no"] = order.MdtrtId
  3584. memo["memo"] = "自费"
  3585. bytesData, _ := json.Marshal(memo)
  3586. fsiOPFLD.Memo = string(bytesData)
  3587. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3588. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3589. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3590. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3591. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3592. fsiOPFLD.BilgDeptName = department.Name
  3593. fsiOPFLD.BilgDeptCodg = department.Number
  3594. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3595. fsiOPFLD.BilgDrName = doctor.UserName
  3596. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3597. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3598. fsiOPFLD.MedChrgitmType = "08"
  3599. memo["hosp_appr_flag"] = "1"
  3600. memo["invoice_no"] = order.MdtrtId
  3601. memo["memo"] = "自费"
  3602. bytesData, _ := json.Marshal(memo)
  3603. fsiOPFLD.Memo = string(bytesData)
  3604. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3605. }
  3606. }
  3607. }
  3608. fmt.Println(fsiOPFLDs)
  3609. struct4201A.Fopfd = fsiOPFLDs
  3610. fmt.Println(struct4201A.Fopfd)
  3611. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3612. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3613. var res2 ResultSix
  3614. var respJSON2 map[string]interface{}
  3615. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3618. return
  3619. }
  3620. userJSONBytes2, _ := json.Marshal(respJSON2)
  3621. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3622. utils.ErrorLog("解析失败:%v", err)
  3623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3624. return
  3625. }
  3626. if res2.Infcode != 0 {
  3627. c.ServeSuccessJSON(map[string]interface{}{
  3628. "failed_code": -10,
  3629. "msg": res2.ErrMsg,
  3630. })
  3631. return
  3632. } else {
  3633. order.IsUploadOrderInfo = 1
  3634. service.UpdateOrder(order)
  3635. c.ServeSuccessJSON(map[string]interface{}{
  3636. "msg": "上传成功",
  3637. })
  3638. }
  3639. }
  3640. func (c *HisApiController) Get2505() {
  3641. admin_user_id, _ := c.GetInt64("admin_user_id")
  3642. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3643. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3644. 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)
  3645. }
  3646. func (c *HisApiController) Get4201A() {
  3647. order_id, _ := c.GetInt64("order_id")
  3648. admin_user_id, _ := c.GetInt64("admin_user_id")
  3649. order, _ := service.GetHisOrderByIDTwo(order_id)
  3650. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3651. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3652. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3653. //order_info = append(order_info, order_info_two...)
  3654. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3655. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3656. department, _ := service.GetDepartMentDetail(his.Departments)
  3657. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3658. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3659. if order.ID == 0 {
  3660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3661. return
  3662. }
  3663. var struct4201A models.Struct4201A
  3664. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3665. for _, items := range order_info {
  3666. memo := make(map[string]interface{})
  3667. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3668. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3669. fsiOPFLD.MedType = "14"
  3670. fsiOPFLD.BkkpSn = items.FeedetlSn
  3671. fsiOPFLD.FixmedinsCode = miConfig.Code
  3672. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3673. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3674. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3675. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3676. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3677. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3678. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3679. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3680. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3681. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3682. fsiOPFLD.BilgDeptName = department.Name
  3683. fsiOPFLD.BilgDeptCodg = department.Number
  3684. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3685. fsiOPFLD.BilgDrName = doctor.UserName
  3686. fsiOPFLD.MedChrgitmType = "09"
  3687. memo["hosp_appr_flag"] = "1"
  3688. memo["invoice_no"] = order.MdtrtId
  3689. memo["memo"] = "自费"
  3690. bytesData, _ := json.Marshal(memo)
  3691. fsiOPFLD.Memo = string(bytesData)
  3692. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3693. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3694. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3695. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3696. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3697. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3698. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3699. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3700. fsiOPFLD.BilgDeptName = department.Name
  3701. fsiOPFLD.BilgDeptCodg = department.Number
  3702. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3703. fsiOPFLD.BilgDrName = doctor.UserName
  3704. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3705. case 0:
  3706. break
  3707. case 1:
  3708. fsiOPFLD.MedChrgitmType = "14"
  3709. break
  3710. case 2:
  3711. fsiOPFLD.MedChrgitmType = "05"
  3712. break
  3713. case 3:
  3714. fsiOPFLD.MedChrgitmType = "03"
  3715. break
  3716. case 4:
  3717. fsiOPFLD.MedChrgitmType = "03"
  3718. break
  3719. case 5:
  3720. fsiOPFLD.MedChrgitmType = "08"
  3721. break
  3722. case 6:
  3723. fsiOPFLD.MedChrgitmType = "14"
  3724. break
  3725. case 7:
  3726. fsiOPFLD.MedChrgitmType = "14"
  3727. break
  3728. case 8:
  3729. fsiOPFLD.MedChrgitmType = "03"
  3730. break
  3731. case 9:
  3732. fsiOPFLD.MedChrgitmType = "14"
  3733. break
  3734. case 10:
  3735. fsiOPFLD.MedChrgitmType = "14"
  3736. break
  3737. case 11:
  3738. fsiOPFLD.MedChrgitmType = "06"
  3739. break
  3740. case 12:
  3741. fsiOPFLD.MedChrgitmType = "12"
  3742. break
  3743. case 13:
  3744. fsiOPFLD.MedChrgitmType = "01"
  3745. break
  3746. case 14:
  3747. fsiOPFLD.MedChrgitmType = "04"
  3748. break
  3749. case 15:
  3750. fsiOPFLD.MedChrgitmType = "14"
  3751. break
  3752. }
  3753. memo["hosp_appr_flag"] = "1"
  3754. memo["invoice_no"] = order.MdtrtId
  3755. memo["memo"] = "自费"
  3756. bytesData, _ := json.Marshal(memo)
  3757. fsiOPFLD.Memo = string(bytesData)
  3758. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3759. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3760. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3761. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3762. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3763. fsiOPFLD.BilgDeptName = department.Name
  3764. fsiOPFLD.BilgDeptCodg = department.Number
  3765. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3766. fsiOPFLD.BilgDrName = doctor.UserName
  3767. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3768. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3769. fsiOPFLD.MedChrgitmType = "08"
  3770. memo["hosp_appr_flag"] = "1"
  3771. memo["invoice_no"] = order.MdtrtId
  3772. memo["memo"] = "自费"
  3773. bytesData, _ := json.Marshal(memo)
  3774. fsiOPFLD.Memo = string(bytesData)
  3775. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3776. }
  3777. }
  3778. }
  3779. for _, items := range order_info_two {
  3780. memo := make(map[string]interface{})
  3781. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3782. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3783. fsiOPFLD.MedType = "14"
  3784. fsiOPFLD.BkkpSn = items.FeedetlSn
  3785. fsiOPFLD.FixmedinsCode = miConfig.Code
  3786. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3787. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3788. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3789. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3790. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3791. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3792. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3793. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3794. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3795. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3796. fsiOPFLD.BilgDeptName = department.Name
  3797. fsiOPFLD.BilgDeptCodg = department.Number
  3798. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3799. fsiOPFLD.BilgDrName = doctor.UserName
  3800. fsiOPFLD.MedChrgitmType = "09"
  3801. memo["hosp_appr_flag"] = "1"
  3802. memo["invoice_no"] = order.MdtrtId
  3803. memo["memo"] = "自费"
  3804. bytesData, _ := json.Marshal(memo)
  3805. fsiOPFLD.Memo = string(bytesData)
  3806. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3807. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3808. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3809. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3810. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3811. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3812. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3813. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3814. fsiOPFLD.BilgDeptName = department.Name
  3815. fsiOPFLD.BilgDeptCodg = department.Number
  3816. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3817. fsiOPFLD.BilgDrName = doctor.UserName
  3818. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3819. case 0:
  3820. break
  3821. case 1:
  3822. fsiOPFLD.MedChrgitmType = "14"
  3823. break
  3824. case 2:
  3825. fsiOPFLD.MedChrgitmType = "05"
  3826. break
  3827. case 3:
  3828. fsiOPFLD.MedChrgitmType = "03"
  3829. break
  3830. case 4:
  3831. fsiOPFLD.MedChrgitmType = "03"
  3832. break
  3833. case 5:
  3834. fsiOPFLD.MedChrgitmType = "08"
  3835. break
  3836. case 6:
  3837. fsiOPFLD.MedChrgitmType = "14"
  3838. break
  3839. case 7:
  3840. fsiOPFLD.MedChrgitmType = "14"
  3841. break
  3842. case 8:
  3843. fsiOPFLD.MedChrgitmType = "03"
  3844. break
  3845. case 9:
  3846. fsiOPFLD.MedChrgitmType = "14"
  3847. break
  3848. case 10:
  3849. fsiOPFLD.MedChrgitmType = "14"
  3850. break
  3851. case 11:
  3852. fsiOPFLD.MedChrgitmType = "06"
  3853. break
  3854. case 12:
  3855. fsiOPFLD.MedChrgitmType = "12"
  3856. break
  3857. case 13:
  3858. fsiOPFLD.MedChrgitmType = "01"
  3859. break
  3860. case 14:
  3861. fsiOPFLD.MedChrgitmType = "04"
  3862. break
  3863. case 15:
  3864. fsiOPFLD.MedChrgitmType = "14"
  3865. break
  3866. }
  3867. memo["hosp_appr_flag"] = "1"
  3868. memo["invoice_no"] = order.MdtrtId
  3869. memo["memo"] = "自费"
  3870. bytesData, _ := json.Marshal(memo)
  3871. fsiOPFLD.Memo = string(bytesData)
  3872. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3873. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3874. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3875. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3876. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3877. fsiOPFLD.BilgDeptName = department.Name
  3878. fsiOPFLD.BilgDeptCodg = department.Number
  3879. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3880. fsiOPFLD.BilgDrName = doctor.UserName
  3881. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3882. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3883. fsiOPFLD.MedChrgitmType = "08"
  3884. memo["hosp_appr_flag"] = "1"
  3885. memo["invoice_no"] = order.MdtrtId
  3886. memo["memo"] = "自费"
  3887. bytesData, _ := json.Marshal(memo)
  3888. fsiOPFLD.Memo = string(bytesData)
  3889. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3890. }
  3891. }
  3892. }
  3893. fmt.Println(fsiOPFLDs)
  3894. struct4201A.Fopfd = fsiOPFLDs
  3895. fmt.Println(struct4201A.Fopfd)
  3896. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3897. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3898. var res2 ResultSix
  3899. var respJSON2 map[string]interface{}
  3900. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3903. return
  3904. }
  3905. userJSONBytes2, _ := json.Marshal(respJSON2)
  3906. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3907. utils.ErrorLog("解析失败:%v", err)
  3908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3909. return
  3910. }
  3911. if res2.Infcode != 0 {
  3912. c.ServeSuccessJSON(map[string]interface{}{
  3913. "failed_code": -10,
  3914. "msg": res2.ErrMsg,
  3915. })
  3916. return
  3917. } else {
  3918. order.IsUploadOrderInfo = 1
  3919. service.UpdateOrder(order)
  3920. c.ServeSuccessJSON(map[string]interface{}{
  3921. "msg": "上传成功",
  3922. })
  3923. }
  3924. }
  3925. func (c *HisApiController) Get4202() {
  3926. order_id, _ := c.GetInt64("order_id")
  3927. admin_user_id, _ := c.GetInt64("admin_user_id")
  3928. order, _ := service.GetHisOrderByIDTwo(order_id)
  3929. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3930. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3931. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3932. if order.ID == 0 {
  3933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3934. return
  3935. }
  3936. var struct4202 models.Struct4202
  3937. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3938. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3939. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3940. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3941. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3942. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3943. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3944. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3945. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3946. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3947. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3948. var config []*models.HisXtDiagnoseConfig
  3949. for _, item := range diagnosis_ids {
  3950. id, _ := strconv.ParseInt(item, 10, 64)
  3951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3952. config = append(config, &diagnosisConfig)
  3953. }
  3954. var tempDiaginfos []models.OwnPayPatnDiagListD
  3955. for index, item := range config {
  3956. if index == 0 {
  3957. var tempDiaginfo models.OwnPayPatnDiagListD
  3958. tempDiaginfo.InoutDiagType = "1"
  3959. tempDiaginfo.DiagCode = item.CountryCode
  3960. tempDiaginfo.DiagName = item.CountryContentName
  3961. tempDiaginfo.DiagType = "1"
  3962. tempDiaginfo.DiagSrtNo = "1"
  3963. tempDiaginfo.MaindiagFlag = "1"
  3964. tempDiaginfo.ValiFlag = "1"
  3965. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3966. } else {
  3967. var tempDiaginfo models.OwnPayPatnDiagListD
  3968. tempDiaginfo.DiagCode = item.CountryCode
  3969. tempDiaginfo.DiagName = item.CountryContentName
  3970. tempDiaginfo.DiagType = "2"
  3971. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3972. tempDiaginfo.MaindiagFlag = "0"
  3973. tempDiaginfo.ValiFlag = "1"
  3974. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3975. }
  3976. }
  3977. struct4202.ODiagListD = tempDiaginfos
  3978. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3979. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3980. var res2 ResultSix
  3981. var respJSON2 map[string]interface{}
  3982. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3985. return
  3986. }
  3987. userJSONBytes2, _ := json.Marshal(respJSON2)
  3988. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3989. utils.ErrorLog("解析失败:%v", err)
  3990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3991. return
  3992. }
  3993. if res2.Infcode != 0 {
  3994. c.ServeSuccessJSON(map[string]interface{}{
  3995. "failed_code": -10,
  3996. "msg": res2.ErrMsg,
  3997. })
  3998. return
  3999. } else {
  4000. order.IsUploadDiagnose = 1
  4001. service.UpdateOrder(order)
  4002. c.ServeSuccessJSON(map[string]interface{}{
  4003. "msg": "上传成功",
  4004. })
  4005. }
  4006. }
  4007. func (c *HisApiController) Get4203() {
  4008. admin_user_id, _ := c.GetInt64("admin_user_id")
  4009. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4010. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4011. order_id, _ := c.GetInt64("order_id")
  4012. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4013. number := ""
  4014. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4015. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4016. if his.ID == 0 {
  4017. number = hospital.Number
  4018. } else {
  4019. number = his.Number
  4020. }
  4021. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  4022. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  4023. var res2 ResultSix
  4024. var respJSON2 map[string]interface{}
  4025. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4028. return
  4029. }
  4030. userJSONBytes2, _ := json.Marshal(respJSON2)
  4031. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4032. utils.ErrorLog("解析失败:%v", err)
  4033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4034. return
  4035. }
  4036. if res2.Infcode != 0 {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": res2.ErrMsg,
  4040. })
  4041. return
  4042. } else {
  4043. order.IsUploadSuccess = 1
  4044. service.UpdateOrderTwo(order)
  4045. c.ServeSuccessJSON(map[string]interface{}{
  4046. "msg": "上传成功",
  4047. })
  4048. }
  4049. }
  4050. func (c *HisApiController) Get4205() {
  4051. order_id, _ := c.GetInt64("order_id")
  4052. admin_user_id, _ := c.GetInt64("admin_user_id")
  4053. fapiao_code := c.GetString("fapiao_code")
  4054. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4055. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4056. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4057. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4058. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  4059. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4060. //order_info = append(order_info, order_info_two...)
  4061. department, _ := service.GetDepartMentDetail(his.Departments)
  4062. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4063. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4064. if order.ID == 0 {
  4065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4066. return
  4067. }
  4068. var struct4201A models.Struct4201A
  4069. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4070. for _, items := range order_info {
  4071. memo := make(map[string]interface{})
  4072. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4073. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4074. fsiOPFLD.MedType = pre.MedType
  4075. fsiOPFLD.FixmedinsCode = miConfig.Code
  4076. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4077. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4078. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4079. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4080. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4081. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4082. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4083. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  4084. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4085. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4086. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4087. fsiOPFLD.BilgDeptName = department.Name
  4088. fsiOPFLD.BilgDeptCodg = department.Number
  4089. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4090. fsiOPFLD.BilgDrName = doctor.UserName
  4091. fsiOPFLD.MedChrgitmType = "09"
  4092. memo["hosp_appr_flag"] = "1"
  4093. memo["invoice_no"] = fapiao_code
  4094. memo["memo"] = "自费"
  4095. bytesData, _ := json.Marshal(memo)
  4096. fsiOPFLD.Memo = string(bytesData)
  4097. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4098. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4099. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4100. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4101. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4102. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4103. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4104. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4105. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4106. fsiOPFLD.BilgDeptName = department.Name
  4107. fsiOPFLD.BilgDeptCodg = department.Number
  4108. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4109. fsiOPFLD.BilgDrName = doctor.UserName
  4110. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4111. case 0:
  4112. break
  4113. case 1:
  4114. fsiOPFLD.MedChrgitmType = "14"
  4115. break
  4116. case 2:
  4117. fsiOPFLD.MedChrgitmType = "05"
  4118. break
  4119. case 3:
  4120. fsiOPFLD.MedChrgitmType = "03"
  4121. break
  4122. case 4:
  4123. fsiOPFLD.MedChrgitmType = "03"
  4124. break
  4125. case 5:
  4126. fsiOPFLD.MedChrgitmType = "08"
  4127. break
  4128. case 6:
  4129. fsiOPFLD.MedChrgitmType = "14"
  4130. break
  4131. case 7:
  4132. fsiOPFLD.MedChrgitmType = "14"
  4133. break
  4134. case 8:
  4135. fsiOPFLD.MedChrgitmType = "03"
  4136. break
  4137. case 9:
  4138. fsiOPFLD.MedChrgitmType = "14"
  4139. break
  4140. case 10:
  4141. fsiOPFLD.MedChrgitmType = "14"
  4142. break
  4143. case 11:
  4144. fsiOPFLD.MedChrgitmType = "06"
  4145. break
  4146. case 12:
  4147. fsiOPFLD.MedChrgitmType = "12"
  4148. break
  4149. case 13:
  4150. fsiOPFLD.MedChrgitmType = "01"
  4151. break
  4152. case 14:
  4153. fsiOPFLD.MedChrgitmType = "04"
  4154. break
  4155. case 15:
  4156. fsiOPFLD.MedChrgitmType = "14"
  4157. break
  4158. }
  4159. memo["hosp_appr_flag"] = "1"
  4160. memo["invoice_no"] = fapiao_code
  4161. memo["memo"] = "自费"
  4162. bytesData, _ := json.Marshal(memo)
  4163. fsiOPFLD.Memo = string(bytesData)
  4164. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4165. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4166. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4167. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4168. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4169. fsiOPFLD.BilgDeptName = department.Name
  4170. fsiOPFLD.BilgDeptCodg = department.Number
  4171. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4172. fsiOPFLD.BilgDrName = doctor.UserName
  4173. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4174. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4175. fsiOPFLD.MedChrgitmType = "08"
  4176. memo["hosp_appr_flag"] = "1"
  4177. memo["invoice_no"] = fapiao_code
  4178. memo["memo"] = "自费"
  4179. bytesData, _ := json.Marshal(memo)
  4180. fsiOPFLD.Memo = string(bytesData)
  4181. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4182. }
  4183. }
  4184. }
  4185. for _, items := range order_info_two {
  4186. memo := make(map[string]interface{})
  4187. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4188. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4189. fsiOPFLD.MedType = pre.MedType
  4190. fsiOPFLD.BkkpSn = items.FeedetlSn
  4191. fsiOPFLD.FixmedinsCode = miConfig.Code
  4192. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4193. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4194. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4195. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4196. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4197. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4198. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4199. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4200. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4201. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4202. fsiOPFLD.BilgDeptName = department.Name
  4203. fsiOPFLD.BilgDeptCodg = department.Number
  4204. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4205. fsiOPFLD.BilgDrName = doctor.UserName
  4206. fsiOPFLD.MedChrgitmType = "09"
  4207. memo["hosp_appr_flag"] = "1"
  4208. memo["invoice_no"] = fapiao_code
  4209. memo["memo"] = "自费"
  4210. bytesData, _ := json.Marshal(memo)
  4211. fsiOPFLD.Memo = string(bytesData)
  4212. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4213. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4214. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4215. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4216. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4217. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4218. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4219. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4220. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4221. fsiOPFLD.BilgDeptName = department.Name
  4222. fsiOPFLD.BilgDeptCodg = department.Number
  4223. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4224. fsiOPFLD.BilgDrName = doctor.UserName
  4225. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4226. case 0:
  4227. break
  4228. case 1:
  4229. fsiOPFLD.MedChrgitmType = "14"
  4230. break
  4231. case 2:
  4232. fsiOPFLD.MedChrgitmType = "05"
  4233. break
  4234. case 3:
  4235. fsiOPFLD.MedChrgitmType = "03"
  4236. break
  4237. case 4:
  4238. fsiOPFLD.MedChrgitmType = "03"
  4239. break
  4240. case 5:
  4241. fsiOPFLD.MedChrgitmType = "08"
  4242. break
  4243. case 6:
  4244. fsiOPFLD.MedChrgitmType = "14"
  4245. break
  4246. case 7:
  4247. fsiOPFLD.MedChrgitmType = "14"
  4248. break
  4249. case 8:
  4250. fsiOPFLD.MedChrgitmType = "03"
  4251. break
  4252. case 9:
  4253. fsiOPFLD.MedChrgitmType = "14"
  4254. break
  4255. case 10:
  4256. fsiOPFLD.MedChrgitmType = "14"
  4257. break
  4258. case 11:
  4259. fsiOPFLD.MedChrgitmType = "06"
  4260. break
  4261. case 12:
  4262. fsiOPFLD.MedChrgitmType = "12"
  4263. break
  4264. case 13:
  4265. fsiOPFLD.MedChrgitmType = "01"
  4266. break
  4267. case 14:
  4268. fsiOPFLD.MedChrgitmType = "04"
  4269. break
  4270. case 15:
  4271. fsiOPFLD.MedChrgitmType = "14"
  4272. break
  4273. }
  4274. memo["hosp_appr_flag"] = "1"
  4275. memo["invoice_no"] = fapiao_code
  4276. memo["memo"] = "自费"
  4277. bytesData, _ := json.Marshal(memo)
  4278. fsiOPFLD.Memo = string(bytesData)
  4279. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4280. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4281. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4282. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4283. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4284. fsiOPFLD.BilgDeptName = department.Name
  4285. fsiOPFLD.BilgDeptCodg = department.Number
  4286. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4287. fsiOPFLD.BilgDrName = doctor.UserName
  4288. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4289. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4290. fsiOPFLD.MedChrgitmType = "08"
  4291. memo["hosp_appr_flag"] = "1"
  4292. memo["invoice_no"] = fapiao_code
  4293. memo["memo"] = "自费"
  4294. bytesData, _ := json.Marshal(memo)
  4295. fsiOPFLD.Memo = string(bytesData)
  4296. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4297. }
  4298. }
  4299. }
  4300. fmt.Println(fsiOPFLDs)
  4301. struct4201A.Fopfd = fsiOPFLDs
  4302. fmt.Println(struct4201A.Fopfd)
  4303. var struct4202 models.Struct4202
  4304. timeLayout := "2006-01-02 15:04:05"
  4305. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4306. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4307. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4308. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4309. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4310. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4311. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4312. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4313. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4314. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4315. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4316. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4317. var config []*models.HisXtDiagnoseConfig
  4318. for _, item := range diagnosis_ids {
  4319. id, _ := strconv.ParseInt(item, 10, 64)
  4320. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4321. config = append(config, &diagnosisConfig)
  4322. }
  4323. var tempDiaginfos []models.OwnPayPatnDiagListD
  4324. for index, item := range config {
  4325. if index == 0 {
  4326. var tempDiaginfo models.OwnPayPatnDiagListD
  4327. tempDiaginfo.InoutDiagType = "1"
  4328. tempDiaginfo.DiagCode = item.CountryCode
  4329. tempDiaginfo.DiagName = item.CountryContentName
  4330. tempDiaginfo.DiagType = "1"
  4331. tempDiaginfo.DiagSrtNo = "1"
  4332. tempDiaginfo.MaindiagFlag = "1"
  4333. tempDiaginfo.ValiFlag = "1"
  4334. tempDiaginfo.DiagDrName = doctor.UserName
  4335. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4336. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4337. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4338. } else {
  4339. var tempDiaginfo models.OwnPayPatnDiagListD
  4340. tempDiaginfo.DiagCode = item.CountryCode
  4341. tempDiaginfo.DiagName = item.CountryContentName
  4342. tempDiaginfo.DiagType = "2"
  4343. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4344. tempDiaginfo.MaindiagFlag = "0"
  4345. tempDiaginfo.ValiFlag = "1"
  4346. tempDiaginfo.DiagDrName = doctor.UserName
  4347. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4348. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4349. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4350. }
  4351. }
  4352. struct4202.ODiagListD = tempDiaginfos
  4353. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4354. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4355. var res2 ResultSix
  4356. var respJSON2 map[string]interface{}
  4357. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4360. return
  4361. }
  4362. userJSONBytes2, _ := json.Marshal(respJSON2)
  4363. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4364. utils.ErrorLog("解析失败:%v", err)
  4365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4366. return
  4367. }
  4368. if res2.Infcode != 0 {
  4369. c.ServeSuccessJSON(map[string]interface{}{
  4370. "failed_code": -10,
  4371. "msg": res2.ErrMsg,
  4372. })
  4373. return
  4374. } else {
  4375. order.IsUploadDiagnose = 1
  4376. order.IsUploadOrderInfo = 1
  4377. service.UpdateOrderTwo(order)
  4378. c.ServeSuccessJSON(map[string]interface{}{
  4379. "msg": "上传成功",
  4380. })
  4381. }
  4382. }
  4383. func (c *HisApiController) Get4207() {
  4384. admin_user_id, _ := c.GetInt64("admin_user_id")
  4385. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4386. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4387. order_id, _ := c.GetInt64("order_id")
  4388. order, _ := service.GetHisOrderByIDTwo(order_id)
  4389. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4390. var struct4207 models.Struct4207
  4391. struct4207.PageNum = "1"
  4392. struct4207.PageSize = "1000"
  4393. struct4207.FixmedinsCode = miConfig.Code
  4394. struct4207.FixmedinsMdtrtID = order.Number
  4395. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4396. saveLog(result, requestLog, "4207", "查询")
  4397. var res2 ResultSix
  4398. var respJSON2 map[string]interface{}
  4399. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4402. return
  4403. }
  4404. userJSONBytes2, _ := json.Marshal(respJSON2)
  4405. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4406. utils.ErrorLog("解析失败:%v", err)
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4408. return
  4409. }
  4410. if res2.Infcode != 0 {
  4411. c.ServeSuccessJSON(map[string]interface{}{
  4412. "failed_code": -10,
  4413. "msg": res2.ErrMsg,
  4414. })
  4415. return
  4416. } else {
  4417. c.ServeSuccessJSON(map[string]interface{}{
  4418. "msg": "查询成功",
  4419. })
  4420. }
  4421. }
  4422. func (c *HisApiController) Get4208() {
  4423. admin_user_id, _ := c.GetInt64("admin_user_id")
  4424. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4425. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4426. order_id, _ := c.GetInt64("order_id")
  4427. order, _ := service.GetHisOrderByIDTwo(order_id)
  4428. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4429. var struct4208 models.Struct4208
  4430. struct4208.PageNum = "1"
  4431. struct4208.PageSize = "1000"
  4432. struct4208.PsnCertType = "01"
  4433. struct4208.Certno = his.Certno
  4434. struct4208.MedType = order.MedType
  4435. struct4208.PsnName = his.Name
  4436. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4437. saveLog(result, requestLog, "4208", "查询")
  4438. var res2 ResultSix
  4439. var respJSON2 map[string]interface{}
  4440. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4443. return
  4444. }
  4445. userJSONBytes2, _ := json.Marshal(respJSON2)
  4446. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4447. utils.ErrorLog("解析失败:%v", err)
  4448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4449. return
  4450. }
  4451. if res2.Infcode != 0 {
  4452. c.ServeSuccessJSON(map[string]interface{}{
  4453. "failed_code": -10,
  4454. "msg": res2.ErrMsg,
  4455. })
  4456. return
  4457. } else {
  4458. c.ServeSuccessJSON(map[string]interface{}{
  4459. "msg": "查询成功",
  4460. })
  4461. }
  4462. }
  4463. func (c *HisApiController) Get4209() {
  4464. admin_user_id, _ := c.GetInt64("admin_user_id")
  4465. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4466. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4467. order_id, _ := c.GetInt64("order_id")
  4468. order, _ := service.GetHisOrderByIDTwo(order_id)
  4469. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4470. var struct4209 models.Struct4209
  4471. struct4209.FixmedinsMdtrtID = order.Number
  4472. struct4209.FixmedinsCode = miConfig.Code
  4473. struct4209.PageSize = "1000"
  4474. struct4209.PageNum = "1"
  4475. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4476. saveLog(result, requestLog, "4209", "查询")
  4477. var res2 ResultSix
  4478. var respJSON2 map[string]interface{}
  4479. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4482. return
  4483. }
  4484. userJSONBytes2, _ := json.Marshal(respJSON2)
  4485. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4486. utils.ErrorLog("解析失败:%v", err)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. if res2.Infcode != 0 {
  4491. c.ServeSuccessJSON(map[string]interface{}{
  4492. "failed_code": -10,
  4493. "msg": res2.ErrMsg,
  4494. })
  4495. return
  4496. } else {
  4497. c.ServeSuccessJSON(map[string]interface{}{
  4498. "msg": "查询成功",
  4499. })
  4500. }
  4501. }
  4502. type Result3101 struct {
  4503. Infcode string `json:"infcode"`
  4504. InfRefmsgid string `json:"inf_refmsgid"`
  4505. RefmsgTime string `json:"refmsg_time"`
  4506. RespondTime string `json:"respond_time"`
  4507. Enctype string `json:"enctype"`
  4508. Signtype string `json:"signtype"`
  4509. ErrMsg string `json:"err_msg"`
  4510. Output struct {
  4511. Result []struct {
  4512. JudgeResultDetailDtos []struct {
  4513. VolaItemType string `json:"vola_item_type"`
  4514. MdtrtID string `json:"mdtrt_id"`
  4515. JrdID string `json:"jrd_id"`
  4516. PatnID string `json:"patn_id"`
  4517. RxID string `json:"rx_id"`
  4518. VolaAmt interface{} `json:"vola_amt"`
  4519. } `json:"judge_result_detail_dtos"`
  4520. RuleID string `json:"rule_id"`
  4521. VolaEvid string `json:"vola_evid"`
  4522. MdtrtID string `json:"mdtrt_id"`
  4523. RuleName string `json:"rule_name"`
  4524. VolaAmtStas string `json:"vola_amt_stas"`
  4525. JrID string `json:"jr_id"`
  4526. PatnID string `json:"patn_id"`
  4527. SevDeg string `json:"sev_deg"`
  4528. VolaAmt float64 `json:"vola_amt"`
  4529. VolaBhvrType string `json:"vola_bhvr_type"`
  4530. VolaCont string `json:"vola_cont"`
  4531. } `json:"result"`
  4532. } `json:"output"`
  4533. }
  4534. type Resultgd3101 struct {
  4535. Infcode int64 `json:"infcode"`
  4536. InfRefmsgid string `json:"inf_refmsgid"`
  4537. RefmsgTime string `json:"refmsg_time"`
  4538. RespondTime string `json:"respond_time"`
  4539. Enctype string `json:"enctype"`
  4540. Signtype string `json:"signtype"`
  4541. ErrMsg string `json:"err_msg"`
  4542. Output struct {
  4543. Result []struct {
  4544. JudgeResultDetailDtos []struct {
  4545. VolaItemType string `json:"vola_item_type"`
  4546. MdtrtID string `json:"mdtrt_id"`
  4547. JrdID string `json:"jrd_id"`
  4548. PatnID string `json:"patn_id"`
  4549. RxID string `json:"rx_id"`
  4550. VolaAmt interface{} `json:"vola_amt"`
  4551. } `json:"judge_result_detail_dtos"`
  4552. RuleID string `json:"rule_id"`
  4553. VolaEvid string `json:"vola_evid"`
  4554. MdtrtID string `json:"mdtrt_id"`
  4555. RuleName string `json:"rule_name"`
  4556. VolaAmtStas string `json:"vola_amt_stas"`
  4557. JrID string `json:"jr_id"`
  4558. PatnID string `json:"patn_id"`
  4559. SevDeg string `json:"sev_deg"`
  4560. VolaAmt float64 `json:"vola_amt"`
  4561. VolaBhvrType string `json:"vola_bhvr_type"`
  4562. VolaCont string `json:"vola_cont"`
  4563. } `json:"result"`
  4564. } `json:"output"`
  4565. }
  4566. func (c *HisApiController) ReadEleToken() {
  4567. admin_user_id, _ := c.GetInt64("admin_user_id")
  4568. his_patient_id, _ := c.GetInt64("his_patient_id")
  4569. adminUser := c.GetAdminUserInfo()
  4570. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4571. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4572. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4573. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4574. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4575. if len(tokens) > 0 {
  4576. c.ServeSuccessJSON(map[string]interface{}{
  4577. "msg": "读取成功",
  4578. })
  4579. } else {
  4580. c.ServeSuccessJSON(map[string]interface{}{
  4581. "failed_code": -10,
  4582. "msg": "读取失败",
  4583. })
  4584. }
  4585. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4586. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4587. if len(tokens) > 0 {
  4588. c.ServeSuccessJSON(map[string]interface{}{
  4589. "msg": "读取成功",
  4590. })
  4591. } else {
  4592. c.ServeSuccessJSON(map[string]interface{}{
  4593. "failed_code": -10,
  4594. "msg": "读取失败",
  4595. })
  4596. }
  4597. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4598. var api string
  4599. 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 +
  4600. "&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"
  4601. resp, requestErr := http.Get(api)
  4602. if requestErr != nil {
  4603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4604. }
  4605. body, ioErr := ioutil.ReadAll(resp.Body)
  4606. if ioErr != nil {
  4607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. }
  4610. var respJSON map[string]interface{}
  4611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4614. return
  4615. }
  4616. var status string
  4617. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4618. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4619. var token string
  4620. var res ResultTwo //1101结果
  4621. var res10265 ResultTwo10265 //1101结果
  4622. if status == "0" { //读卡成功
  4623. var card_info string //卡信息
  4624. var busi_card_info string
  4625. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4626. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4627. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4628. fmt.Println(card_info)
  4629. fmt.Println(busi_card_info)
  4630. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4631. result, _ := json.Marshal(respJSON)
  4632. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4633. utils.ErrorLog("解析失败:%v", err)
  4634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4635. return
  4636. }
  4637. res.ErrMsg = res10265.ErrMsg
  4638. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4639. res.Infcode = infocode
  4640. res.Output = res10265.Output
  4641. res.InfRefmsgid = res10265.InfRefmsgid
  4642. if res.Infcode == 0 {
  4643. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4644. if err == gorm.ErrRecordNotFound {
  4645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4646. return
  4647. } else if err != nil {
  4648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4649. return
  4650. } else {
  4651. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4652. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4653. infoStr := string(Iinfos)
  4654. idetinfoStr := string(Idetinfos)
  4655. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4656. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4657. psn := &models.HisPsn{
  4658. PsnNo: res.Output.Baseinfo.PsnNo,
  4659. PatientId: patient.ID,
  4660. Certno: res.Output.Baseinfo.Certno,
  4661. Gend: res.Output.Baseinfo.Gend,
  4662. Naty: res.Output.Baseinfo.Naty,
  4663. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4664. PsnName: res.Output.Baseinfo.PsnName,
  4665. Age: float64(age),
  4666. Brdy: b,
  4667. Idetinfo: idetinfoStr,
  4668. Insuinfo: infoStr,
  4669. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4670. CardInfo: card_info,
  4671. VerifyNumber: token,
  4672. IdCardType: 4,
  4673. }
  4674. var rf []*ResultFive
  4675. json.Unmarshal([]byte(infoStr), &rf)
  4676. var insutypes []*ResultFive
  4677. var insutype string
  4678. var is390 int = 0
  4679. var is310 int = 0
  4680. for _, item := range rf {
  4681. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4682. insutypes = append(insutypes, item)
  4683. }
  4684. }
  4685. if len(insutypes) == 1 {
  4686. insutype = insutypes[0].Insutype
  4687. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4688. } else {
  4689. for _, i := range insutypes {
  4690. if i.Insutype == "390" {
  4691. is390 = 1
  4692. }
  4693. if i.Insutype == "310" {
  4694. is310 = 1
  4695. }
  4696. }
  4697. }
  4698. if is390 == 1 {
  4699. insutype = "390"
  4700. }
  4701. if is310 == 1 {
  4702. insutype = "310"
  4703. }
  4704. if len(insutypes) == 0 {
  4705. insutype = "310"
  4706. }
  4707. service.CreateHisPsn(psn)
  4708. c.ServeSuccessJSON(map[string]interface{}{
  4709. "patient": patient,
  4710. "number": token,
  4711. "insutype": insutype,
  4712. })
  4713. }
  4714. } else {
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4716. return
  4717. }
  4718. } else { //读卡失败
  4719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4720. return
  4721. }
  4722. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4723. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4724. if len(errMsg) == 0 {
  4725. type ELeData struct {
  4726. Data struct {
  4727. IdNo string `json:"idNo"`
  4728. IdType string `json:"idType"`
  4729. UserName string `json:"userName"`
  4730. EcToken string `json:"ecToken"`
  4731. InsuOrg string `json:"insuOrg"`
  4732. Gender string `json:"gender"`
  4733. Birthday string `json:"birthday"`
  4734. Nationality string `json:"nationality"`
  4735. Email string `json:"email"`
  4736. Extra string `json:"extra"`
  4737. } `json:"data"`
  4738. Code int `json:"code"`
  4739. Message string `json:"message"`
  4740. }
  4741. var ele ELeData
  4742. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4743. if err != nil {
  4744. utils.ErrorLog("解析失败:%v", err)
  4745. }
  4746. token := ele.Data.EcToken
  4747. if len(token) > 0 {
  4748. psn := &models.HisPsn{
  4749. PsnNo: his.PsnNo,
  4750. Age: 0,
  4751. PatientId: his.PatientId,
  4752. Certno: his.Certno,
  4753. Brdy: his.Brdy,
  4754. Gend: his.Gend,
  4755. Naty: his.Naty,
  4756. PsnCertType: his.PsnCertType,
  4757. PsnName: his.PsnName,
  4758. Idetinfo: his.Idetinfo,
  4759. Insuinfo: his.Iinfo,
  4760. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4761. CardInfo: outPutInfo,
  4762. VerifyNumber: token,
  4763. }
  4764. service.CreateHisPsn(psn)
  4765. }
  4766. if len(token) > 0 {
  4767. c.ServeSuccessJSON(map[string]interface{}{
  4768. "msg": "读取成功",
  4769. })
  4770. } else {
  4771. c.ServeSuccessJSON(map[string]interface{}{
  4772. "failed_code": -10,
  4773. "msg": "读取失败",
  4774. })
  4775. }
  4776. }
  4777. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4778. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4779. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4780. type ELeData struct {
  4781. Data struct {
  4782. IdNo string `json:"idNo"`
  4783. IdType string `json:"idType"`
  4784. UserName string `json:"userName"`
  4785. EcToken string `json:"ecToken"`
  4786. InsuOrg string `json:"insuOrg"`
  4787. Gender string `json:"gender"`
  4788. Birthday string `json:"birthday"`
  4789. Nationality string `json:"nationality"`
  4790. Email string `json:"email"`
  4791. Extra string `json:"extra"`
  4792. } `json:"data"`
  4793. Code int `json:"code"`
  4794. Message string `json:"message"`
  4795. }
  4796. var ele ELeData
  4797. err := json.Unmarshal([]byte(result), &ele)
  4798. if err != nil {
  4799. utils.ErrorLog("解析失败:%v", err)
  4800. }
  4801. token := ele.Data.EcToken
  4802. token = Remove0000(token)
  4803. fmt.Println(ele.Data.UserName)
  4804. 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)
  4805. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4806. var res ResultTwo
  4807. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4808. utils.ErrorLog("解析失败:%v", err)
  4809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4810. return
  4811. }
  4812. if res.Infcode == 0 {
  4813. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4814. if err == gorm.ErrRecordNotFound {
  4815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4816. return
  4817. } else if err != nil {
  4818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4819. return
  4820. } else {
  4821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4823. infoStr := string(Iinfos)
  4824. idetinfoStr := string(Idetinfos)
  4825. psn := &models.HisPsn{
  4826. PsnNo: res.Output.Baseinfo.PsnNo,
  4827. PatientId: patient.ID,
  4828. Certno: res.Output.Baseinfo.Certno,
  4829. Gend: res.Output.Baseinfo.Gend,
  4830. Naty: res.Output.Baseinfo.Naty,
  4831. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4832. PsnName: res.Output.Baseinfo.PsnName,
  4833. Idetinfo: idetinfoStr,
  4834. Insuinfo: infoStr,
  4835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4836. CardInfo: "",
  4837. VerifyNumber: token,
  4838. }
  4839. service.CreateHisPsn(psn)
  4840. c.ServeSuccessJSON(map[string]interface{}{
  4841. "patient": patient,
  4842. "number": token,
  4843. })
  4844. }
  4845. } else {
  4846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4847. return
  4848. }
  4849. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4850. idNo := c.GetString("idNo")
  4851. userName := c.GetString("userName")
  4852. ecToken := c.GetString("ecToken")
  4853. insuOrg := c.GetString("insuOrg")
  4854. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4855. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4856. var res ResultTwo
  4857. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4858. utils.ErrorLog("解析失败:%v", err)
  4859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4860. return
  4861. }
  4862. if res.Infcode == 0 {
  4863. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4864. if err == gorm.ErrRecordNotFound {
  4865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4866. return
  4867. } else if err != nil {
  4868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4869. return
  4870. } else {
  4871. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4872. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4873. infoStr := string(Iinfos)
  4874. idetinfoStr := string(Idetinfos)
  4875. psn := &models.HisPsn{
  4876. PsnNo: res.Output.Baseinfo.PsnNo,
  4877. PatientId: patient.ID,
  4878. Certno: res.Output.Baseinfo.Certno,
  4879. Gend: res.Output.Baseinfo.Gend,
  4880. Naty: res.Output.Baseinfo.Naty,
  4881. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4882. PsnName: res.Output.Baseinfo.PsnName,
  4883. Idetinfo: idetinfoStr,
  4884. Insuinfo: infoStr,
  4885. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4886. CardInfo: "",
  4887. VerifyNumber: ecToken,
  4888. InsuplcAdmdvs: insuOrg,
  4889. }
  4890. service.CreateHisPsn(psn)
  4891. c.ServeSuccessJSON(map[string]interface{}{
  4892. "patient": patient,
  4893. "number": ecToken,
  4894. })
  4895. }
  4896. } else {
  4897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4898. return
  4899. }
  4900. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4901. res := c.GetoleInfo()
  4902. if res.Infcode == 0 {
  4903. var result string
  4904. if res.Output.MdtrtCertType == "01" {
  4905. 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)
  4906. } else if res.Output.MdtrtCertType == "02" {
  4907. 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)
  4908. } else if res.Output.MdtrtCertType == "03" {
  4909. 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)
  4910. }
  4911. var dat map[string]interface{}
  4912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4913. fmt.Println(dat)
  4914. } else {
  4915. fmt.Println(err)
  4916. }
  4917. userJSONBytes, _ := json.Marshal(dat)
  4918. var res2 ResultTwo
  4919. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4920. utils.ErrorLog("解析失败:%v", err)
  4921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4922. return
  4923. }
  4924. if res2.Infcode == 0 {
  4925. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4926. if err == gorm.ErrRecordNotFound {
  4927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4928. return
  4929. } else if err != nil {
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4931. return
  4932. } else {
  4933. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4934. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4935. infoStr := string(Iinfos)
  4936. idetinfoStr := string(Idetinfos)
  4937. var rf []*ResultFive
  4938. json.Unmarshal([]byte(infoStr), &rf)
  4939. var insutypes []*ResultFive
  4940. var insutype string
  4941. var is390 int = 0
  4942. var is310 int = 0
  4943. //var insuplc_admdvs string
  4944. for _, item := range rf {
  4945. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4946. insutypes = append(insutypes, item)
  4947. }
  4948. }
  4949. if len(insutypes) == 1 {
  4950. insutype = insutypes[0].Insutype
  4951. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4952. } else {
  4953. for _, i := range insutypes {
  4954. if i.Insutype == "390" {
  4955. is390 = 1
  4956. }
  4957. if i.Insutype == "310" {
  4958. is310 = 1
  4959. }
  4960. }
  4961. }
  4962. if is390 == 1 {
  4963. insutype = "390"
  4964. }
  4965. if is310 == 1 {
  4966. insutype = "310"
  4967. }
  4968. if len(insutypes) == 0 {
  4969. insutype = "310"
  4970. }
  4971. psn := &models.HisPsn{
  4972. PsnNo: res2.Output.Baseinfo.PsnNo,
  4973. PatientId: patient.ID,
  4974. Certno: res2.Output.Baseinfo.Certno,
  4975. Gend: res2.Output.Baseinfo.Gend,
  4976. Naty: res2.Output.Baseinfo.Naty,
  4977. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4978. PsnName: res2.Output.Baseinfo.PsnName,
  4979. Idetinfo: idetinfoStr,
  4980. Insuinfo: infoStr,
  4981. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4982. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4983. VerifyNumber: res.Output.EcToken,
  4984. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4985. }
  4986. service.CreateHisPsn(psn)
  4987. c.ServeSuccessJSON(map[string]interface{}{
  4988. "patient": patient,
  4989. "number": res.Output.CardNo,
  4990. "insutype": insutype,
  4991. })
  4992. }
  4993. } else {
  4994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4995. return
  4996. }
  4997. } else {
  4998. c.ServeSuccessJSON(map[string]interface{}{
  4999. "failed_code": -10,
  5000. "msg": res.ErrMsg,
  5001. })
  5002. }
  5003. } else {
  5004. //if initFlag == 0 {
  5005. // c.TestGetBasBaseInit()
  5006. //}
  5007. //token := c.GetEleBaseInfo()
  5008. //token = Remove0000(token)
  5009. type ELeData struct {
  5010. Code string `json:"code"`
  5011. Data struct {
  5012. Aac002 string `json:"aac002"`
  5013. Aaz500 string `json:"aaz500"`
  5014. ActCardNo string `json:"actCardNo"`
  5015. Bab520 string `json:"bab520"`
  5016. Bkz543 string `json:"bkz543"`
  5017. BusinessType string `json:"businessType"`
  5018. CertfCodg string `json:"certfCodg"`
  5019. EcIndexNo string `json:"ecIndexNo"`
  5020. EcToken string `json:"ecToken"`
  5021. ID0000 string `json:"id0000"`
  5022. IDNo string `json:"idNo"`
  5023. IDType string `json:"idType"`
  5024. Idcode string `json:"idcode"`
  5025. IdentityToken string `json:"identity_token"`
  5026. InsuOrg string `json:"insuOrg"`
  5027. OfficeID string `json:"officeId"`
  5028. OfficeName string `json:"officeName"`
  5029. OperatorID string `json:"operatorId"`
  5030. OperatorName string `json:"operatorName"`
  5031. OrgID string `json:"orgId"`
  5032. UserName string `json:"userName"`
  5033. } `json:"data"`
  5034. Infno interface{} `json:"infno"`
  5035. Message string `json:"message"`
  5036. OrgID string `json:"orgId"`
  5037. TransType string `json:"transType"`
  5038. }
  5039. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5040. fmt.Println(result)
  5041. outPutInfo := Remove0000(result)
  5042. fmt.Println(outPutInfo)
  5043. var ele ELeData
  5044. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5045. if err != nil {
  5046. utils.ErrorLog("解析失败:%v", err)
  5047. }
  5048. token := ele.Data.EcToken
  5049. var result2 string
  5050. var requestLog2 string
  5051. if len(token) > 0 {
  5052. if strings.Contains(ele.Data.IDNo, "HKG") {
  5053. 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)
  5054. } else {
  5055. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5056. }
  5057. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5058. var res ResultTwo
  5059. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5060. utils.ErrorLog("解析失败:%v", err)
  5061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5062. return
  5063. }
  5064. if res.Infcode == 0 {
  5065. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5066. if err == gorm.ErrRecordNotFound {
  5067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5068. return
  5069. } else if err != nil {
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5071. return
  5072. } else {
  5073. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5074. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5075. infoStr := string(Iinfos)
  5076. idetinfoStr := string(Idetinfos)
  5077. psn := &models.HisPsn{
  5078. PsnNo: res.Output.Baseinfo.PsnNo,
  5079. PatientId: patient.ID,
  5080. Certno: res.Output.Baseinfo.Certno,
  5081. Gend: res.Output.Baseinfo.Gend,
  5082. Naty: res.Output.Baseinfo.Naty,
  5083. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5084. PsnName: res.Output.Baseinfo.PsnName,
  5085. Idetinfo: idetinfoStr,
  5086. Insuinfo: infoStr,
  5087. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5088. CardInfo: "",
  5089. VerifyNumber: token,
  5090. }
  5091. service.CreateHisPsn(psn)
  5092. c.ServeSuccessJSON(map[string]interface{}{
  5093. "msg": "读取成功",
  5094. })
  5095. }
  5096. } else {
  5097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5098. return
  5099. }
  5100. } else {
  5101. c.ServeSuccessJSON(map[string]interface{}{
  5102. "failed_code": -10,
  5103. "msg": "读取失败",
  5104. })
  5105. }
  5106. }
  5107. }
  5108. func (c *HisApiController) ReadEleFace() {
  5109. admin_user_id, _ := c.GetInt64("admin_user_id")
  5110. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5111. adminUser := c.GetAdminUserInfo()
  5112. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5113. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5114. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5115. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5116. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5117. if len(tokens) > 0 {
  5118. c.ServeSuccessJSON(map[string]interface{}{
  5119. "msg": "读取成功",
  5120. })
  5121. } else {
  5122. c.ServeSuccessJSON(map[string]interface{}{
  5123. "failed_code": -10,
  5124. "msg": "读取失败",
  5125. })
  5126. }
  5127. }
  5128. }
  5129. func (c *HisApiController) Get9001() {
  5130. adminUser := c.GetAdminUserInfo()
  5131. admin_user_id, _ := c.GetInt64("admin_user_id")
  5132. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5133. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5134. if miConfig.MdtrtareaAdmvs == "350500" {
  5135. service.GetFjAuthorizationInfo(miConfig.Code)
  5136. } else if miConfig.MdtrtareaAdmvs == "131023" {
  5137. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  5138. var dat map[string]interface{}
  5139. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5140. fmt.Println(dat)
  5141. } else {
  5142. fmt.Println(err)
  5143. }
  5144. userJSONBytes, _ := json.Marshal(dat)
  5145. var res models.Result9001
  5146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5147. utils.ErrorLog("解析失败:%v", err)
  5148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5149. return
  5150. }
  5151. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5152. fmt.Println(miConfig.SecretKey)
  5153. var res models.Result9001Two
  5154. 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 +
  5155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  5156. resp, requestErr := http.Get(api)
  5157. if requestErr != nil {
  5158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5159. return
  5160. }
  5161. body, ioErr := ioutil.ReadAll(resp.Body)
  5162. if ioErr != nil {
  5163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5165. return
  5166. }
  5167. var respJSON map[string]interface{}
  5168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5171. return
  5172. }
  5173. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5174. if status == "0" {
  5175. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5176. c.ServeSuccessJSON(map[string]interface{}{
  5177. "failed_code": -10,
  5178. "msg": err_msg,
  5179. })
  5180. return
  5181. }
  5182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5183. result, _ := json.Marshal(respJSON)
  5184. fmt.Println("log")
  5185. fmt.Println(string(result))
  5186. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5187. utils.ErrorLog("解析失败:%v", err)
  5188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5189. return
  5190. }
  5191. if res.Infcode == 0 {
  5192. sign := models.HisSignIn{
  5193. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5194. SignNo: res.Output.Signinoutb.SignNo,
  5195. SignTime: "",
  5196. Ctime: time.Now().Unix(),
  5197. Mtime: time.Now().Unix(),
  5198. Status: 1,
  5199. InputLog: "",
  5200. OutputLog: "",
  5201. FixmedinsCode: miConfig.Code,
  5202. }
  5203. err := service.CreateSignIn(&sign)
  5204. if err == nil {
  5205. c.ServeSuccessJSON(map[string]interface{}{
  5206. "msg": "签到成功",
  5207. })
  5208. }
  5209. } else {
  5210. c.ServeSuccessJSON(map[string]interface{}{
  5211. "failed_code": -10,
  5212. "msg": res.ErrMsg,
  5213. })
  5214. return
  5215. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5216. //return
  5217. }
  5218. } else {
  5219. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5220. var dat map[string]interface{}
  5221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5222. fmt.Println(dat)
  5223. } else {
  5224. fmt.Println(err)
  5225. }
  5226. userJSONBytes, _ := json.Marshal(dat)
  5227. var res models.Result9001
  5228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5229. utils.ErrorLog("解析失败:%v", err)
  5230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5231. return
  5232. }
  5233. if res.Infcode == 0 {
  5234. sign := models.HisSignIn{
  5235. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5236. SignNo: res.Output.Signinoutb.SignNo,
  5237. SignTime: res.Output.Signinoutb.SignTime,
  5238. Ctime: time.Now().Unix(),
  5239. Mtime: time.Now().Unix(),
  5240. Status: 1,
  5241. InputLog: "",
  5242. OutputLog: "",
  5243. FixmedinsCode: miConfig.Code,
  5244. }
  5245. err := service.CreateSignIn(&sign)
  5246. if err == nil {
  5247. c.ServeSuccessJSON(map[string]interface{}{
  5248. "msg": "签到成功",
  5249. })
  5250. }
  5251. }
  5252. }
  5253. }
  5254. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  5255. var res Result3101
  5256. adminUser := c.GetAdminUserInfo()
  5257. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5258. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5259. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5260. //record_time := c.GetString("record_time")
  5261. //trig_scen := c.GetString("trig_scen")
  5262. timeLayout := "2006-01-02"
  5263. loc, _ := time.LoadLocation("Local")
  5264. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5265. if err != nil {
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5267. return res
  5268. }
  5269. recordDateTime := theTime.Unix()
  5270. var patientPrescription models.HisPrescriptionInfo
  5271. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5272. //if patientPrescription.ID == 0 {
  5273. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5274. //}
  5275. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5276. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5277. //
  5278. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5279. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5280. var pp models.PublicParams
  5281. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5282. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5283. pp.FixmedinsName = miConfig.OrgName
  5284. pp.FixmedinsCode = miConfig.Code
  5285. pp.RequestUrl = miConfig.Url
  5286. pp.Cainfo = miConfig.Cainfo
  5287. pp.SecretKey = miConfig.SecretKey
  5288. pp.AccessKey = miConfig.AccessKey
  5289. pp.OpterName = roles.UserName
  5290. var config []*models.HisXtDiagnoseConfig
  5291. for _, item := range diagnosis_ids {
  5292. id, _ := strconv.ParseInt(item, 10, 64)
  5293. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5294. config = append(config, &diagnosisConfig)
  5295. }
  5296. var pd models.PatientDtos
  5297. pd.PatnID = his.PsnNo
  5298. pd.PatnName = his.Name
  5299. pd.Gend = his.Gend
  5300. pd.Brdy = his.Brdy
  5301. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5302. pd.CurrMdtrtID = his.Number
  5303. var fed models.FsiEncounterDtos
  5304. fed.MdtrtID = his.Number
  5305. fed.MedinsID = miConfig.Code
  5306. fed.MedinsName = miConfig.OrgName
  5307. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5308. fed.MedMdtrtType = "1"
  5309. fed.MedinsType = "1"
  5310. fed.MedinsLv = "11"
  5311. tm := time.Unix(his.RecordDate, 0)
  5312. s_tm := tm.Format("2006-01-02 15:04:05")
  5313. fed.AdmDate = s_tm
  5314. fed.DscgDate = s_tm
  5315. fed.DscgMainDiseCodg = config[0].CountryCode
  5316. fed.DscgMainDiseName = config[0].CountryContentName
  5317. //诊断信息
  5318. var fdds []*models.FsiDiagnoseDtos
  5319. for index, item := range config {
  5320. if index == 0 {
  5321. var fdd models.FsiDiagnoseDtos
  5322. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5323. fdd.InoutDiseType = "1"
  5324. fdd.MaindiseFlag = "1"
  5325. fdd.DiseDate = s_tm
  5326. fdd.DiasSrtNo = "1"
  5327. fdd.DiseName = item.CountryContentName
  5328. fdd.DiseCodg = item.CountryCode
  5329. fdds = append(fdds, &fdd)
  5330. } else {
  5331. var fdd models.FsiDiagnoseDtos
  5332. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5333. fdd.InoutDiseType = "1"
  5334. fdd.MaindiseFlag = "1"
  5335. fdd.DiseDate = s_tm
  5336. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5337. fdd.DiseName = item.CountryContentName
  5338. fdd.DiseCodg = item.CountryCode
  5339. fdds = append(fdds, &fdd)
  5340. }
  5341. }
  5342. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5343. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5344. fed.AdmDeptName = department.Name
  5345. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5346. fed.DscgDeptName = department.Name
  5347. fed.MedMdtrtType = "1"
  5348. fed.MedType = "11"
  5349. //if his.Insutype == "390" {
  5350. // fed.MedType = "1402"
  5351. //} else {
  5352. // fed.MedType = "9933"
  5353. //}
  5354. var orders []*models.FsiOrderDtos
  5355. if trig_scen == "2" {
  5356. //处方医嘱信息
  5357. for _, item := range prescriptions {
  5358. for _, subItem := range item.HisDoctorAdviceInfo {
  5359. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5360. var order models.FsiOrderDtos
  5361. order.RxID = strconv.FormatInt(item.ID, 10)
  5362. order.Rxno = strconv.FormatInt(item.ID, 10)
  5363. order.LongDrordFlag = "0"
  5364. order.HilistType = "1"
  5365. order.ChrgType = "1"
  5366. order.DrordBhvr = "-"
  5367. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5368. order.HosplistName = subItem.BaseDrugLib.DrugName
  5369. order.HilistLv = "1"
  5370. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5371. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5372. order.HosplistName = subItem.BaseDrugLib.DrugName
  5373. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5374. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5375. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5376. order.OwnpayAmt = ""
  5377. order.SelfpayAmt = ""
  5378. order.Spec = ""
  5379. order.SpecUnt = ""
  5380. order.DrordBegnDate = s_tm
  5381. order.DrordStopDate = ""
  5382. order.DrordDrCodg = doctor_info.DoctorNumber
  5383. order.DrordDeptName = department.Name
  5384. order.DrordDeptCodg = department.Number
  5385. order.DrordDrName = doctor_info.UserName
  5386. order.DrordDrProfttl = "234"
  5387. order.CurrDrordFlag = "1"
  5388. orders = append(orders, &order)
  5389. }
  5390. }
  5391. for _, subItem := range item.HisPrescriptionProject {
  5392. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5393. var order models.FsiOrderDtos
  5394. order.RxID = strconv.FormatInt(item.ID, 10)
  5395. order.Rxno = strconv.FormatInt(item.ID, 10)
  5396. order.LongDrordFlag = "0"
  5397. order.HilistType = "1"
  5398. order.ChrgType = "1"
  5399. order.DrordBhvr = "-"
  5400. order.HilistCode = subItem.HisProject.MedicalCode
  5401. order.HosplistName = subItem.HisProject.ProjectName
  5402. order.HilistLv = "1"
  5403. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5404. order.HosplistCode = subItem.HisProject.MedicalCode
  5405. order.HosplistName = subItem.HisProject.ProjectName
  5406. order.Cnt = subItem.Count
  5407. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5408. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5409. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5410. order.OwnpayAmt = ""
  5411. order.SelfpayAmt = ""
  5412. order.Spec = ""
  5413. order.SpecUnt = ""
  5414. order.DrordBegnDate = s_tm
  5415. order.DrordStopDate = ""
  5416. order.DrordDrCodg = doctor_info.DoctorNumber
  5417. order.DrordDeptName = department.Name
  5418. order.DrordDeptCodg = department.Number
  5419. order.DrordDrName = doctor_info.UserName
  5420. order.DrordDrProfttl = "234"
  5421. order.CurrDrordFlag = "1"
  5422. orders = append(orders, &order)
  5423. }
  5424. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5425. var order models.FsiOrderDtos
  5426. order.RxID = strconv.FormatInt(item.ID, 10)
  5427. order.Rxno = strconv.FormatInt(item.ID, 10)
  5428. order.LongDrordFlag = "0"
  5429. order.HilistType = "1"
  5430. order.ChrgType = "1"
  5431. order.DrordBhvr = "-"
  5432. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5433. order.HosplistName = subItem.GoodInfo.GoodName
  5434. order.HilistLv = "1"
  5435. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5436. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5437. order.HosplistName = subItem.GoodInfo.GoodName
  5438. order.Cnt = subItem.Count
  5439. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5440. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5441. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5442. order.OwnpayAmt = ""
  5443. order.SelfpayAmt = ""
  5444. order.Spec = ""
  5445. order.SpecUnt = ""
  5446. order.DrordBegnDate = s_tm
  5447. order.DrordStopDate = ""
  5448. order.DrordDrCodg = doctor_info.DoctorNumber
  5449. order.DrordDeptName = department.Name
  5450. order.DrordDeptCodg = department.Number
  5451. order.DrordDrName = doctor_info.UserName
  5452. order.DrordDrProfttl = "234"
  5453. order.CurrDrordFlag = "1"
  5454. orders = append(orders, &order)
  5455. }
  5456. }
  5457. }
  5458. //处方医嘱信息
  5459. }
  5460. fed.MatnStas = "0"
  5461. fed.MedfeeSumamt = "0"
  5462. fed.OwnpayAmt = "0"
  5463. fed.SelfpayAmt = "0"
  5464. fed.AcctPayamt = "0"
  5465. fed.MaAmt = "0"
  5466. fed.HifpPayamt = "0"
  5467. fed.SetlTotlnum = "1"
  5468. fed.Insutype = his.Insutype
  5469. fed.ReimFlag = "0"
  5470. fed.OutSetlFlag = "0"
  5471. var fopd []*models.FsiOperationDtosData
  5472. data := make(map[string]interface{})
  5473. data["fed"] = fed
  5474. data["fdd"] = fdds
  5475. data["fod"] = orders
  5476. data["pd"] = pd
  5477. data["pp"] = pp
  5478. data["fopd"] = fopd
  5479. data["trig_scen"] = trig_scen
  5480. fmt.Println(data)
  5481. fmt.Println(fed)
  5482. fmt.Println(fdds)
  5483. fmt.Println(orders)
  5484. fmt.Println(pd)
  5485. fmt.Println(pp)
  5486. fmt.Println(fopd)
  5487. client := &http.Client{}
  5488. bytesData, _ := json.Marshal(data)
  5489. var req *http.Request
  5490. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5491. if miConfig.MdtrtareaAdmvs == "320921" {
  5492. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5493. } else {
  5494. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5495. }
  5496. resp, _ := client.Do(req)
  5497. defer resp.Body.Close()
  5498. body, ioErr := ioutil.ReadAll(resp.Body)
  5499. if ioErr != nil {
  5500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5502. return res
  5503. }
  5504. var respJSON map[string]interface{}
  5505. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5508. return res
  5509. }
  5510. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5511. fmt.Println(respJSON)
  5512. result, _ := json.Marshal(respJSON)
  5513. fmt.Println(result)
  5514. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5515. utils.ErrorLog("解析失败:%v", err)
  5516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5517. return res
  5518. }
  5519. return res
  5520. } else {
  5521. //if miConfig.MdtrtareaAdmvs == "441202" {
  5522. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5523. saveLog(output, input, "3101", "事前")
  5524. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5525. utils.ErrorLog("解析失败:%v", err)
  5526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5527. return
  5528. }
  5529. return res
  5530. //}
  5531. }
  5532. }
  5533. 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) {
  5534. adminUser := c.GetAdminUserInfo()
  5535. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5536. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5538. //record_time := c.GetString("record_time")
  5539. //trig_scen := c.GetString("trig_scen")
  5540. timeLayout := "2006-01-02"
  5541. loc, _ := time.LoadLocation("Local")
  5542. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5543. if err != nil {
  5544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5545. return res
  5546. }
  5547. recordDateTime := theTime.Unix()
  5548. var patientPrescription models.HisPrescriptionInfo
  5549. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5550. if patientPrescription.ID == 0 {
  5551. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5552. }
  5553. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5554. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5555. //
  5556. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5557. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5558. var pp models.PublicParams
  5559. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5560. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5561. pp.FixmedinsName = miConfig.OrgName
  5562. pp.FixmedinsCode = miConfig.Code
  5563. pp.RequestUrl = miConfig.Url
  5564. pp.Cainfo = miConfig.Cainfo
  5565. pp.SecretKey = miConfig.SecretKey
  5566. pp.AccessKey = miConfig.AccessKey
  5567. pp.OpterName = roles.UserName
  5568. var config []*models.HisXtDiagnoseConfig
  5569. for _, item := range diagnosis_ids {
  5570. id, _ := strconv.ParseInt(item, 10, 64)
  5571. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5572. config = append(config, &diagnosisConfig)
  5573. }
  5574. var pd models.PatientDtos
  5575. pd.PatnID = his.PsnNo
  5576. pd.PatnName = his.Name
  5577. pd.Gend = his.Gend
  5578. pd.Brdy = his.Brdy
  5579. pd.Poolarea = his.InsuplcAdmdvs
  5580. pd.CurrMdtrtID = his.Number
  5581. var fed models.FsiEncounterDtos
  5582. fed.MdtrtID = his.Number
  5583. fed.MedinsID = miConfig.Code
  5584. fed.MedinsName = miConfig.OrgName
  5585. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5586. fed.MedMdtrtType = "1"
  5587. fed.MedinsType = "1"
  5588. fed.MedinsLv = "11"
  5589. tm := time.Unix(his.RecordDate, 0)
  5590. s_tm := tm.Format("2006-01-02 15:04:05")
  5591. fed.AdmDate = s_tm
  5592. fed.DscgDate = s_tm
  5593. fed.DscgMainDiseCodg = config[0].CountryCode
  5594. fed.DscgMainDiseName = config[0].CountryContentName
  5595. //诊断信息
  5596. var fdds []*models.FsiDiagnoseDtos
  5597. for index, item := range config {
  5598. if index == 0 {
  5599. var fdd models.FsiDiagnoseDtos
  5600. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5601. fdd.InoutDiseType = "1"
  5602. fdd.MaindiseFlag = "1"
  5603. fdd.DiseDate = s_tm
  5604. fdd.DiasSrtNo = "1"
  5605. fdd.DiseName = item.CountryContentName
  5606. fdd.DiseCodg = item.CountryCode
  5607. fdds = append(fdds, &fdd)
  5608. } else {
  5609. var fdd models.FsiDiagnoseDtos
  5610. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5611. fdd.InoutDiseType = "1"
  5612. fdd.MaindiseFlag = "1"
  5613. fdd.DiseDate = s_tm
  5614. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5615. fdd.DiseName = item.CountryContentName
  5616. fdd.DiseCodg = item.CountryCode
  5617. fdds = append(fdds, &fdd)
  5618. }
  5619. }
  5620. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5621. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5622. fed.AdmDeptName = department.Name
  5623. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5624. fed.DscgDeptName = department.Name
  5625. fed.MedMdtrtType = "1"
  5626. fed.MedType = "11"
  5627. //if his.Insutype == "390" {
  5628. // fed.MedType = "1402"
  5629. //} else {
  5630. // fed.MedType = "9933"
  5631. //}
  5632. var orders []*models.FsiOrderDtos
  5633. if trig_scen == "2" {
  5634. //处方医嘱信息
  5635. for _, item := range prescriptions {
  5636. for _, subItem := range item.HisDoctorAdviceInfo {
  5637. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5638. var order models.FsiOrderDtos
  5639. order.RxID = strconv.FormatInt(item.ID, 10)
  5640. order.Rxno = strconv.FormatInt(item.ID, 10)
  5641. order.LongDrordFlag = "0"
  5642. order.HilistType = "1"
  5643. order.ChrgType = "1"
  5644. order.DrordBhvr = "-"
  5645. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5646. order.HosplistName = subItem.BaseDrugLib.DrugName
  5647. order.HilistLv = "1"
  5648. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5649. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5650. order.HosplistName = subItem.BaseDrugLib.DrugName
  5651. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5652. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5653. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5654. order.OwnpayAmt = ""
  5655. order.SelfpayAmt = ""
  5656. order.Spec = ""
  5657. order.SpecUnt = ""
  5658. order.DrordBegnDate = s_tm
  5659. order.DrordStopDate = ""
  5660. order.DrordDrCodg = doctor_info.DoctorNumber
  5661. order.DrordDeptName = department.Name
  5662. order.DrordDeptCodg = department.Number
  5663. order.DrordDrName = doctor_info.UserName
  5664. order.DrordDrProfttl = "234"
  5665. order.CurrDrordFlag = "1"
  5666. orders = append(orders, &order)
  5667. }
  5668. }
  5669. for _, subItem := range item.HisPrescriptionProject {
  5670. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5671. var order models.FsiOrderDtos
  5672. order.RxID = strconv.FormatInt(item.ID, 10)
  5673. order.Rxno = strconv.FormatInt(item.ID, 10)
  5674. order.LongDrordFlag = "0"
  5675. order.HilistType = "1"
  5676. order.ChrgType = "1"
  5677. order.DrordBhvr = "-"
  5678. order.HilistCode = subItem.HisProject.MedicalCode
  5679. order.HosplistName = subItem.HisProject.ProjectName
  5680. order.HilistLv = "1"
  5681. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5682. order.HosplistCode = subItem.HisProject.MedicalCode
  5683. order.HosplistName = subItem.HisProject.ProjectName
  5684. order.Cnt = subItem.Count
  5685. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5686. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5687. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5688. order.OwnpayAmt = ""
  5689. order.SelfpayAmt = ""
  5690. order.Spec = ""
  5691. order.SpecUnt = ""
  5692. order.DrordBegnDate = s_tm
  5693. order.DrordStopDate = ""
  5694. order.DrordDrCodg = doctor_info.DoctorNumber
  5695. order.DrordDeptName = department.Name
  5696. order.DrordDeptCodg = department.Number
  5697. order.DrordDrName = doctor_info.UserName
  5698. order.DrordDrProfttl = "234"
  5699. order.CurrDrordFlag = "1"
  5700. orders = append(orders, &order)
  5701. }
  5702. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5703. var order models.FsiOrderDtos
  5704. order.RxID = strconv.FormatInt(item.ID, 10)
  5705. order.Rxno = strconv.FormatInt(item.ID, 10)
  5706. order.LongDrordFlag = "0"
  5707. order.HilistType = "1"
  5708. order.ChrgType = "1"
  5709. order.DrordBhvr = "-"
  5710. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5711. order.HosplistName = subItem.GoodInfo.GoodName
  5712. order.HilistLv = "1"
  5713. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5714. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5715. order.HosplistName = subItem.GoodInfo.GoodName
  5716. order.Cnt = subItem.Count
  5717. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5718. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5719. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5720. order.OwnpayAmt = ""
  5721. order.SelfpayAmt = ""
  5722. order.Spec = ""
  5723. order.SpecUnt = ""
  5724. order.DrordBegnDate = s_tm
  5725. order.DrordStopDate = ""
  5726. order.DrordDrCodg = doctor_info.DoctorNumber
  5727. order.DrordDeptName = department.Name
  5728. order.DrordDeptCodg = department.Number
  5729. order.DrordDrName = doctor_info.UserName
  5730. order.DrordDrProfttl = "234"
  5731. order.CurrDrordFlag = "1"
  5732. orders = append(orders, &order)
  5733. }
  5734. }
  5735. }
  5736. //处方医嘱信息
  5737. }
  5738. fed.MatnStas = "0"
  5739. fed.MedfeeSumamt = "0"
  5740. fed.OwnpayAmt = "0"
  5741. fed.SelfpayAmt = "0"
  5742. fed.AcctPayamt = "0"
  5743. fed.MaAmt = "0"
  5744. fed.HifpPayamt = "0"
  5745. fed.SetlTotlnum = "1"
  5746. fed.Insutype = his.Insutype
  5747. fed.ReimFlag = "0"
  5748. fed.OutSetlFlag = "0"
  5749. var fopd []*models.FsiOperationDtosData
  5750. data := make(map[string]interface{})
  5751. data["fed"] = fed
  5752. data["fdd"] = fdds
  5753. data["fod"] = orders
  5754. data["pd"] = pd
  5755. data["pp"] = pp
  5756. data["fopd"] = fopd
  5757. data["trig_scen"] = trig_scen
  5758. fmt.Println(data)
  5759. fmt.Println(fed)
  5760. fmt.Println(fdds)
  5761. fmt.Println(orders)
  5762. fmt.Println(pd)
  5763. fmt.Println(pp)
  5764. fmt.Println(fopd)
  5765. client := &http.Client{}
  5766. bytesData, _ := json.Marshal(data)
  5767. var req *http.Request
  5768. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5769. if miConfig.MdtrtareaAdmvs == "320921" {
  5770. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5771. } else {
  5772. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5773. }
  5774. resp, _ := client.Do(req)
  5775. defer resp.Body.Close()
  5776. body, ioErr := ioutil.ReadAll(resp.Body)
  5777. if ioErr != nil {
  5778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5780. return res
  5781. }
  5782. var respJSON map[string]interface{}
  5783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5786. return res
  5787. }
  5788. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5789. fmt.Println(respJSON)
  5790. result, _ := json.Marshal(respJSON)
  5791. fmt.Println(result)
  5792. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5793. utils.ErrorLog("解析失败:%v", err)
  5794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5795. return res
  5796. }
  5797. return res
  5798. } else {
  5799. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5800. saveLog(output, input, "3101", "事前")
  5801. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5802. utils.ErrorLog("解析失败:%v", err)
  5803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5804. return
  5805. }
  5806. return res
  5807. }
  5808. return res
  5809. }
  5810. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5811. ////patient_id, _ := c.GetInt64("patient_id")
  5812. //order_id, _ := c.GetInt64("order_id")
  5813. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5814. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5815. //trig_scen := c.GetString("trig_scen")
  5816. adminUser := c.GetAdminUserInfo()
  5817. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5818. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5819. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5820. record_time := c.GetString("record_time")
  5821. order, _ := service.GetHisOrderByID(order_id)
  5822. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5823. timeLayout := "2006-01-02"
  5824. loc, _ := time.LoadLocation("Local")
  5825. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5826. if err != nil {
  5827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5828. return
  5829. }
  5830. recordDateTime := theTime.Unix()
  5831. var patientPrescription models.HisPrescriptionInfo
  5832. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5833. if patientPrescription.ID == 0 {
  5834. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5835. }
  5836. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5837. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5838. //
  5839. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5840. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5841. var pp models.PublicParams
  5842. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5843. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5844. pp.FixmedinsName = miConfig.OrgName
  5845. pp.FixmedinsCode = miConfig.Code
  5846. pp.RequestUrl = miConfig.Url
  5847. pp.Cainfo = miConfig.Cainfo
  5848. pp.SecretKey = miConfig.SecretKey
  5849. pp.AccessKey = miConfig.AccessKey
  5850. pp.OpterName = roles.UserName
  5851. var config []*models.HisXtDiagnoseConfig
  5852. for _, item := range diagnosis_ids {
  5853. id, _ := strconv.ParseInt(item, 10, 64)
  5854. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5855. config = append(config, &diagnosisConfig)
  5856. }
  5857. var pd models.PatientDtos
  5858. pd.PatnID = his.PsnNo
  5859. pd.PatnName = his.Name
  5860. pd.Gend = his.Gend
  5861. pd.Brdy = psn_info.Brdy
  5862. pd.Poolarea = his.InsuplcAdmdvs
  5863. pd.CurrMdtrtID = his.Number
  5864. var fed models.FsiEncounterDtos
  5865. fed.MdtrtID = his.Number
  5866. fed.MedinsID = miConfig.Code
  5867. fed.MedinsName = miConfig.OrgName
  5868. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5869. fed.MedMdtrtType = "1"
  5870. fed.MedinsType = "1"
  5871. fed.MedinsLv = "11"
  5872. tm := time.Unix(his.RecordDate, 0)
  5873. s_tm := tm.Format("2006-01-02 15:04:05")
  5874. fed.AdmDate = s_tm
  5875. fed.DscgDate = s_tm
  5876. fed.DscgMainDiseCodg = config[0].CountryCode
  5877. fed.DscgMainDiseName = config[0].CountryContentName
  5878. //诊断信息
  5879. var fdds []*models.FsiDiagnoseDtos
  5880. for index, item := range config {
  5881. if index == 0 {
  5882. var fdd models.FsiDiagnoseDtos
  5883. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5884. fdd.InoutDiseType = "1"
  5885. fdd.MaindiseFlag = "1"
  5886. fdd.DiseDate = s_tm
  5887. fdd.DiasSrtNo = "1"
  5888. fdd.DiseName = item.CountryContentName
  5889. fdd.DiseCodg = item.CountryCode
  5890. fdds = append(fdds, &fdd)
  5891. } else {
  5892. var fdd models.FsiDiagnoseDtos
  5893. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5894. fdd.InoutDiseType = "1"
  5895. fdd.MaindiseFlag = "1"
  5896. fdd.DiseDate = s_tm
  5897. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5898. fdd.DiseName = item.CountryContentName
  5899. fdd.DiseCodg = item.CountryCode
  5900. fdds = append(fdds, &fdd)
  5901. }
  5902. }
  5903. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5904. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5905. fed.AdmDeptName = department.Name
  5906. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5907. fed.DscgDeptName = department.Name
  5908. fed.MedType = order.MedType
  5909. //处方医嘱信息
  5910. var orders []*models.FsiOrderDtos
  5911. //for _, item := range prescriptions {
  5912. // for _, subItem := range item.HisDoctorAdviceInfo {
  5913. // var order models.FsiOrderDtos
  5914. // order.RxID = strconv.FormatInt(item.ID, 10)
  5915. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5916. // order.LongDrordFlag = "0"
  5917. // order.HilistType = "1"
  5918. // order.ChrgType = "1"
  5919. // order.DrordBhvr = "-"
  5920. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5921. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5922. // order.HilistLv = "1"
  5923. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5924. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5925. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5926. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5927. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5928. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5929. // order.OwnpayAmt = ""
  5930. // order.SelfpayAmt = ""
  5931. // order.Spec = ""
  5932. // order.SpecUnt = ""
  5933. // order.DrordBegnDate = s_tm
  5934. // order.DrordStopDate = ""
  5935. // order.DrordDrCodg = "1"
  5936. // order.DrordDeptName = department.Name
  5937. // order.DrordDrCodg = "1"
  5938. // order.DrordDrName = doctor_info.UserName
  5939. // order.DrordDrProfttl = ""
  5940. // order.CurrDrordFlag = "1"
  5941. // orders = append(orders, &order)
  5942. // }
  5943. // for _, subItem := range item.HisPrescriptionProject {
  5944. // if subItem.Type == 2 {
  5945. // var order models.FsiOrderDtos
  5946. // order.RxID = strconv.FormatInt(item.ID, 10)
  5947. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5948. // order.LongDrordFlag = "0"
  5949. // order.HilistType = "1"
  5950. // order.ChrgType = "1"
  5951. // order.DrordBhvr = "-"
  5952. // order.HilistCode = subItem.HisProject.MedicalCode
  5953. // order.HosplistName = subItem.HisProject.ProjectName
  5954. // order.HilistLv = "1"
  5955. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5956. // order.HosplistCode = subItem.HisProject.MedicalCode
  5957. // order.HosplistName = subItem.HisProject.ProjectName
  5958. // order.Cnt = subItem.Count
  5959. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5960. //
  5961. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5962. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5963. // order.OwnpayAmt = ""
  5964. // order.SelfpayAmt = ""
  5965. // order.Spec = ""
  5966. // order.SpecUnt = ""
  5967. // order.DrordBegnDate = s_tm
  5968. // order.DrordStopDate = ""
  5969. // order.DrordDrCodg = "1"
  5970. // order.DrordDeptName = department.Name
  5971. // order.DrordDrCodg = "1"
  5972. // order.DrordDrName = doctor_info.UserName
  5973. // order.DrordDrProfttl = ""
  5974. // order.CurrDrordFlag = "1"
  5975. // orders = append(orders, &order)
  5976. //
  5977. // }
  5978. // if subItem.Type == 3 {
  5979. //
  5980. // var order models.FsiOrderDtos
  5981. // order.RxID = strconv.FormatInt(item.ID, 10)
  5982. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5983. // order.LongDrordFlag = "0"
  5984. // order.HilistType = "1"
  5985. // order.ChrgType = "1"
  5986. // order.DrordBhvr = "-"
  5987. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5988. // order.HosplistName = subItem.GoodInfo.GoodName
  5989. // order.HilistLv = "1"
  5990. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5991. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5992. // order.HosplistName = subItem.GoodInfo.GoodName
  5993. // order.Cnt = subItem.Count
  5994. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5995. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5996. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5997. // order.OwnpayAmt = ""
  5998. // order.SelfpayAmt = ""
  5999. // order.Spec = ""
  6000. // order.SpecUnt = ""
  6001. // order.DrordBegnDate = s_tm
  6002. // order.DrordStopDate = ""
  6003. // order.DrordDrCodg = "1"
  6004. // order.DrordDeptName = department.Name
  6005. // order.DrordDrCodg = "1"
  6006. // order.DrordDrName = doctor_info.UserName
  6007. // order.DrordDrProfttl = ""
  6008. // order.CurrDrordFlag = "1"
  6009. // orders = append(orders, &order)
  6010. //
  6011. // }
  6012. // }
  6013. //}
  6014. for _, item := range prescriptions {
  6015. for _, subItem := range item.HisDoctorAdviceInfo {
  6016. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6017. var order models.FsiOrderDtos
  6018. order.RxID = strconv.FormatInt(item.ID, 10)
  6019. order.Rxno = strconv.FormatInt(item.ID, 10)
  6020. order.LongDrordFlag = "0"
  6021. order.HilistType = "1"
  6022. order.ChrgType = "1"
  6023. order.DrordBhvr = "-"
  6024. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6025. order.HosplistName = subItem.BaseDrugLib.DrugName
  6026. order.HilistLv = "1"
  6027. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6028. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6029. order.HosplistName = subItem.BaseDrugLib.DrugName
  6030. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6031. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6032. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6033. order.OwnpayAmt = ""
  6034. order.SelfpayAmt = ""
  6035. order.Spec = ""
  6036. order.SpecUnt = ""
  6037. order.DrordBegnDate = s_tm
  6038. order.DrordStopDate = ""
  6039. order.DrordDrCodg = doctor_info.DoctorNumber
  6040. order.DrordDeptName = department.Name
  6041. order.DrordDeptCodg = department.Number
  6042. order.DrordDrName = doctor_info.UserName
  6043. order.DrordDrProfttl = "234"
  6044. order.CurrDrordFlag = "1"
  6045. orders = append(orders, &order)
  6046. }
  6047. }
  6048. for _, subItem := range item.HisPrescriptionProject {
  6049. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6050. var order models.FsiOrderDtos
  6051. order.RxID = strconv.FormatInt(item.ID, 10)
  6052. order.Rxno = strconv.FormatInt(item.ID, 10)
  6053. order.LongDrordFlag = "0"
  6054. order.HilistType = "1"
  6055. order.ChrgType = "1"
  6056. order.DrordBhvr = "-"
  6057. order.HilistCode = subItem.HisProject.MedicalCode
  6058. order.HosplistName = subItem.HisProject.ProjectName
  6059. order.HilistLv = "1"
  6060. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6061. order.HosplistCode = subItem.HisProject.MedicalCode
  6062. order.HosplistName = subItem.HisProject.ProjectName
  6063. order.Cnt = subItem.Count
  6064. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6065. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6066. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6067. order.OwnpayAmt = ""
  6068. order.SelfpayAmt = ""
  6069. order.Spec = ""
  6070. order.SpecUnt = ""
  6071. order.DrordBegnDate = s_tm
  6072. order.DrordStopDate = ""
  6073. order.DrordDrCodg = doctor_info.DoctorNumber
  6074. order.DrordDeptName = department.Name
  6075. order.DrordDeptCodg = department.Number
  6076. order.DrordDrName = doctor_info.UserName
  6077. order.DrordDrProfttl = "234"
  6078. order.CurrDrordFlag = "1"
  6079. orders = append(orders, &order)
  6080. }
  6081. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6082. var order models.FsiOrderDtos
  6083. order.RxID = strconv.FormatInt(item.ID, 10)
  6084. order.Rxno = strconv.FormatInt(item.ID, 10)
  6085. order.LongDrordFlag = "0"
  6086. order.HilistType = "1"
  6087. order.ChrgType = "1"
  6088. order.DrordBhvr = "0"
  6089. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6090. order.HosplistName = subItem.GoodInfo.GoodName
  6091. order.HilistLv = "1"
  6092. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6093. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6094. order.HosplistName = subItem.GoodInfo.GoodName
  6095. order.Cnt = subItem.Count
  6096. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6097. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6098. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6099. order.OwnpayAmt = ""
  6100. order.SelfpayAmt = ""
  6101. order.Spec = ""
  6102. order.SpecUnt = ""
  6103. order.DrordBegnDate = s_tm
  6104. order.DrordStopDate = ""
  6105. order.DrordDrCodg = doctor_info.DoctorNumber
  6106. order.DrordDeptName = department.Name
  6107. order.DrordDeptCodg = department.Number
  6108. order.DrordDrName = doctor_info.UserName
  6109. order.DrordDrProfttl = "234"
  6110. order.CurrDrordFlag = "1"
  6111. orders = append(orders, &order)
  6112. }
  6113. }
  6114. }
  6115. //处方医嘱信息
  6116. fed.MatnStas = "0"
  6117. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6118. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6119. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6120. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6121. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6122. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6123. fed.SetlTotlnum = "1"
  6124. fed.Insutype = his.Insutype
  6125. fed.ReimFlag = "0"
  6126. fed.OutSetlFlag = "0"
  6127. var fopd []*models.FsiOperationDtosData
  6128. data := make(map[string]interface{})
  6129. data["fed"] = fed
  6130. data["fdd"] = fdds
  6131. data["fod"] = orders
  6132. data["pd"] = pd
  6133. data["pp"] = pp
  6134. data["fopd"] = fopd
  6135. data["trig_scen"] = trig_scen
  6136. client := &http.Client{}
  6137. bytesData, _ := json.Marshal(data)
  6138. var req *http.Request
  6139. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6140. if miConfig.MdtrtareaAdmvs == "320921" {
  6141. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6142. } else {
  6143. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6144. }
  6145. resp, _ := client.Do(req)
  6146. defer resp.Body.Close()
  6147. body, ioErr := ioutil.ReadAll(resp.Body)
  6148. if ioErr != nil {
  6149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6151. return res
  6152. }
  6153. var respJSON map[string]interface{}
  6154. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return res
  6158. }
  6159. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6160. result, _ := json.Marshal(respJSON)
  6161. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6162. utils.ErrorLog("解析失败:%v", err)
  6163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6164. return res
  6165. }
  6166. return res
  6167. } else {
  6168. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6169. saveLog(output, input, "3102", "事中")
  6170. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6171. utils.ErrorLog("解析失败:%v", err)
  6172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6173. return
  6174. }
  6175. return res
  6176. }
  6177. return res
  6178. }
  6179. func Checkgd3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Resultgd3101) {
  6180. var res Resultgd3101
  6181. adminUser := c.GetAdminUserInfo()
  6182. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6183. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6185. //record_time := c.GetString("record_time")
  6186. //trig_scen := c.GetString("trig_scen")
  6187. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6188. timeLayout := "2006-01-02"
  6189. loc, _ := time.LoadLocation("Local")
  6190. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6191. if err != nil {
  6192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6193. return res
  6194. }
  6195. recordDateTime := theTime.Unix()
  6196. var patientPrescription models.HisPrescriptionInfo
  6197. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6198. //if patientPrescription.ID == 0 {
  6199. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6200. //}
  6201. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6202. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6203. //
  6204. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6205. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6206. var pp models.PublicParams
  6207. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6208. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6209. pp.FixmedinsName = miConfig.OrgName
  6210. pp.FixmedinsCode = miConfig.Code
  6211. pp.RequestUrl = miConfig.Url
  6212. pp.Cainfo = miConfig.Cainfo
  6213. pp.SecretKey = miConfig.SecretKey
  6214. pp.AccessKey = miConfig.AccessKey
  6215. pp.OpterName = roles.UserName
  6216. var config []*models.HisXtDiagnoseConfig
  6217. for _, item := range diagnosis_ids {
  6218. id, _ := strconv.ParseInt(item, 10, 64)
  6219. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6220. config = append(config, &diagnosisConfig)
  6221. }
  6222. var pd models.PatientDtos
  6223. pd.PatnID = his.PsnNo
  6224. pd.PatnName = his.Name
  6225. pd.Gend = his.Gend
  6226. pd.Brdy = psn_info.Brdy
  6227. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6228. pd.CurrMdtrtID = his.Number
  6229. var fed models.FsiEncounterDtos
  6230. fed.MdtrtID = his.Number
  6231. fed.MedinsID = miConfig.Code
  6232. fed.MedinsName = miConfig.OrgName
  6233. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6234. fed.MedMdtrtType = "1"
  6235. fed.MedinsType = "1"
  6236. fed.MedinsLv = "11"
  6237. tm := time.Unix(his.RecordDate, 0)
  6238. s_tm := tm.Format("2006-01-02 15:04:05")
  6239. fed.AdmDate = s_tm
  6240. fed.DscgDate = s_tm
  6241. fed.DscgMainDiseCodg = config[0].CountryCode
  6242. fed.DscgMainDiseName = config[0].CountryContentName
  6243. //诊断信息
  6244. var fdds []*models.FsiDiagnoseDtos
  6245. for index, item := range config {
  6246. if index == 0 {
  6247. var fdd models.FsiDiagnoseDtos
  6248. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6249. fdd.InoutDiseType = "1"
  6250. fdd.MaindiseFlag = "1"
  6251. fdd.DiseDate = s_tm
  6252. fdd.DiasSrtNo = "1"
  6253. fdd.DiseName = item.CountryContentName
  6254. fdd.DiseCodg = item.CountryCode
  6255. fdds = append(fdds, &fdd)
  6256. } else {
  6257. var fdd models.FsiDiagnoseDtos
  6258. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6259. fdd.InoutDiseType = "1"
  6260. fdd.MaindiseFlag = "1"
  6261. fdd.DiseDate = s_tm
  6262. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6263. fdd.DiseName = item.CountryContentName
  6264. fdd.DiseCodg = item.CountryCode
  6265. fdds = append(fdds, &fdd)
  6266. }
  6267. }
  6268. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6269. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6270. fed.AdmDeptName = department.Name
  6271. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6272. fed.DscgDeptName = department.Name
  6273. fed.MedMdtrtType = "1"
  6274. fed.MedType = "11"
  6275. //if his.Insutype == "390" {
  6276. // fed.MedType = "1402"
  6277. //} else {
  6278. // fed.MedType = "9933"
  6279. //}
  6280. var orders []*models.FsiOrderDtos
  6281. if trig_scen == "2" {
  6282. //处方医嘱信息
  6283. for _, item := range prescriptions {
  6284. for _, subItem := range item.HisDoctorAdviceInfo {
  6285. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6286. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6287. var order models.FsiOrderDtos
  6288. order.RxID = strconv.FormatInt(item.ID, 10)
  6289. order.Rxno = strconv.FormatInt(item.ID, 10)
  6290. order.LongDrordFlag = "0"
  6291. order.HilistType = "1"
  6292. order.ChrgType = "1"
  6293. order.DrordBhvr = "0"
  6294. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6295. order.HosplistName = subItem.BaseDrugLib.DrugName
  6296. order.HilistLv = "1"
  6297. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6298. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6299. order.HosplistName = subItem.BaseDrugLib.DrugName
  6300. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6301. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6302. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6303. order.OwnpayAmt = ""
  6304. order.SelfpayAmt = ""
  6305. order.Spec = spec
  6306. order.SpecUnt = subItem.PrescribingNumberUnit
  6307. order.DrordBegnDate = s_tm
  6308. order.DrordStopDate = ""
  6309. order.DrordDrCodg = doctor_info.DoctorNumber
  6310. order.DrordDeptName = department.Name
  6311. order.DrordDeptCodg = department.Number
  6312. order.DrordDrName = doctor_info.UserName
  6313. order.DrordDrProfttl = "234"
  6314. order.CurrDrordFlag = "1"
  6315. orders = append(orders, &order)
  6316. }
  6317. }
  6318. for _, subItem := range item.HisPrescriptionProject {
  6319. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6320. var order models.FsiOrderDtos
  6321. order.RxID = strconv.FormatInt(item.ID, 10)
  6322. order.Rxno = strconv.FormatInt(item.ID, 10)
  6323. order.LongDrordFlag = "0"
  6324. order.HilistType = "1"
  6325. order.ChrgType = "1"
  6326. order.DrordBhvr = "0"
  6327. order.HilistCode = subItem.HisProject.MedicalCode
  6328. order.HosplistName = subItem.HisProject.ProjectName
  6329. order.HilistLv = "1"
  6330. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6331. order.HosplistCode = subItem.HisProject.MedicalCode
  6332. order.HosplistName = subItem.HisProject.ProjectName
  6333. order.Cnt = subItem.Count
  6334. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6335. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6336. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6337. order.OwnpayAmt = ""
  6338. order.SelfpayAmt = ""
  6339. order.Spec = subItem.Unit
  6340. order.SpecUnt = subItem.Unit
  6341. order.DrordBegnDate = s_tm
  6342. order.DrordStopDate = ""
  6343. order.DrordDrCodg = doctor_info.DoctorNumber
  6344. order.DrordDeptName = department.Name
  6345. order.DrordDeptCodg = department.Number
  6346. order.DrordDrName = doctor_info.UserName
  6347. order.DrordDrProfttl = "234"
  6348. order.CurrDrordFlag = "1"
  6349. orders = append(orders, &order)
  6350. }
  6351. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6352. var order models.FsiOrderDtos
  6353. order.RxID = strconv.FormatInt(item.ID, 10)
  6354. order.Rxno = strconv.FormatInt(item.ID, 10)
  6355. order.LongDrordFlag = "0"
  6356. order.HilistType = "1"
  6357. order.ChrgType = "1"
  6358. order.DrordBhvr = "0"
  6359. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6360. order.HosplistName = subItem.GoodInfo.GoodName
  6361. order.HilistLv = "1"
  6362. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6363. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6364. order.HosplistName = subItem.GoodInfo.GoodName
  6365. order.Cnt = subItem.Count
  6366. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6367. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6368. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6369. order.OwnpayAmt = ""
  6370. order.SelfpayAmt = ""
  6371. order.Spec = subItem.GoodInfo.SpecificationName
  6372. order.SpecUnt = subItem.Unit
  6373. order.DrordBegnDate = s_tm
  6374. order.DrordStopDate = ""
  6375. order.DrordDrCodg = doctor_info.DoctorNumber
  6376. order.DrordDeptName = department.Name
  6377. order.DrordDeptCodg = department.Number
  6378. order.DrordDrName = doctor_info.UserName
  6379. order.DrordDrProfttl = "234"
  6380. order.CurrDrordFlag = "1"
  6381. orders = append(orders, &order)
  6382. }
  6383. }
  6384. }
  6385. //处方医嘱信息
  6386. }
  6387. fed.MatnStas = "0"
  6388. fed.MedfeeSumamt = "0"
  6389. fed.OwnpayAmt = "0"
  6390. fed.SelfpayAmt = "0"
  6391. fed.AcctPayamt = "0"
  6392. fed.MaAmt = "0"
  6393. fed.HifpPayamt = "0"
  6394. fed.SetlTotlnum = "1"
  6395. fed.Insutype = his.Insutype
  6396. fed.ReimFlag = "0"
  6397. fed.OutSetlFlag = "0"
  6398. var fopd []*models.FsiOperationDtosData
  6399. data := make(map[string]interface{})
  6400. data["fed"] = fed
  6401. data["fdd"] = fdds
  6402. data["fod"] = orders
  6403. data["pd"] = pd
  6404. data["pp"] = pp
  6405. data["fopd"] = fopd
  6406. data["trig_scen"] = trig_scen
  6407. fmt.Println(data)
  6408. fmt.Println(fed)
  6409. fmt.Println(fdds)
  6410. fmt.Println(orders)
  6411. fmt.Println(pd)
  6412. fmt.Println(pp)
  6413. fmt.Println(fopd)
  6414. client := &http.Client{}
  6415. bytesData, _ := json.Marshal(data)
  6416. var req *http.Request
  6417. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6418. if miConfig.MdtrtareaAdmvs == "320921" {
  6419. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6420. } else {
  6421. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6422. }
  6423. resp, _ := client.Do(req)
  6424. defer resp.Body.Close()
  6425. body, ioErr := ioutil.ReadAll(resp.Body)
  6426. if ioErr != nil {
  6427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. return res
  6430. }
  6431. var respJSON map[string]interface{}
  6432. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. return res
  6436. }
  6437. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6438. fmt.Println(respJSON)
  6439. result, _ := json.Marshal(respJSON)
  6440. fmt.Println(result)
  6441. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6442. utils.ErrorLog("解析失败:%v", err)
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. return res
  6445. }
  6446. return res
  6447. } else {
  6448. //if miConfig.MdtrtareaAdmvs == "441202" {
  6449. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6450. saveLog(output, input, "3101", "事前")
  6451. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6452. utils.ErrorLog("解析失败:%v", err)
  6453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6454. return
  6455. }
  6456. return res
  6457. //}
  6458. }
  6459. }
  6460. 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) {
  6461. adminUser := c.GetAdminUserInfo()
  6462. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6463. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6464. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6465. //record_time := c.GetString("record_time")
  6466. //trig_scen := c.GetString("trig_scen")
  6467. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6468. timeLayout := "2006-01-02"
  6469. loc, _ := time.LoadLocation("Local")
  6470. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6471. if err != nil {
  6472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6473. return res
  6474. }
  6475. recordDateTime := theTime.Unix()
  6476. var patientPrescription models.HisPrescriptionInfo
  6477. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6478. if patientPrescription.ID == 0 {
  6479. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6480. }
  6481. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6482. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6483. //
  6484. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6485. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6486. var pp models.PublicParams
  6487. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6488. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6489. pp.FixmedinsName = miConfig.OrgName
  6490. pp.FixmedinsCode = miConfig.Code
  6491. pp.RequestUrl = miConfig.Url
  6492. pp.Cainfo = miConfig.Cainfo
  6493. pp.SecretKey = miConfig.SecretKey
  6494. pp.AccessKey = miConfig.AccessKey
  6495. pp.OpterName = roles.UserName
  6496. var config []*models.HisXtDiagnoseConfig
  6497. for _, item := range diagnosis_ids {
  6498. id, _ := strconv.ParseInt(item, 10, 64)
  6499. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6500. config = append(config, &diagnosisConfig)
  6501. }
  6502. var pd models.PatientDtos
  6503. pd.PatnID = his.PsnNo
  6504. pd.PatnName = his.Name
  6505. pd.Gend = his.Gend
  6506. pd.Brdy = psn_info.Brdy
  6507. pd.Poolarea = his.InsuplcAdmdvs
  6508. pd.CurrMdtrtID = his.Number
  6509. var fed models.FsiEncounterDtos
  6510. fed.MdtrtID = his.Number
  6511. fed.MedinsID = miConfig.Code
  6512. fed.MedinsName = miConfig.OrgName
  6513. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6514. fed.MedMdtrtType = "1"
  6515. fed.MedinsType = "1"
  6516. fed.MedinsLv = "11"
  6517. tm := time.Unix(his.RecordDate, 0)
  6518. s_tm := tm.Format("2006-01-02 15:04:05")
  6519. fed.AdmDate = s_tm
  6520. fed.DscgDate = s_tm
  6521. fed.DscgMainDiseCodg = config[0].CountryCode
  6522. fed.DscgMainDiseName = config[0].CountryContentName
  6523. //诊断信息
  6524. var fdds []*models.FsiDiagnoseDtos
  6525. for index, item := range config {
  6526. if index == 0 {
  6527. var fdd models.FsiDiagnoseDtos
  6528. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6529. fdd.InoutDiseType = "1"
  6530. fdd.MaindiseFlag = "1"
  6531. fdd.DiseDate = s_tm
  6532. fdd.DiasSrtNo = "1"
  6533. fdd.DiseName = item.CountryContentName
  6534. fdd.DiseCodg = item.CountryCode
  6535. fdds = append(fdds, &fdd)
  6536. } else {
  6537. var fdd models.FsiDiagnoseDtos
  6538. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6539. fdd.InoutDiseType = "1"
  6540. fdd.MaindiseFlag = "1"
  6541. fdd.DiseDate = s_tm
  6542. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6543. fdd.DiseName = item.CountryContentName
  6544. fdd.DiseCodg = item.CountryCode
  6545. fdds = append(fdds, &fdd)
  6546. }
  6547. }
  6548. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6549. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6550. fed.AdmDeptName = department.Name
  6551. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6552. fed.DscgDeptName = department.Name
  6553. fed.MedMdtrtType = "1"
  6554. fed.MedType = "11"
  6555. //if his.Insutype == "390" {
  6556. // fed.MedType = "1402"
  6557. //} else {
  6558. // fed.MedType = "9933"
  6559. //}
  6560. var orders []*models.FsiOrderDtos
  6561. if trig_scen == "2" {
  6562. //处方医嘱信息
  6563. for _, item := range prescriptions {
  6564. for _, subItem := range item.HisDoctorAdviceInfo {
  6565. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6566. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6567. var order models.FsiOrderDtos
  6568. order.RxID = strconv.FormatInt(item.ID, 10)
  6569. order.Rxno = strconv.FormatInt(item.ID, 10)
  6570. order.LongDrordFlag = "0"
  6571. order.HilistType = "1"
  6572. order.ChrgType = "1"
  6573. order.DrordBhvr = "0"
  6574. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6575. order.HosplistName = subItem.BaseDrugLib.DrugName
  6576. order.HilistLv = "1"
  6577. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6578. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6579. order.HosplistName = subItem.BaseDrugLib.DrugName
  6580. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6581. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6582. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6583. order.OwnpayAmt = ""
  6584. order.SelfpayAmt = ""
  6585. order.Spec = spec
  6586. order.SpecUnt = subItem.PrescribingNumberUnit
  6587. order.DrordBegnDate = s_tm
  6588. order.DrordStopDate = ""
  6589. order.DrordDrCodg = doctor_info.DoctorNumber
  6590. order.DrordDeptName = department.Name
  6591. order.DrordDeptCodg = department.Number
  6592. order.DrordDrName = doctor_info.UserName
  6593. order.DrordDrProfttl = "234"
  6594. order.CurrDrordFlag = "1"
  6595. orders = append(orders, &order)
  6596. }
  6597. }
  6598. for _, subItem := range item.HisPrescriptionProject {
  6599. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6600. var order models.FsiOrderDtos
  6601. order.RxID = strconv.FormatInt(item.ID, 10)
  6602. order.Rxno = strconv.FormatInt(item.ID, 10)
  6603. order.LongDrordFlag = "0"
  6604. order.HilistType = "1"
  6605. order.ChrgType = "1"
  6606. order.DrordBhvr = "0"
  6607. order.HilistCode = subItem.HisProject.MedicalCode
  6608. order.HosplistName = subItem.HisProject.ProjectName
  6609. order.HilistLv = "1"
  6610. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6611. order.HosplistCode = subItem.HisProject.MedicalCode
  6612. order.HosplistName = subItem.HisProject.ProjectName
  6613. order.Cnt = subItem.Count
  6614. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6615. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6616. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6617. order.OwnpayAmt = ""
  6618. order.SelfpayAmt = ""
  6619. order.Spec = subItem.Unit
  6620. order.SpecUnt = subItem.Unit
  6621. order.DrordBegnDate = s_tm
  6622. order.DrordStopDate = ""
  6623. order.DrordDrCodg = doctor_info.DoctorNumber
  6624. order.DrordDeptName = department.Name
  6625. order.DrordDeptCodg = department.Number
  6626. order.DrordDrName = doctor_info.UserName
  6627. order.DrordDrProfttl = "234"
  6628. order.CurrDrordFlag = "1"
  6629. orders = append(orders, &order)
  6630. }
  6631. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6632. var order models.FsiOrderDtos
  6633. order.RxID = strconv.FormatInt(item.ID, 10)
  6634. order.Rxno = strconv.FormatInt(item.ID, 10)
  6635. order.LongDrordFlag = "0"
  6636. order.HilistType = "1"
  6637. order.ChrgType = "1"
  6638. order.DrordBhvr = "0"
  6639. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6640. order.HosplistName = subItem.GoodInfo.GoodName
  6641. order.HilistLv = "1"
  6642. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6643. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6644. order.HosplistName = subItem.GoodInfo.GoodName
  6645. order.Cnt = subItem.Count
  6646. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6647. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6648. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6649. order.OwnpayAmt = ""
  6650. order.SelfpayAmt = ""
  6651. order.Spec = subItem.GoodInfo.SpecificationName
  6652. order.SpecUnt = subItem.Unit
  6653. order.DrordBegnDate = s_tm
  6654. order.DrordStopDate = ""
  6655. order.DrordDrCodg = doctor_info.DoctorNumber
  6656. order.DrordDeptName = department.Name
  6657. order.DrordDeptCodg = department.Number
  6658. order.DrordDrName = doctor_info.UserName
  6659. order.DrordDrProfttl = "234"
  6660. order.CurrDrordFlag = "1"
  6661. orders = append(orders, &order)
  6662. }
  6663. }
  6664. }
  6665. //处方医嘱信息
  6666. }
  6667. fed.MatnStas = "0"
  6668. fed.MedfeeSumamt = "0"
  6669. fed.OwnpayAmt = "0"
  6670. fed.SelfpayAmt = "0"
  6671. fed.AcctPayamt = "0"
  6672. fed.MaAmt = "0"
  6673. fed.HifpPayamt = "0"
  6674. fed.SetlTotlnum = "1"
  6675. fed.Insutype = his.Insutype
  6676. fed.ReimFlag = "0"
  6677. fed.OutSetlFlag = "0"
  6678. var fopd []*models.FsiOperationDtosData
  6679. data := make(map[string]interface{})
  6680. data["fed"] = fed
  6681. data["fdd"] = fdds
  6682. data["fod"] = orders
  6683. data["pd"] = pd
  6684. data["pp"] = pp
  6685. data["fopd"] = fopd
  6686. data["trig_scen"] = trig_scen
  6687. fmt.Println(data)
  6688. fmt.Println(fed)
  6689. fmt.Println(fdds)
  6690. fmt.Println(orders)
  6691. fmt.Println(pd)
  6692. fmt.Println(pp)
  6693. fmt.Println(fopd)
  6694. client := &http.Client{}
  6695. bytesData, _ := json.Marshal(data)
  6696. var req *http.Request
  6697. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6698. if miConfig.MdtrtareaAdmvs == "320921" {
  6699. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6700. } else {
  6701. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6702. }
  6703. resp, _ := client.Do(req)
  6704. defer resp.Body.Close()
  6705. body, ioErr := ioutil.ReadAll(resp.Body)
  6706. if ioErr != nil {
  6707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6709. return res
  6710. }
  6711. var respJSON map[string]interface{}
  6712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6715. return res
  6716. }
  6717. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6718. fmt.Println(respJSON)
  6719. result, _ := json.Marshal(respJSON)
  6720. fmt.Println(result)
  6721. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6722. utils.ErrorLog("解析失败:%v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. return res
  6725. }
  6726. return res
  6727. } else {
  6728. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6729. saveLog(output, input, "3101", "事前")
  6730. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6731. utils.ErrorLog("解析失败:%v", err)
  6732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6733. return
  6734. }
  6735. return res
  6736. }
  6737. return res
  6738. }
  6739. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6740. ////patient_id, _ := c.GetInt64("patient_id")
  6741. //order_id, _ := c.GetInt64("order_id")
  6742. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6743. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6744. //trig_scen := c.GetString("trig_scen")
  6745. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6746. utils.ErrorLog("解析失败:%v", psn_info)
  6747. adminUser := c.GetAdminUserInfo()
  6748. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6749. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6751. record_time := c.GetString("record_time")
  6752. order, _ := service.GetHisOrderByID(order_id)
  6753. timeLayout := "2006-01-02"
  6754. loc, _ := time.LoadLocation("Local")
  6755. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6756. if err != nil {
  6757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6758. return
  6759. }
  6760. recordDateTime := theTime.Unix()
  6761. var patientPrescription models.HisPrescriptionInfo
  6762. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6763. if patientPrescription.ID == 0 {
  6764. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6765. }
  6766. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6767. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6768. //
  6769. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6770. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6771. var pp models.PublicParams
  6772. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6773. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6774. pp.FixmedinsName = miConfig.OrgName
  6775. pp.FixmedinsCode = miConfig.Code
  6776. pp.RequestUrl = miConfig.Url
  6777. pp.Cainfo = miConfig.Cainfo
  6778. pp.SecretKey = miConfig.SecretKey
  6779. pp.AccessKey = miConfig.AccessKey
  6780. pp.OpterName = roles.UserName
  6781. var config []*models.HisXtDiagnoseConfig
  6782. for _, item := range diagnosis_ids {
  6783. id, _ := strconv.ParseInt(item, 10, 64)
  6784. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6785. config = append(config, &diagnosisConfig)
  6786. }
  6787. var pd models.PatientDtos
  6788. pd.PatnID = his.PsnNo
  6789. pd.PatnName = his.Name
  6790. pd.Gend = his.Gend
  6791. pd.Brdy = psn_info.Brdy
  6792. pd.Poolarea = his.InsuplcAdmdvs
  6793. pd.CurrMdtrtID = his.Number
  6794. var fed models.FsiEncounterDtos
  6795. fed.MdtrtID = his.Number
  6796. fed.MedinsID = miConfig.Code
  6797. fed.MedinsName = miConfig.OrgName
  6798. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6799. fed.MedMdtrtType = "1"
  6800. fed.MedinsType = "1"
  6801. fed.MedinsLv = "11"
  6802. tm := time.Unix(his.RecordDate, 0)
  6803. s_tm := tm.Format("2006-01-02 15:04:05")
  6804. fed.AdmDate = s_tm
  6805. fed.DscgDate = s_tm
  6806. fed.DscgMainDiseCodg = config[0].CountryCode
  6807. fed.DscgMainDiseName = config[0].CountryContentName
  6808. //诊断信息
  6809. var fdds []*models.FsiDiagnoseDtos
  6810. for index, item := range config {
  6811. if index == 0 {
  6812. var fdd models.FsiDiagnoseDtos
  6813. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6814. fdd.InoutDiseType = "1"
  6815. fdd.MaindiseFlag = "1"
  6816. fdd.DiseDate = s_tm
  6817. fdd.DiasSrtNo = "1"
  6818. fdd.DiseName = item.CountryContentName
  6819. fdd.DiseCodg = item.CountryCode
  6820. fdds = append(fdds, &fdd)
  6821. } else {
  6822. var fdd models.FsiDiagnoseDtos
  6823. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6824. fdd.InoutDiseType = "1"
  6825. fdd.MaindiseFlag = "1"
  6826. fdd.DiseDate = s_tm
  6827. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6828. fdd.DiseName = item.CountryContentName
  6829. fdd.DiseCodg = item.CountryCode
  6830. fdds = append(fdds, &fdd)
  6831. }
  6832. }
  6833. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6834. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6835. fed.AdmDeptName = department.Name
  6836. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6837. fed.DscgDeptName = department.Name
  6838. fed.MedType = order.MedType
  6839. //处方医嘱信息
  6840. var orders []*models.FsiOrderDtos
  6841. //for _, item := range prescriptions {
  6842. // for _, subItem := range item.HisDoctorAdviceInfo {
  6843. // var order models.FsiOrderDtos
  6844. // order.RxID = strconv.FormatInt(item.ID, 10)
  6845. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6846. // order.LongDrordFlag = "0"
  6847. // order.HilistType = "1"
  6848. // order.ChrgType = "1"
  6849. // order.DrordBhvr = "-"
  6850. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6851. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6852. // order.HilistLv = "1"
  6853. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6854. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6855. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6856. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6857. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6858. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6859. // order.OwnpayAmt = ""
  6860. // order.SelfpayAmt = ""
  6861. // order.Spec = ""
  6862. // order.SpecUnt = ""
  6863. // order.DrordBegnDate = s_tm
  6864. // order.DrordStopDate = ""
  6865. // order.DrordDrCodg = "1"
  6866. // order.DrordDeptName = department.Name
  6867. // order.DrordDrCodg = "1"
  6868. // order.DrordDrName = doctor_info.UserName
  6869. // order.DrordDrProfttl = ""
  6870. // order.CurrDrordFlag = "1"
  6871. // orders = append(orders, &order)
  6872. // }
  6873. // for _, subItem := range item.HisPrescriptionProject {
  6874. // if subItem.Type == 2 {
  6875. // var order models.FsiOrderDtos
  6876. // order.RxID = strconv.FormatInt(item.ID, 10)
  6877. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6878. // order.LongDrordFlag = "0"
  6879. // order.HilistType = "1"
  6880. // order.ChrgType = "1"
  6881. // order.DrordBhvr = "-"
  6882. // order.HilistCode = subItem.HisProject.MedicalCode
  6883. // order.HosplistName = subItem.HisProject.ProjectName
  6884. // order.HilistLv = "1"
  6885. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6886. // order.HosplistCode = subItem.HisProject.MedicalCode
  6887. // order.HosplistName = subItem.HisProject.ProjectName
  6888. // order.Cnt = subItem.Count
  6889. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6890. //
  6891. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6892. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6893. // order.OwnpayAmt = ""
  6894. // order.SelfpayAmt = ""
  6895. // order.Spec = ""
  6896. // order.SpecUnt = ""
  6897. // order.DrordBegnDate = s_tm
  6898. // order.DrordStopDate = ""
  6899. // order.DrordDrCodg = "1"
  6900. // order.DrordDeptName = department.Name
  6901. // order.DrordDrCodg = "1"
  6902. // order.DrordDrName = doctor_info.UserName
  6903. // order.DrordDrProfttl = ""
  6904. // order.CurrDrordFlag = "1"
  6905. // orders = append(orders, &order)
  6906. //
  6907. // }
  6908. // if subItem.Type == 3 {
  6909. //
  6910. // var order models.FsiOrderDtos
  6911. // order.RxID = strconv.FormatInt(item.ID, 10)
  6912. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6913. // order.LongDrordFlag = "0"
  6914. // order.HilistType = "1"
  6915. // order.ChrgType = "1"
  6916. // order.DrordBhvr = "-"
  6917. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6918. // order.HosplistName = subItem.GoodInfo.GoodName
  6919. // order.HilistLv = "1"
  6920. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6921. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6922. // order.HosplistName = subItem.GoodInfo.GoodName
  6923. // order.Cnt = subItem.Count
  6924. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6925. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6926. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6927. // order.OwnpayAmt = ""
  6928. // order.SelfpayAmt = ""
  6929. // order.Spec = ""
  6930. // order.SpecUnt = ""
  6931. // order.DrordBegnDate = s_tm
  6932. // order.DrordStopDate = ""
  6933. // order.DrordDrCodg = "1"
  6934. // order.DrordDeptName = department.Name
  6935. // order.DrordDrCodg = "1"
  6936. // order.DrordDrName = doctor_info.UserName
  6937. // order.DrordDrProfttl = ""
  6938. // order.CurrDrordFlag = "1"
  6939. // orders = append(orders, &order)
  6940. //
  6941. // }
  6942. // }
  6943. //}
  6944. for _, item := range prescriptions {
  6945. for _, subItem := range item.HisDoctorAdviceInfo {
  6946. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6947. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6948. var order models.FsiOrderDtos
  6949. order.RxID = strconv.FormatInt(item.ID, 10)
  6950. order.Rxno = strconv.FormatInt(item.ID, 10)
  6951. order.LongDrordFlag = "0"
  6952. order.HilistType = "1"
  6953. order.ChrgType = "1"
  6954. order.DrordBhvr = "0"
  6955. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6956. order.HosplistName = subItem.BaseDrugLib.DrugName
  6957. order.HilistLv = "1"
  6958. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6959. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6960. order.HosplistName = subItem.BaseDrugLib.DrugName
  6961. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6962. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6963. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6964. order.OwnpayAmt = ""
  6965. order.SelfpayAmt = ""
  6966. order.Spec = spec
  6967. order.SpecUnt = subItem.PrescribingNumberUnit
  6968. order.DrordBegnDate = s_tm
  6969. order.DrordStopDate = ""
  6970. order.DrordDrCodg = doctor_info.DoctorNumber
  6971. order.DrordDeptName = department.Name
  6972. order.DrordDeptCodg = department.Number
  6973. order.DrordDrName = doctor_info.UserName
  6974. order.DrordDrProfttl = "234"
  6975. order.CurrDrordFlag = "1"
  6976. orders = append(orders, &order)
  6977. }
  6978. }
  6979. for _, subItem := range item.HisPrescriptionProject {
  6980. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6981. var order models.FsiOrderDtos
  6982. order.RxID = strconv.FormatInt(item.ID, 10)
  6983. order.Rxno = strconv.FormatInt(item.ID, 10)
  6984. order.LongDrordFlag = "0"
  6985. order.HilistType = "1"
  6986. order.ChrgType = "1"
  6987. order.DrordBhvr = "0"
  6988. order.HilistCode = subItem.HisProject.MedicalCode
  6989. order.HosplistName = subItem.HisProject.ProjectName
  6990. order.HilistLv = "1"
  6991. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6992. order.HosplistCode = subItem.HisProject.MedicalCode
  6993. order.HosplistName = subItem.HisProject.ProjectName
  6994. order.Cnt = subItem.Count
  6995. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6996. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6997. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6998. order.OwnpayAmt = ""
  6999. order.SelfpayAmt = ""
  7000. order.Spec = subItem.Unit
  7001. order.SpecUnt = subItem.Unit
  7002. order.DrordBegnDate = s_tm
  7003. order.DrordStopDate = ""
  7004. order.DrordDrCodg = doctor_info.DoctorNumber
  7005. order.DrordDeptName = department.Name
  7006. order.DrordDeptCodg = department.Number
  7007. order.DrordDrName = doctor_info.UserName
  7008. order.DrordDrProfttl = "234"
  7009. order.CurrDrordFlag = "1"
  7010. orders = append(orders, &order)
  7011. }
  7012. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7013. var order models.FsiOrderDtos
  7014. order.RxID = strconv.FormatInt(item.ID, 10)
  7015. order.Rxno = strconv.FormatInt(item.ID, 10)
  7016. order.LongDrordFlag = "0"
  7017. order.HilistType = "1"
  7018. order.ChrgType = "1"
  7019. order.DrordBhvr = "0"
  7020. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7021. order.HosplistName = subItem.GoodInfo.GoodName
  7022. order.HilistLv = "1"
  7023. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7024. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7025. order.HosplistName = subItem.GoodInfo.GoodName
  7026. order.Cnt = subItem.Count
  7027. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7028. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7029. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7030. order.OwnpayAmt = ""
  7031. order.SelfpayAmt = ""
  7032. order.Spec = subItem.GoodInfo.SpecificationName
  7033. order.SpecUnt = subItem.Unit
  7034. order.DrordBegnDate = s_tm
  7035. order.DrordStopDate = ""
  7036. order.DrordDrCodg = doctor_info.DoctorNumber
  7037. order.DrordDeptName = department.Name
  7038. order.DrordDeptCodg = department.Number
  7039. order.DrordDrName = doctor_info.UserName
  7040. order.DrordDrProfttl = "234"
  7041. order.CurrDrordFlag = "1"
  7042. orders = append(orders, &order)
  7043. }
  7044. }
  7045. }
  7046. //处方医嘱信息
  7047. fed.MatnStas = "0"
  7048. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7049. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7050. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7051. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7052. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7053. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7054. fed.SetlTotlnum = "1"
  7055. fed.Insutype = his.Insutype
  7056. fed.ReimFlag = "0"
  7057. fed.OutSetlFlag = "0"
  7058. var fopd []*models.FsiOperationDtosData
  7059. data := make(map[string]interface{})
  7060. data["fed"] = fed
  7061. data["fdd"] = fdds
  7062. data["fod"] = orders
  7063. data["pd"] = pd
  7064. data["pp"] = pp
  7065. data["fopd"] = fopd
  7066. data["trig_scen"] = trig_scen
  7067. client := &http.Client{}
  7068. bytesData, _ := json.Marshal(data)
  7069. var req *http.Request
  7070. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7071. if miConfig.MdtrtareaAdmvs == "320921" {
  7072. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7073. } else {
  7074. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7075. }
  7076. resp, _ := client.Do(req)
  7077. defer resp.Body.Close()
  7078. body, ioErr := ioutil.ReadAll(resp.Body)
  7079. if ioErr != nil {
  7080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. return res
  7083. }
  7084. var respJSON map[string]interface{}
  7085. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7088. return res
  7089. }
  7090. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7091. result, _ := json.Marshal(respJSON)
  7092. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7093. utils.ErrorLog("解析失败:%v", err)
  7094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7095. return res
  7096. }
  7097. return res
  7098. } else {
  7099. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7100. saveLog(output, input, "3102", "事中")
  7101. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7102. utils.ErrorLog("解析失败:%v", err)
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. return
  7105. }
  7106. return res
  7107. }
  7108. return res
  7109. }
  7110. func (c *HisApiController) Check() {
  7111. psn_no := c.GetString("psn_no")
  7112. in := c.GetString("in")
  7113. mt := c.GetString("mt")
  7114. baseParams := models.BaseParams{
  7115. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  7116. FixmedinsCode: "H15049901371",
  7117. InsuplcAdmdvs: "150499",
  7118. MdtrtareaAdmvs: "150499",
  7119. OrgName: "赤峰费森血液透析中心",
  7120. Doctor: "1111",
  7121. }
  7122. service.Gdyb2001(baseParams, psn_no, in, mt)
  7123. }
  7124. func (c *HisApiController) GetPsnNcdsInfo() {
  7125. admin_user_id, _ := c.GetInt64("admin_user_id")
  7126. patient_id, _ := c.GetInt64("patient_id")
  7127. //id, _ := c.GetInt64("id")
  7128. adminUser := c.GetAdminUserInfo()
  7129. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7130. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7131. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7132. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7133. //psn_record, _ := service.GetP(id)
  7134. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7135. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  7136. //
  7137. //if psn_record.ID == 0 {
  7138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7139. // return
  7140. //}
  7141. var res Result5301
  7142. var res10265 Result5301For10265
  7143. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7144. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7145. var api string
  7146. if miConfig.MdtrtareaAdmvs == "320921" {
  7147. 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 +
  7148. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7149. } else {
  7150. 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 +
  7151. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7152. }
  7153. resp, requestErr := http.Get(api)
  7154. if requestErr != nil {
  7155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7156. return
  7157. }
  7158. body, ioErr := ioutil.ReadAll(resp.Body)
  7159. if ioErr != nil {
  7160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. return
  7163. }
  7164. var respJSON map[string]interface{}
  7165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7168. return
  7169. }
  7170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7171. result, _ := json.Marshal(respJSON)
  7172. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7173. utils.ErrorLog("解析失败:%v", err)
  7174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7175. return
  7176. }
  7177. res.ErrMsg = res10265.ErrMsg
  7178. res.Output = res10265.Output
  7179. res.InfRefmsgid = res10265.InfRefmsgid
  7180. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7181. res.Infcode = infocode
  7182. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7183. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7184. var api string
  7185. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7187. resp, requestErr := http.Get(api)
  7188. if requestErr != nil {
  7189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7190. return
  7191. }
  7192. body, ioErr := ioutil.ReadAll(resp.Body)
  7193. if ioErr != nil {
  7194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. return
  7197. }
  7198. var respJSON map[string]interface{}
  7199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7202. return
  7203. }
  7204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7205. if status == "0" {
  7206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7207. c.ServeSuccessJSON(map[string]interface{}{
  7208. "failed_code": -10,
  7209. "msg": err_msg,
  7210. })
  7211. return
  7212. }
  7213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7214. result, _ := json.Marshal(respJSON)
  7215. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7216. utils.ErrorLog("解析失败:%v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. return
  7219. }
  7220. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7221. p, _ := service.GetHisPatientById(patient_id)
  7222. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7223. var dat map[string]interface{}
  7224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7225. fmt.Println(dat)
  7226. } else {
  7227. fmt.Println(err)
  7228. }
  7229. userJSONBytes, _ := json.Marshal(dat)
  7230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7231. utils.ErrorLog("解析失败:%v", err)
  7232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7233. return
  7234. }
  7235. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7236. p, _ := service.GetHisPatientById(patient_id)
  7237. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7238. var dat map[string]interface{}
  7239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7240. fmt.Println(dat)
  7241. } else {
  7242. fmt.Println(err)
  7243. }
  7244. userJSONBytes, _ := json.Marshal(dat)
  7245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7246. utils.ErrorLog("解析失败:%v", err)
  7247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7248. return
  7249. }
  7250. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7251. p, _ := service.GetHisPatientById(patient_id)
  7252. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7253. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7255. resp, requestErr := http.Get(api)
  7256. if requestErr != nil {
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. return
  7259. }
  7260. body, ioErr := ioutil.ReadAll(resp.Body)
  7261. if ioErr != nil {
  7262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7264. return
  7265. }
  7266. var respJSON map[string]interface{}
  7267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7270. return
  7271. }
  7272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7273. result, _ := json.Marshal(respJSON)
  7274. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7275. utils.ErrorLog("解析失败:%v", err)
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. return
  7278. }
  7279. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7280. p, _ := service.GetHisPatientById(patient_id)
  7281. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7282. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7283. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7284. resp, requestErr := http.Get(api)
  7285. if requestErr != nil {
  7286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7287. return
  7288. }
  7289. body, ioErr := ioutil.ReadAll(resp.Body)
  7290. if ioErr != nil {
  7291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7293. return
  7294. }
  7295. var respJSON map[string]interface{}
  7296. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7299. return
  7300. }
  7301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7302. result, _ := json.Marshal(respJSON)
  7303. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7304. utils.ErrorLog("解析失败:%v", err)
  7305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7306. return
  7307. }
  7308. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7309. p, _ := service.GetHisPatientById(patient_id)
  7310. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7311. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7312. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7313. resp, requestErr := http.Get(api)
  7314. if requestErr != nil {
  7315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7316. return
  7317. }
  7318. body, ioErr := ioutil.ReadAll(resp.Body)
  7319. if ioErr != nil {
  7320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7322. return
  7323. }
  7324. var respJSON map[string]interface{}
  7325. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7328. return
  7329. }
  7330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7331. result, _ := json.Marshal(respJSON)
  7332. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7333. utils.ErrorLog("解析失败:%v", err)
  7334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7335. return
  7336. }
  7337. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7338. p, _ := service.GetHisPatientById(patient_id)
  7339. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7340. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7342. resp, requestErr := http.Get(api)
  7343. if requestErr != nil {
  7344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7345. return
  7346. }
  7347. body, ioErr := ioutil.ReadAll(resp.Body)
  7348. if ioErr != nil {
  7349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7351. return
  7352. }
  7353. var respJSON map[string]interface{}
  7354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7357. return
  7358. }
  7359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7360. result, _ := json.Marshal(respJSON)
  7361. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7362. utils.ErrorLog("解析失败:%v", err)
  7363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7364. return
  7365. }
  7366. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7367. p, _ := service.GetHisPatientById(patient_id)
  7368. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7369. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7370. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7371. resp, requestErr := http.Get(api)
  7372. if requestErr != nil {
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. body, ioErr := ioutil.ReadAll(resp.Body)
  7377. if ioErr != nil {
  7378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. return
  7381. }
  7382. var respJSON map[string]interface{}
  7383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. return
  7387. }
  7388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7389. result, _ := json.Marshal(respJSON)
  7390. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7391. utils.ErrorLog("解析失败:%v", err)
  7392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. return
  7394. }
  7395. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7396. p, _ := service.GetHisPatientById(patient_id)
  7397. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7398. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7399. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7400. resp, requestErr := http.Get(api)
  7401. if requestErr != nil {
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. return
  7404. }
  7405. body, ioErr := ioutil.ReadAll(resp.Body)
  7406. if ioErr != nil {
  7407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. return
  7410. }
  7411. var respJSON map[string]interface{}
  7412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. return
  7416. }
  7417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7418. result, _ := json.Marshal(respJSON)
  7419. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7420. utils.ErrorLog("解析失败:%v", err)
  7421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7422. return
  7423. }
  7424. } else {
  7425. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7426. var dat map[string]interface{}
  7427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7428. fmt.Println(dat)
  7429. } else {
  7430. fmt.Println(err)
  7431. }
  7432. userJSONBytes, _ := json.Marshal(dat)
  7433. if miConfig.Code == "H15049901371" {
  7434. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7435. utils.ErrorLog("解析失败:%v", err)
  7436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7437. return
  7438. }
  7439. res.InfRefmsgid = res10265.InfRefmsgid
  7440. res.Output = res10265.Output
  7441. res.ErrMsg = res10265.ErrMsg
  7442. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7443. res.Infcode = infocode
  7444. } else {
  7445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7446. utils.ErrorLog("解析失败:%v", err)
  7447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7448. return
  7449. }
  7450. }
  7451. }
  7452. if res.Infcode == 0 {
  7453. c.ServeSuccessJSON(map[string]interface{}{
  7454. "result": res.Output.Result,
  7455. })
  7456. }
  7457. }
  7458. func (c *HisApiController) CheckInsutype() {
  7459. his_patient_id, _ := c.GetInt64("his_patient_id")
  7460. admin_user_id, _ := c.GetInt64("admin_user_id")
  7461. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7462. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7463. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7464. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7465. var dat map[string]interface{}
  7466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7467. fmt.Println(dat)
  7468. } else {
  7469. fmt.Println(err)
  7470. }
  7471. userJSONBytes, _ := json.Marshal(dat)
  7472. var res Result90100
  7473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7474. utils.ErrorLog("解析失败:%v", err)
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. return
  7477. }
  7478. if res.Infcode != 0 {
  7479. c.ServeSuccessJSON(map[string]interface{}{
  7480. "failed_code": -10,
  7481. "msg": res.ErrMsg,
  7482. })
  7483. return
  7484. } else {
  7485. fmt.Println(res)
  7486. }
  7487. }
  7488. func (c *HisApiController) CheckCardPWD() {
  7489. card_pwd := c.GetString("card_pwd")
  7490. his_patient_id, _ := c.GetInt64("his_patient_id")
  7491. admin_user_id, _ := c.GetInt64("admin_user_id")
  7492. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7493. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7494. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7495. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7496. bas := strings.Split(psn.CardInfo, "|")
  7497. basNumber := bas[2]
  7498. if psn.InsuplcAdmdvs[:4] == "4403" {
  7499. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7500. var dat map[string]interface{}
  7501. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7502. fmt.Println(dat)
  7503. } else {
  7504. fmt.Println(err)
  7505. }
  7506. userJSONBytes, _ := json.Marshal(dat)
  7507. var res Result90991
  7508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7509. utils.ErrorLog("解析失败:%v", err)
  7510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7511. return
  7512. }
  7513. if res.Infcode != 0 {
  7514. c.ServeSuccessJSON(map[string]interface{}{
  7515. "failed_code": -10,
  7516. "msg": res.ErrMsg,
  7517. })
  7518. return
  7519. } else {
  7520. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7521. var msg string
  7522. switch res.Output.Result.CardStat {
  7523. case "00":
  7524. msg = "未激活"
  7525. break
  7526. case "10":
  7527. msg = "激活"
  7528. break
  7529. case "20":
  7530. msg = "窗口挂失"
  7531. break
  7532. case "21":
  7533. msg = "电话挂失"
  7534. break
  7535. case "22":
  7536. msg = "单位网上申报挂失"
  7537. break
  7538. case "23":
  7539. msg = "保健办挂失"
  7540. break
  7541. case "24":
  7542. msg = "个人网上挂失"
  7543. break
  7544. case "25":
  7545. msg = "网上服务大厅挂失"
  7546. break
  7547. case "30":
  7548. msg = "注销"
  7549. break
  7550. case "40":
  7551. msg = "回收"
  7552. break
  7553. case "99":
  7554. msg = "制卡中(无效卡)"
  7555. break
  7556. }
  7557. c.ServeSuccessJSON(map[string]interface{}{
  7558. "failed_code": -10,
  7559. "msg": msg,
  7560. })
  7561. return
  7562. } else {
  7563. c.ServeSuccessJSON(map[string]interface{}{
  7564. "msg": "校验成功",
  7565. })
  7566. return
  7567. }
  7568. }
  7569. } else {
  7570. c.ServeSuccessJSON(map[string]interface{}{
  7571. "msg": "校验成功",
  7572. })
  7573. return
  7574. }
  7575. }
  7576. func (c *HisApiController) CheckCardPWDTwo() {
  7577. //card_pwd := c.GetString("card_pwd")
  7578. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7579. admin_user_id, _ := c.GetInt64("admin_user_id")
  7580. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7582. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7583. var dat map[string]interface{}
  7584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7585. fmt.Println(dat)
  7586. } else {
  7587. fmt.Println(err)
  7588. }
  7589. userJSONBytes, _ := json.Marshal(dat)
  7590. var res Result90991
  7591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7592. utils.ErrorLog("解析失败:%v", err)
  7593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7594. return
  7595. }
  7596. if res.Infcode != 0 {
  7597. c.ServeSuccessJSON(map[string]interface{}{
  7598. "failed_code": -10,
  7599. "msg": res.ErrMsg,
  7600. })
  7601. return
  7602. } else {
  7603. if res.Output.Result.SscnoCheckStat == "0" {
  7604. var msg string
  7605. switch res.Output.Result.CardStat {
  7606. case "00":
  7607. msg = "未激活"
  7608. break
  7609. case "10":
  7610. msg = "激活"
  7611. break
  7612. case "20":
  7613. msg = "窗口挂失"
  7614. break
  7615. case "21":
  7616. msg = "电话挂失"
  7617. break
  7618. case "22":
  7619. msg = "单位网上申报挂失"
  7620. break
  7621. case "23":
  7622. msg = "保健办挂失"
  7623. break
  7624. case "24":
  7625. msg = "个人网上挂失"
  7626. break
  7627. case "25":
  7628. msg = "网上服务大厅挂失"
  7629. break
  7630. case "30":
  7631. msg = "注销"
  7632. break
  7633. case "40":
  7634. msg = "回收"
  7635. break
  7636. case "99":
  7637. msg = "制卡中(无效卡)"
  7638. break
  7639. }
  7640. c.ServeSuccessJSON(map[string]interface{}{
  7641. "failed_code": -10,
  7642. "msg": msg,
  7643. })
  7644. return
  7645. } else {
  7646. c.ServeSuccessJSON(map[string]interface{}{
  7647. "msg": "校验成功",
  7648. })
  7649. return
  7650. }
  7651. }
  7652. }
  7653. type ELeCertData struct {
  7654. Data struct {
  7655. Extra string `json:"extra"`
  7656. IDNo string `json:"idNo"`
  7657. IDType string `json:"idType"`
  7658. EcToken string `json:"ecToken"`
  7659. InsuOrg string `json:"insuOrg"`
  7660. UserName string `json:"userName"`
  7661. EcIndexNo string `json:"ecIndexNo"`
  7662. Gender string `json:"gender"`
  7663. Birthday string `json:"birthday"`
  7664. Nationality string `json:"nationality"`
  7665. Email string `json:"email"`
  7666. } `json:"OutData"`
  7667. }
  7668. func (c *HisApiController) ReadCard() {
  7669. id_card_type, _ := c.GetInt64("id_card_type")
  7670. admin_user_id, _ := c.GetInt64("admin_user_id")
  7671. certificates, _ := c.GetInt64("certificates")
  7672. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7673. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7674. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7675. switch id_card_type {
  7676. case 1:
  7677. if miConfig.MdtrtareaAdmvs == "421300" {
  7678. var res ResultTwo
  7679. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7680. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7681. "&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)
  7682. resp, requestErr := http.Get(api)
  7683. if requestErr != nil {
  7684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7685. return
  7686. }
  7687. body, ioErr := ioutil.ReadAll(resp.Body)
  7688. if ioErr != nil {
  7689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7691. return
  7692. }
  7693. var respJSON map[string]interface{}
  7694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7697. return
  7698. }
  7699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7700. result, _ := json.Marshal(respJSON)
  7701. fmt.Println("log")
  7702. fmt.Println(string(result))
  7703. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7704. utils.ErrorLog("解析失败:%v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. if res.Infcode == 0 {
  7709. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7710. if err == gorm.ErrRecordNotFound {
  7711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7712. return
  7713. } else if err != nil {
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7715. return
  7716. } else {
  7717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7719. infoStr := string(Iinfos)
  7720. idetinfoStr := string(Idetinfos)
  7721. var rf []*ResultFive
  7722. json.Unmarshal([]byte(infoStr), &rf)
  7723. var insutypes []*ResultFive
  7724. var insutype string
  7725. var is390 int = 0
  7726. var is310 int = 0
  7727. for _, item := range rf {
  7728. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7729. insutypes = append(insutypes, item)
  7730. }
  7731. }
  7732. if len(insutypes) == 1 {
  7733. insutype = insutypes[0].Insutype
  7734. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7735. } else {
  7736. for _, i := range insutypes {
  7737. if i.Insutype == "390" {
  7738. is390 = 1
  7739. }
  7740. if i.Insutype == "310" {
  7741. is310 = 1
  7742. }
  7743. }
  7744. }
  7745. if is390 == 1 {
  7746. insutype = "390"
  7747. }
  7748. if is310 == 1 {
  7749. insutype = "310"
  7750. }
  7751. if len(insutypes) == 0 {
  7752. insutype = "390"
  7753. }
  7754. var insuplc_admdvs string
  7755. for _, item := range rf {
  7756. if item.Insutype == insutype {
  7757. insuplc_admdvs = item.InsuplcAdmdvs
  7758. }
  7759. }
  7760. if strings.Contains(insuplc_admdvs, "4213") {
  7761. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7762. }
  7763. psn := &models.HisPsn{
  7764. PsnNo: res.Output.Baseinfo.PsnNo,
  7765. PatientId: patient.ID,
  7766. Certno: res.Output.Baseinfo.Certno,
  7767. Gend: res.Output.Baseinfo.Gend,
  7768. Naty: res.Output.Baseinfo.Naty,
  7769. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7770. PsnName: res.Output.Baseinfo.PsnName,
  7771. Idetinfo: idetinfoStr,
  7772. Insuinfo: infoStr,
  7773. InsuplcAdmdvs: insuplc_admdvs,
  7774. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7775. }
  7776. service.CreateHisPsn(psn)
  7777. c.ServeSuccessJSON(map[string]interface{}{
  7778. "patient": patient,
  7779. "number": res.Output.Baseinfo.Certno,
  7780. })
  7781. }
  7782. } else {
  7783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7784. return
  7785. }
  7786. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7787. var res ResultTwo
  7788. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7789. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7790. "&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)
  7791. resp, requestErr := http.Get(api)
  7792. if requestErr != nil {
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7794. return
  7795. }
  7796. body, ioErr := ioutil.ReadAll(resp.Body)
  7797. if ioErr != nil {
  7798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7800. return
  7801. }
  7802. var respJSON map[string]interface{}
  7803. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7809. result, _ := json.Marshal(respJSON)
  7810. fmt.Println("log")
  7811. fmt.Println(string(result))
  7812. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7813. utils.ErrorLog("解析失败:%v", err)
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. return
  7816. }
  7817. if res.Infcode == 0 {
  7818. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7819. if err == gorm.ErrRecordNotFound {
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7821. return
  7822. } else if err != nil {
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7824. return
  7825. } else {
  7826. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7827. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7828. infoStr := string(Iinfos)
  7829. idetinfoStr := string(Idetinfos)
  7830. psn := &models.HisPsn{
  7831. PsnNo: res.Output.Baseinfo.PsnNo,
  7832. PatientId: patient.ID,
  7833. Certno: res.Output.Baseinfo.Certno,
  7834. Gend: res.Output.Baseinfo.Gend,
  7835. Naty: res.Output.Baseinfo.Naty,
  7836. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7837. PsnName: res.Output.Baseinfo.PsnName,
  7838. Idetinfo: idetinfoStr,
  7839. Insuinfo: infoStr,
  7840. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7841. }
  7842. service.CreateHisPsn(psn)
  7843. var rf []*ResultFive
  7844. json.Unmarshal([]byte(infoStr), &rf)
  7845. var insutypes []*ResultFive
  7846. var insutype string
  7847. var is390 int = 0
  7848. var is310 int = 0
  7849. for _, item := range rf {
  7850. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7851. insutypes = append(insutypes, item)
  7852. }
  7853. }
  7854. if len(insutypes) == 1 {
  7855. insutype = insutypes[0].Insutype
  7856. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7857. } else {
  7858. for _, i := range insutypes {
  7859. if i.Insutype == "390" {
  7860. is390 = 1
  7861. }
  7862. if i.Insutype == "310" {
  7863. is310 = 1
  7864. }
  7865. }
  7866. }
  7867. if is390 == 1 {
  7868. insutype = "390"
  7869. }
  7870. if is310 == 1 {
  7871. insutype = "310"
  7872. }
  7873. if len(insutypes) == 0 {
  7874. insutype = "310"
  7875. }
  7876. c.ServeSuccessJSON(map[string]interface{}{
  7877. "patient": patient,
  7878. "number": res.Output.Baseinfo.Certno,
  7879. "insutype": insutype,
  7880. })
  7881. }
  7882. } else {
  7883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7884. return
  7885. }
  7886. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7887. var res ResultTwo
  7888. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  7889. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7890. "&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)
  7891. resp, requestErr := http.Get(api)
  7892. if requestErr != nil {
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7894. return
  7895. }
  7896. body, ioErr := ioutil.ReadAll(resp.Body)
  7897. if ioErr != nil {
  7898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7900. return
  7901. }
  7902. var respJSON map[string]interface{}
  7903. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7909. result, _ := json.Marshal(respJSON)
  7910. fmt.Println("log")
  7911. fmt.Println(string(result))
  7912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7913. utils.ErrorLog("解析失败:%v", err)
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. if res.Infcode == 0 {
  7918. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7919. if err == gorm.ErrRecordNotFound {
  7920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7921. return
  7922. } else if err != nil {
  7923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7924. return
  7925. } else {
  7926. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7927. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7928. infoStr := string(Iinfos)
  7929. idetinfoStr := string(Idetinfos)
  7930. var rf []*ResultFive
  7931. json.Unmarshal([]byte(infoStr), &rf)
  7932. var insutypes []*ResultFive
  7933. var insutype string
  7934. var is390 int = 0
  7935. var is310 int = 0
  7936. for _, item := range rf {
  7937. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7938. insutypes = append(insutypes, item)
  7939. }
  7940. }
  7941. if len(insutypes) == 1 {
  7942. insutype = insutypes[0].Insutype
  7943. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7944. } else {
  7945. for _, i := range insutypes {
  7946. if i.Insutype == "390" {
  7947. is390 = 1
  7948. }
  7949. if i.Insutype == "310" {
  7950. is310 = 1
  7951. }
  7952. }
  7953. }
  7954. if is390 == 1 {
  7955. insutype = "390"
  7956. }
  7957. if is310 == 1 {
  7958. insutype = "310"
  7959. }
  7960. if len(insutypes) == 0 {
  7961. insutype = "390"
  7962. }
  7963. var insuplc_admdvs string
  7964. for _, item := range rf {
  7965. if item.Insutype == insutype {
  7966. insuplc_admdvs = item.InsuplcAdmdvs
  7967. }
  7968. }
  7969. psn := &models.HisPsn{
  7970. PsnNo: res.Output.Baseinfo.PsnNo,
  7971. PatientId: patient.ID,
  7972. Certno: res.Output.Baseinfo.Certno,
  7973. Gend: res.Output.Baseinfo.Gend,
  7974. Naty: res.Output.Baseinfo.Naty,
  7975. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7976. PsnName: res.Output.Baseinfo.PsnName,
  7977. Idetinfo: idetinfoStr,
  7978. Insuinfo: infoStr,
  7979. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7980. InsuplcAdmdvs: insuplc_admdvs,
  7981. }
  7982. service.CreateHisPsn(psn)
  7983. for _, item := range rf {
  7984. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7985. insutypes = append(insutypes, item)
  7986. }
  7987. }
  7988. if len(insutypes) == 1 {
  7989. insutype = insutypes[0].Insutype
  7990. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7991. } else {
  7992. for _, i := range insutypes {
  7993. if i.Insutype == "390" {
  7994. is390 = 1
  7995. }
  7996. if i.Insutype == "310" {
  7997. is310 = 1
  7998. }
  7999. }
  8000. }
  8001. if is390 == 1 {
  8002. insutype = "390"
  8003. }
  8004. if is310 == 1 {
  8005. insutype = "310"
  8006. }
  8007. if len(insutypes) == 0 {
  8008. insutype = "310"
  8009. }
  8010. c.ServeSuccessJSON(map[string]interface{}{
  8011. "patient": patient,
  8012. "number": res.Output.Baseinfo.Certno,
  8013. "insutype": insutype,
  8014. })
  8015. }
  8016. } else {
  8017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8018. return
  8019. }
  8020. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8021. var res ResultTwo
  8022. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  8023. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8024. "&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)
  8025. resp, requestErr := http.Get(api)
  8026. if requestErr != nil {
  8027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8028. return
  8029. }
  8030. body, ioErr := ioutil.ReadAll(resp.Body)
  8031. if ioErr != nil {
  8032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8034. return
  8035. }
  8036. var respJSON map[string]interface{}
  8037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8040. return
  8041. }
  8042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8043. result, _ := json.Marshal(respJSON)
  8044. fmt.Println("log")
  8045. fmt.Println(string(result))
  8046. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8047. utils.ErrorLog("解析失败:%v", err)
  8048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8049. return
  8050. }
  8051. if res.Infcode == 0 {
  8052. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8053. if err == gorm.ErrRecordNotFound {
  8054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8055. return
  8056. } else if err != nil {
  8057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8058. return
  8059. } else {
  8060. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8061. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8062. infoStr := string(Iinfos)
  8063. idetinfoStr := string(Idetinfos)
  8064. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8065. psn := &models.HisPsn{
  8066. PsnNo: res.Output.Baseinfo.PsnNo,
  8067. PatientId: patient.ID,
  8068. Certno: res.Output.Baseinfo.Certno,
  8069. Brdy: b,
  8070. Age: float64(age),
  8071. Gend: res.Output.Baseinfo.Gend,
  8072. Naty: res.Output.Baseinfo.Naty,
  8073. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8074. PsnName: res.Output.Baseinfo.PsnName,
  8075. Idetinfo: idetinfoStr,
  8076. Insuinfo: infoStr,
  8077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8078. }
  8079. service.CreateHisPsn(psn)
  8080. var rf []*ResultFive
  8081. json.Unmarshal([]byte(infoStr), &rf)
  8082. var insutypes []*ResultFive
  8083. var insutype string
  8084. var is390 int = 0
  8085. var is310 int = 0
  8086. for _, item := range rf {
  8087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8088. insutypes = append(insutypes, item)
  8089. }
  8090. }
  8091. if len(insutypes) == 1 {
  8092. insutype = insutypes[0].Insutype
  8093. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8094. } else {
  8095. for _, i := range insutypes {
  8096. if i.Insutype == "390" {
  8097. is390 = 1
  8098. }
  8099. if i.Insutype == "310" {
  8100. is310 = 1
  8101. }
  8102. }
  8103. }
  8104. if is390 == 1 {
  8105. insutype = "390"
  8106. }
  8107. if is310 == 1 {
  8108. insutype = "310"
  8109. }
  8110. if len(insutypes) == 0 {
  8111. insutype = "310"
  8112. }
  8113. c.ServeSuccessJSON(map[string]interface{}{
  8114. "patient": patient,
  8115. "number": res.Output.Baseinfo.Certno,
  8116. "insutype": insutype,
  8117. })
  8118. }
  8119. } else {
  8120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8121. return
  8122. }
  8123. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8124. var api string
  8125. if miConfig.MdtrtareaAdmvs == "320921" {
  8126. 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 +
  8127. "&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
  8128. fmt.Println(api)
  8129. } else {
  8130. 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 +
  8131. "&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)
  8132. }
  8133. resp, requestErr := http.Get(api)
  8134. if requestErr != nil {
  8135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8136. return
  8137. }
  8138. body, ioErr := ioutil.ReadAll(resp.Body)
  8139. if ioErr != nil {
  8140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. var respJSON map[string]interface{}
  8145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8148. return
  8149. }
  8150. var status string
  8151. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8152. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8153. //console.log()
  8154. fmt.Println("type===")
  8155. fmt.Println(card_type)
  8156. var token string
  8157. var res ResultTwo //1101结果
  8158. var res10265 ResultTwo10265 //1101结果
  8159. var card_info string //卡信息
  8160. var busi_card_info string
  8161. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8162. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8163. if status == "0" { //读卡成功
  8164. if card_type == "1" {
  8165. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8166. result, _ := json.Marshal(respJSON)
  8167. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8168. utils.ErrorLog("解析失败:%v", err)
  8169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8170. return
  8171. }
  8172. res.ErrMsg = res10265.ErrMsg
  8173. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8174. res.Infcode = infocode
  8175. res.Output = res10265.Output
  8176. res.InfRefmsgid = res10265.InfRefmsgid
  8177. } else {
  8178. //var card_info string //卡信息
  8179. //var busi_card_info string
  8180. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8181. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8182. //fmt.Println(card_info)
  8183. //fmt.Println(busi_card_info)
  8184. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8185. result, _ := json.Marshal(respJSON)
  8186. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8187. utils.ErrorLog("解析失败:%v", err)
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. res.ErrMsg = res10265.ErrMsg
  8192. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8193. res.Infcode = infocode
  8194. res.Output = res10265.Output
  8195. res.InfRefmsgid = res10265.InfRefmsgid
  8196. }
  8197. if res.Infcode == 0 {
  8198. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8199. if err == gorm.ErrRecordNotFound {
  8200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8201. return
  8202. } else if err != nil {
  8203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8204. return
  8205. } else {
  8206. if card_type == "1" {
  8207. bas := strings.Split(card_info, "|")
  8208. basNumber := bas[2]
  8209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8211. infoStr := string(Iinfos)
  8212. idetinfoStr := string(Idetinfos)
  8213. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8214. psn := &models.HisPsn{
  8215. PsnNo: res.Output.Baseinfo.PsnNo,
  8216. PatientId: patient.ID,
  8217. Certno: res.Output.Baseinfo.Certno,
  8218. Brdy: b,
  8219. Age: float64(age),
  8220. Gend: res.Output.Baseinfo.Gend,
  8221. Naty: res.Output.Baseinfo.Naty,
  8222. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8223. PsnName: res.Output.Baseinfo.PsnName,
  8224. Idetinfo: idetinfoStr,
  8225. Insuinfo: infoStr,
  8226. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8227. CardInfo: card_info,
  8228. VerifyNumber: busi_card_info,
  8229. }
  8230. service.CreateHisPsn(psn)
  8231. var rf []*ResultFive
  8232. json.Unmarshal([]byte(infoStr), &rf)
  8233. var insutypes []*ResultFive
  8234. var insutype string
  8235. var is390 int = 0
  8236. var is310 int = 0
  8237. for _, item := range rf {
  8238. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8239. insutypes = append(insutypes, item)
  8240. }
  8241. }
  8242. if len(insutypes) == 1 {
  8243. insutype = insutypes[0].Insutype
  8244. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8245. } else {
  8246. for _, i := range insutypes {
  8247. if i.Insutype == "390" {
  8248. is390 = 1
  8249. }
  8250. if i.Insutype == "310" {
  8251. is310 = 1
  8252. }
  8253. }
  8254. }
  8255. if is390 == 1 {
  8256. insutype = "390"
  8257. }
  8258. if is310 == 1 {
  8259. insutype = "310"
  8260. }
  8261. if len(insutypes) == 0 {
  8262. insutype = "310"
  8263. }
  8264. c.ServeSuccessJSON(map[string]interface{}{
  8265. "patient": patient,
  8266. "number": basNumber,
  8267. "insutype": insutype,
  8268. })
  8269. } else {
  8270. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8271. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8272. infoStr := string(Iinfos)
  8273. idetinfoStr := string(Idetinfos)
  8274. psn := &models.HisPsn{
  8275. PsnNo: res.Output.Baseinfo.PsnNo,
  8276. PatientId: patient.ID,
  8277. Certno: res.Output.Baseinfo.Certno,
  8278. Gend: res.Output.Baseinfo.Gend,
  8279. Naty: res.Output.Baseinfo.Naty,
  8280. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8281. PsnName: res.Output.Baseinfo.PsnName,
  8282. Idetinfo: idetinfoStr,
  8283. Insuinfo: infoStr,
  8284. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8285. CardInfo: card_info,
  8286. VerifyNumber: token,
  8287. }
  8288. service.CreateHisPsn(psn)
  8289. c.ServeSuccessJSON(map[string]interface{}{
  8290. "patient": patient,
  8291. "number": token,
  8292. })
  8293. }
  8294. }
  8295. } else {
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8297. return
  8298. }
  8299. } else { //读卡失败
  8300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8301. return
  8302. }
  8303. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8304. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8305. cardnum = DeleteExtraSpaceTwo(cardnum)
  8306. cardCode = DeleteExtraSpaceTwo(cardCode)
  8307. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8308. name = DeleteExtraSpaceTwo(name)
  8309. errmsg = DeleteExtraSpaceTwo(errmsg)
  8310. cardnum = Remove0000(cardnum)
  8311. cardCode = Remove0000(cardCode)
  8312. id_card_no = Remove0000(id_card_no)
  8313. name = Remove0000(name)
  8314. errmsg = Remove0000(errmsg)
  8315. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8316. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8317. //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)
  8318. //fmt.Println(result2)
  8319. //fmt.Println(requestLog2)
  8320. //fmt.Println(errMsgLog2)
  8321. 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)
  8322. saveLog(result, requestLog, "1101", "获取人员信息")
  8323. fmt.Println(errMsgLog)
  8324. if len(errMsgLog) > 0 {
  8325. } else {
  8326. var dat map[string]interface{}
  8327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8328. fmt.Println(dat)
  8329. } else {
  8330. fmt.Println(err)
  8331. }
  8332. userJSONBytes, _ := json.Marshal(dat)
  8333. var res ResultTwo
  8334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8335. utils.ErrorLog("解析失败:%v", err)
  8336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8337. return
  8338. }
  8339. res.ErrMsg = errMsgLog
  8340. if res.Infcode == 0 {
  8341. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8342. if err == gorm.ErrRecordNotFound {
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8344. return
  8345. } else if err != nil {
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8347. return
  8348. } else {
  8349. fmt.Println(res)
  8350. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8351. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8352. infoStr := string(Iinfos)
  8353. idetinfoStr := string(Idetinfos)
  8354. var rf []*ResultFive
  8355. json.Unmarshal([]byte(infoStr), &rf)
  8356. var insutypes []*ResultFive
  8357. var insutype string
  8358. var is390 int = 0
  8359. var is310 int = 0
  8360. for _, item := range rf {
  8361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8362. insutypes = append(insutypes, item)
  8363. }
  8364. }
  8365. if len(insutypes) == 1 {
  8366. insutype = insutypes[0].Insutype
  8367. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8368. } else {
  8369. for _, i := range insutypes {
  8370. if i.Insutype == "390" {
  8371. is390 = 1
  8372. }
  8373. if i.Insutype == "310" {
  8374. is310 = 1
  8375. }
  8376. }
  8377. }
  8378. if is390 == 1 {
  8379. insutype = "390"
  8380. }
  8381. if is310 == 1 {
  8382. insutype = "310"
  8383. }
  8384. if len(insutypes) == 0 {
  8385. insutype = "390"
  8386. }
  8387. var insuplc_admdvs string
  8388. for _, item := range rf {
  8389. if item.Insutype == insutype {
  8390. insuplc_admdvs = item.InsuplcAdmdvs
  8391. }
  8392. }
  8393. psn := &models.HisPsn{
  8394. PsnNo: res.Output.Baseinfo.PsnNo,
  8395. PatientId: patient.ID,
  8396. Certno: res.Output.Baseinfo.Certno,
  8397. Gend: res.Output.Baseinfo.Gend,
  8398. Naty: res.Output.Baseinfo.Naty,
  8399. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8400. PsnName: res.Output.Baseinfo.PsnName,
  8401. Idetinfo: idetinfoStr,
  8402. Insuinfo: infoStr,
  8403. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8404. CardInfo: basStr,
  8405. VerifyNumber: "",
  8406. InsuplcAdmdvs: insuplc_admdvs,
  8407. }
  8408. service.CreateHisPsn(psn)
  8409. c.ServeSuccessJSON(map[string]interface{}{
  8410. "patient": patient,
  8411. "number": cardnum,
  8412. "insutype": insutype,
  8413. })
  8414. }
  8415. } else {
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8417. return
  8418. }
  8419. }
  8420. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8421. fmt.Println(initFlag)
  8422. fmt.Println("initFlag")
  8423. if initFlag == 0 {
  8424. c.TestGetJiangXiBasBaseInit()
  8425. }
  8426. basStr := c.GetBasBaseInfo()
  8427. if len(basStr) == 0 {
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8429. return
  8430. }
  8431. fmt.Println(basStr)
  8432. bas := strings.Split(basStr, "|")
  8433. basNumber := bas[1]
  8434. fmt.Println(basNumber)
  8435. card_sn := bas[3]
  8436. fmt.Println(card_sn)
  8437. 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, "")
  8438. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8439. var dat map[string]interface{}
  8440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8441. fmt.Println(dat)
  8442. } else {
  8443. fmt.Println(err)
  8444. }
  8445. userJSONBytes, _ := json.Marshal(dat)
  8446. var res ResultTwo
  8447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8448. utils.ErrorLog("解析失败:%v", err)
  8449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8450. return
  8451. }
  8452. if res.Infcode == 0 {
  8453. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8454. if err == gorm.ErrRecordNotFound {
  8455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8456. return
  8457. } else if err != nil {
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8459. return
  8460. } else {
  8461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8463. infoStr := string(Iinfos)
  8464. idetinfoStr := string(Idetinfos)
  8465. var rf []*ResultFive
  8466. json.Unmarshal([]byte(infoStr), &rf)
  8467. var insutypes []*ResultFive
  8468. var insutype string
  8469. var is390 int = 0
  8470. var is310 int = 0
  8471. var insuplc_admdvs string
  8472. for _, item := range rf {
  8473. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8474. insutypes = append(insutypes, item)
  8475. }
  8476. }
  8477. if len(insutypes) == 1 {
  8478. insutype = insutypes[0].Insutype
  8479. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8480. } else {
  8481. for _, i := range insutypes {
  8482. if i.Insutype == "390" {
  8483. is390 = 1
  8484. }
  8485. if i.Insutype == "310" {
  8486. is310 = 1
  8487. }
  8488. }
  8489. }
  8490. if is390 == 1 {
  8491. insutype = "390"
  8492. }
  8493. if is310 == 1 {
  8494. insutype = "310"
  8495. }
  8496. if len(insutypes) == 0 {
  8497. insutype = "310"
  8498. }
  8499. for _, item := range rf {
  8500. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8501. insuplc_admdvs = item.InsuplcAdmdvs
  8502. }
  8503. }
  8504. psn := &models.HisPsn{
  8505. PsnNo: res.Output.Baseinfo.PsnNo,
  8506. PatientId: patient.ID,
  8507. Certno: res.Output.Baseinfo.Certno,
  8508. Gend: res.Output.Baseinfo.Gend,
  8509. Naty: res.Output.Baseinfo.Naty,
  8510. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8511. PsnName: res.Output.Baseinfo.PsnName,
  8512. Idetinfo: idetinfoStr,
  8513. Insuinfo: infoStr,
  8514. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8515. CardInfo: basStr,
  8516. InsuplcAdmdvs: insuplc_admdvs,
  8517. VerifyNumber: "",
  8518. }
  8519. service.CreateHisPsn(psn)
  8520. c.ServeSuccessJSON(map[string]interface{}{
  8521. "patient": patient,
  8522. "number": basNumber,
  8523. "insutype": insutype,
  8524. })
  8525. }
  8526. } else {
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8528. return
  8529. }
  8530. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8531. fmt.Println(initFlag)
  8532. fmt.Println("initFlag")
  8533. if initFlag == 0 {
  8534. c.TestGetHnBasBaseInit()
  8535. }
  8536. basStr := c.GetBasBaseInfo()
  8537. if len(basStr) == 0 {
  8538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8539. return
  8540. }
  8541. fmt.Println(basStr)
  8542. bas := strings.Split(basStr, "|")
  8543. basNumber := bas[1]
  8544. fmt.Println(basNumber)
  8545. card_sn := bas[3]
  8546. card_no := bas[2]
  8547. fmt.Println(card_sn)
  8548. name := bas[4]
  8549. name = ConvertToString(name, "gbk", "utf-8")
  8550. 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)
  8551. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8552. var dat map[string]interface{}
  8553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8554. fmt.Println(dat)
  8555. } else {
  8556. fmt.Println(err)
  8557. }
  8558. userJSONBytes, _ := json.Marshal(dat)
  8559. var res ResultTwo
  8560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8561. utils.ErrorLog("解析失败:%v", err)
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. if res.Infcode == 0 {
  8566. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8567. if err == gorm.ErrRecordNotFound {
  8568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8569. return
  8570. } else if err != nil {
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8572. return
  8573. } else {
  8574. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8575. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8576. infoStr := string(Iinfos)
  8577. idetinfoStr := string(Idetinfos)
  8578. psn := &models.HisPsn{
  8579. PsnNo: res.Output.Baseinfo.PsnNo,
  8580. PatientId: patient.ID,
  8581. Certno: res.Output.Baseinfo.Certno,
  8582. Gend: res.Output.Baseinfo.Gend,
  8583. Naty: res.Output.Baseinfo.Naty,
  8584. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8585. PsnName: res.Output.Baseinfo.PsnName,
  8586. Idetinfo: idetinfoStr,
  8587. Insuinfo: infoStr,
  8588. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8589. CardInfo: basStr,
  8590. VerifyNumber: "",
  8591. }
  8592. service.CreateHisPsn(psn)
  8593. var rf []*ResultFive
  8594. json.Unmarshal([]byte(infoStr), &rf)
  8595. var insutypes []*ResultFive
  8596. var insutype string
  8597. var is390 int = 0
  8598. var is310 int = 0
  8599. for _, item := range rf {
  8600. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8601. insutypes = append(insutypes, item)
  8602. }
  8603. }
  8604. if len(insutypes) == 1 {
  8605. insutype = insutypes[0].Insutype
  8606. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8607. } else {
  8608. for _, i := range insutypes {
  8609. if i.Insutype == "390" {
  8610. is390 = 1
  8611. }
  8612. if i.Insutype == "310" {
  8613. is310 = 1
  8614. }
  8615. }
  8616. }
  8617. if is390 == 1 {
  8618. insutype = "390"
  8619. }
  8620. if is310 == 1 {
  8621. insutype = "310"
  8622. }
  8623. if len(insutypes) == 0 {
  8624. insutype = "310"
  8625. }
  8626. c.ServeSuccessJSON(map[string]interface{}{
  8627. "patient": patient,
  8628. "number": basNumber,
  8629. "insutype": insutype,
  8630. })
  8631. }
  8632. } else {
  8633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8634. return
  8635. }
  8636. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8637. var api string
  8638. 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 +
  8639. "&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
  8640. fmt.Println(api)
  8641. resp, requestErr := http.Get(api)
  8642. if requestErr != nil {
  8643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8644. return
  8645. }
  8646. body, ioErr := ioutil.ReadAll(resp.Body)
  8647. if ioErr != nil {
  8648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8650. return
  8651. }
  8652. var respJSON map[string]interface{}
  8653. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8656. return
  8657. }
  8658. var res ResultTwo //1101结果
  8659. var res10265 ResultTwo10265 //1101结果
  8660. var card_info string //卡信息
  8661. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8662. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8663. result, _ := json.Marshal(respJSON)
  8664. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8665. utils.ErrorLog("解析失败:%v", err)
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. res.ErrMsg = res10265.ErrMsg
  8670. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8671. res.Infcode = infocode
  8672. res.Output = res10265.Output
  8673. res.InfRefmsgid = res10265.InfRefmsgid
  8674. if res.Infcode == 0 {
  8675. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8676. if err == gorm.ErrRecordNotFound {
  8677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8678. return
  8679. } else if err != nil {
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8681. return
  8682. } else {
  8683. bas := strings.Split(card_info, "|")
  8684. basNumber := bas[2]
  8685. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8686. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8687. infoStr := string(Iinfos)
  8688. idetinfoStr := string(Idetinfos)
  8689. psn := &models.HisPsn{
  8690. PsnNo: res.Output.Baseinfo.PsnNo,
  8691. PatientId: patient.ID,
  8692. Certno: res.Output.Baseinfo.Certno,
  8693. Gend: res.Output.Baseinfo.Gend,
  8694. Naty: res.Output.Baseinfo.Naty,
  8695. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8696. PsnName: res.Output.Baseinfo.PsnName,
  8697. Idetinfo: idetinfoStr,
  8698. Insuinfo: infoStr,
  8699. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8700. CardInfo: card_info,
  8701. VerifyNumber: token,
  8702. }
  8703. service.CreateHisPsn(psn)
  8704. var rf []*ResultFive
  8705. json.Unmarshal([]byte(infoStr), &rf)
  8706. var insutypes []*ResultFive
  8707. var insutype string
  8708. var is390 int = 0
  8709. var is310 int = 0
  8710. for _, item := range rf {
  8711. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8712. insutypes = append(insutypes, item)
  8713. }
  8714. }
  8715. if len(insutypes) == 1 {
  8716. insutype = insutypes[0].Insutype
  8717. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8718. } else {
  8719. for _, i := range insutypes {
  8720. if i.Insutype == "390" {
  8721. is390 = 1
  8722. }
  8723. if i.Insutype == "310" {
  8724. is310 = 1
  8725. }
  8726. }
  8727. }
  8728. if is390 == 1 {
  8729. insutype = "390"
  8730. }
  8731. if is310 == 1 {
  8732. insutype = "310"
  8733. }
  8734. if len(insutypes) == 0 {
  8735. insutype = "310"
  8736. }
  8737. c.ServeSuccessJSON(map[string]interface{}{
  8738. "patient": patient,
  8739. "number": basNumber,
  8740. "insutype": insutype,
  8741. })
  8742. }
  8743. } else {
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8745. return
  8746. }
  8747. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8748. res := c.GetoleInfo()
  8749. if res.Infcode == 0 {
  8750. var result string
  8751. if res.Output.MdtrtCertType == "01" {
  8752. 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)
  8753. } else if res.Output.MdtrtCertType == "02" {
  8754. 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)
  8755. } else if res.Output.MdtrtCertType == "03" {
  8756. 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)
  8757. }
  8758. var dat map[string]interface{}
  8759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8760. fmt.Println(dat)
  8761. } else {
  8762. fmt.Println(err)
  8763. }
  8764. userJSONBytes, _ := json.Marshal(dat)
  8765. var res2 ResultTwo
  8766. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8767. utils.ErrorLog("解析失败:%v", err)
  8768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8769. return
  8770. }
  8771. if res2.Infcode == 0 {
  8772. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8773. if err == gorm.ErrRecordNotFound {
  8774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8775. return
  8776. } else if err != nil {
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8778. return
  8779. } else {
  8780. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8781. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8782. infoStr := string(Iinfos)
  8783. idetinfoStr := string(Idetinfos)
  8784. var rf []*ResultFive
  8785. json.Unmarshal([]byte(infoStr), &rf)
  8786. var insutypes []*ResultFive
  8787. var insutype string
  8788. var is390 int = 0
  8789. var is310 int = 0
  8790. //var insuplc_admdvs string
  8791. for _, item := range rf {
  8792. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8793. insutypes = append(insutypes, item)
  8794. }
  8795. }
  8796. if len(insutypes) == 1 {
  8797. insutype = insutypes[0].Insutype
  8798. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8799. } else {
  8800. for _, i := range insutypes {
  8801. if i.Insutype == "390" {
  8802. is390 = 1
  8803. }
  8804. if i.Insutype == "310" {
  8805. is310 = 1
  8806. }
  8807. }
  8808. }
  8809. if is390 == 1 {
  8810. insutype = "390"
  8811. }
  8812. if is310 == 1 {
  8813. insutype = "310"
  8814. }
  8815. if len(insutypes) == 0 {
  8816. insutype = "310"
  8817. }
  8818. psn := &models.HisPsn{
  8819. PsnNo: res2.Output.Baseinfo.PsnNo,
  8820. PatientId: patient.ID,
  8821. Certno: res2.Output.Baseinfo.Certno,
  8822. Gend: res2.Output.Baseinfo.Gend,
  8823. Naty: res2.Output.Baseinfo.Naty,
  8824. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8825. PsnName: res2.Output.Baseinfo.PsnName,
  8826. Idetinfo: idetinfoStr,
  8827. Insuinfo: infoStr,
  8828. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8829. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8830. VerifyNumber: res.Output.EcToken,
  8831. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8832. }
  8833. if res.Output.MdtrtCertType == "01" {
  8834. psn.VerifyNumber = res.Output.EcToken
  8835. //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)
  8836. } else if res.Output.MdtrtCertType == "02" {
  8837. psn.VerifyNumber = res.Output.MdtrtCertNo
  8838. //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)
  8839. } else if res.Output.MdtrtCertType == "03" {
  8840. psn.VerifyNumber = res.Output.MdtrtCertNo
  8841. //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)
  8842. }
  8843. var balc float64
  8844. for _, item := range rf {
  8845. if item.Insutype == insutype {
  8846. balc = item.Balc
  8847. }
  8848. }
  8849. service.CreateHisPsn(psn)
  8850. c.ServeSuccessJSON(map[string]interface{}{
  8851. "patient": patient,
  8852. "number": res.Output.CardNo,
  8853. "insutype": insutype,
  8854. "blac": balc,
  8855. "desc": idetinfoStr,
  8856. })
  8857. }
  8858. } else {
  8859. c.ServeSuccessJSON(map[string]interface{}{
  8860. "failed_code": -10,
  8861. "msg": res2.ErrMsg,
  8862. })
  8863. }
  8864. } else {
  8865. c.ServeSuccessJSON(map[string]interface{}{
  8866. "failed_code": -10,
  8867. "msg": res.ErrMsg,
  8868. })
  8869. }
  8870. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8871. var api string
  8872. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8873. "&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
  8874. fmt.Println(api)
  8875. resp, requestErr := http.Get(api)
  8876. if requestErr != nil {
  8877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8878. return
  8879. }
  8880. body, ioErr := ioutil.ReadAll(resp.Body)
  8881. if ioErr != nil {
  8882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8884. return
  8885. }
  8886. var respJSON map[string]interface{}
  8887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8890. return
  8891. }
  8892. var status string
  8893. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8894. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8895. //console.log()
  8896. fmt.Println("type===")
  8897. fmt.Println(card_type)
  8898. var token string
  8899. var res ResultTwo //1101结果
  8900. //var res10265 ResultTwoesultTwo10265 //1101结果
  8901. var card_info string //卡信息
  8902. var busi_card_info string
  8903. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8904. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8905. if status == "0" { //读卡成功
  8906. if card_type == "1" {
  8907. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8908. result, _ := json.Marshal(respJSON)
  8909. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8910. utils.ErrorLog("解析失败:%v", err)
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8912. return
  8913. }
  8914. } else {
  8915. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8916. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8917. result, _ := json.Marshal(respJSON)
  8918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8919. utils.ErrorLog("解析失败:%v", err)
  8920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8921. return
  8922. }
  8923. }
  8924. if res.Infcode == 0 {
  8925. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8926. if err == gorm.ErrRecordNotFound {
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8928. return
  8929. } else if err != nil {
  8930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8931. return
  8932. } else {
  8933. if card_type == "1" {
  8934. bas := strings.Split(card_info, "|")
  8935. basNumber := bas[2]
  8936. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8937. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8938. infoStr := string(Iinfos)
  8939. idetinfoStr := string(Idetinfos)
  8940. psn := &models.HisPsn{
  8941. PsnNo: res.Output.Baseinfo.PsnNo,
  8942. PatientId: patient.ID,
  8943. Certno: res.Output.Baseinfo.Certno,
  8944. Gend: res.Output.Baseinfo.Gend,
  8945. Naty: res.Output.Baseinfo.Naty,
  8946. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8947. PsnName: res.Output.Baseinfo.PsnName,
  8948. Idetinfo: idetinfoStr,
  8949. Insuinfo: infoStr,
  8950. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8951. CardInfo: card_info,
  8952. VerifyNumber: busi_card_info,
  8953. }
  8954. service.CreateHisPsn(psn)
  8955. var rf []*ResultFive
  8956. json.Unmarshal([]byte(infoStr), &rf)
  8957. var insutypes []*ResultFive
  8958. var insutype string
  8959. var is390 int = 0
  8960. var is310 int = 0
  8961. for _, item := range rf {
  8962. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8963. insutypes = append(insutypes, item)
  8964. }
  8965. }
  8966. if len(insutypes) == 1 {
  8967. insutype = insutypes[0].Insutype
  8968. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8969. } else {
  8970. for _, i := range insutypes {
  8971. if i.Insutype == "390" {
  8972. is390 = 1
  8973. }
  8974. if i.Insutype == "310" {
  8975. is310 = 1
  8976. }
  8977. }
  8978. }
  8979. if is390 == 1 {
  8980. insutype = "390"
  8981. }
  8982. if is310 == 1 {
  8983. insutype = "310"
  8984. }
  8985. if len(insutypes) == 0 {
  8986. insutype = "310"
  8987. }
  8988. c.ServeSuccessJSON(map[string]interface{}{
  8989. "patient": patient,
  8990. "number": basNumber,
  8991. "insutype": insutype,
  8992. })
  8993. } else {
  8994. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8995. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8996. infoStr := string(Iinfos)
  8997. idetinfoStr := string(Idetinfos)
  8998. psn := &models.HisPsn{
  8999. PsnNo: res.Output.Baseinfo.PsnNo,
  9000. PatientId: patient.ID,
  9001. Certno: res.Output.Baseinfo.Certno,
  9002. Gend: res.Output.Baseinfo.Gend,
  9003. Naty: res.Output.Baseinfo.Naty,
  9004. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9005. PsnName: res.Output.Baseinfo.PsnName,
  9006. Idetinfo: idetinfoStr,
  9007. Insuinfo: infoStr,
  9008. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9009. CardInfo: card_info,
  9010. VerifyNumber: token,
  9011. }
  9012. service.CreateHisPsn(psn)
  9013. c.ServeSuccessJSON(map[string]interface{}{
  9014. "patient": patient,
  9015. "number": token,
  9016. })
  9017. }
  9018. }
  9019. } else {
  9020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9021. return
  9022. }
  9023. } else { //读卡失败
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9025. return
  9026. }
  9027. } else {
  9028. if initFlag == 0 {
  9029. c.TestGetBasBaseInit()
  9030. }
  9031. basStr := c.GetBasBaseInfo()
  9032. if len(basStr) == 0 {
  9033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9034. return
  9035. }
  9036. fmt.Println(basStr)
  9037. bas := strings.Split(basStr, "|")
  9038. basNumber := bas[1]
  9039. fmt.Println(basNumber)
  9040. card_sn := bas[3]
  9041. fmt.Println(card_sn)
  9042. cardNumber := bas[2]
  9043. fmt.Println(cardNumber)
  9044. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  9045. var result string
  9046. if bas[0][:2] == "44" {
  9047. 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)
  9048. } else {
  9049. 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)
  9050. }
  9051. var dat map[string]interface{}
  9052. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9053. fmt.Println(dat)
  9054. } else {
  9055. fmt.Println(err)
  9056. }
  9057. userJSONBytes, _ := json.Marshal(dat)
  9058. var res ResultTwo
  9059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9060. utils.ErrorLog("解析失败:%v", err)
  9061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9062. return
  9063. }
  9064. if res.Infcode == 0 {
  9065. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9066. if err == gorm.ErrRecordNotFound {
  9067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9068. return
  9069. } else if err != nil {
  9070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9071. return
  9072. } else {
  9073. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9074. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9075. infoStr := string(Iinfos)
  9076. idetinfoStr := string(Idetinfos)
  9077. var rf []*ResultFive
  9078. json.Unmarshal([]byte(infoStr), &rf)
  9079. var insutypes []*ResultFive
  9080. var insutype string
  9081. var is390 int = 0
  9082. var is310 int = 0
  9083. var insuplc_admdvs string
  9084. for _, item := range rf {
  9085. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9086. insutypes = append(insutypes, item)
  9087. }
  9088. }
  9089. if len(insutypes) == 1 {
  9090. insutype = insutypes[0].Insutype
  9091. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9092. } else {
  9093. for _, i := range insutypes {
  9094. if i.Insutype == "390" {
  9095. is390 = 1
  9096. }
  9097. if i.Insutype == "310" {
  9098. is310 = 1
  9099. }
  9100. }
  9101. }
  9102. if is390 == 1 {
  9103. insutype = "390"
  9104. }
  9105. if is310 == 1 {
  9106. insutype = "310"
  9107. }
  9108. if len(insutypes) == 0 {
  9109. insutype = "310"
  9110. }
  9111. for _, item := range rf {
  9112. if item.Insutype == insutype {
  9113. insuplc_admdvs = item.InsuplcAdmdvs
  9114. }
  9115. }
  9116. psn := &models.HisPsn{
  9117. PsnNo: res.Output.Baseinfo.PsnNo,
  9118. PatientId: patient.ID,
  9119. Certno: res.Output.Baseinfo.Certno,
  9120. Gend: res.Output.Baseinfo.Gend,
  9121. Naty: res.Output.Baseinfo.Naty,
  9122. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9123. PsnName: res.Output.Baseinfo.PsnName,
  9124. Idetinfo: idetinfoStr,
  9125. Insuinfo: infoStr,
  9126. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9127. CardInfo: basStr,
  9128. VerifyNumber: "",
  9129. InsuplcAdmdvs: insuplc_admdvs,
  9130. }
  9131. service.CreateHisPsn(psn)
  9132. c.ServeSuccessJSON(map[string]interface{}{
  9133. "patient": patient,
  9134. "number": basNumber,
  9135. })
  9136. }
  9137. } else {
  9138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9139. return
  9140. }
  9141. break
  9142. }
  9143. case 2:
  9144. if miConfig.MdtrtareaAdmvs == "430800" {
  9145. if initFlag == 0 {
  9146. c.TestGetHnBasBaseInit()
  9147. }
  9148. SFZStr := c.GetSFZBaseInfo()
  9149. if len(SFZStr) == 0 {
  9150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9151. return
  9152. }
  9153. fmt.Println(SFZStr)
  9154. id_card_str := strings.Split(SFZStr, "^")
  9155. card_no := id_card_str[0]
  9156. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9157. //name := id_card_str[1]
  9158. //name = ConvertToString(name, "gbk", "utf-8")
  9159. 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, "", patient.Name, card_no)
  9160. var dat map[string]interface{}
  9161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9162. fmt.Println(dat)
  9163. } else {
  9164. fmt.Println(err)
  9165. }
  9166. userJSONBytes, _ := json.Marshal(dat)
  9167. var res ResultTwo
  9168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9169. utils.ErrorLog("解析失败:%v", err)
  9170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9171. return
  9172. }
  9173. if res.Infcode == 0 {
  9174. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9175. if err == gorm.ErrRecordNotFound {
  9176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9177. return
  9178. } else if err != nil {
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9180. return
  9181. } else {
  9182. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9183. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9184. infoStr := string(Iinfos)
  9185. idetinfoStr := string(Idetinfos)
  9186. var rf []*ResultFive
  9187. json.Unmarshal([]byte(infoStr), &rf)
  9188. var insutypes []*ResultFive
  9189. var insutype string
  9190. var is390 int = 0
  9191. var is310 int = 0
  9192. for _, item := range rf {
  9193. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9194. insutypes = append(insutypes, item)
  9195. }
  9196. }
  9197. if len(insutypes) == 1 {
  9198. insutype = insutypes[0].Insutype
  9199. } else {
  9200. for _, i := range insutypes {
  9201. if i.Insutype == "390" {
  9202. is390 = 1
  9203. }
  9204. if i.Insutype == "310" {
  9205. is310 = 1
  9206. }
  9207. }
  9208. }
  9209. if is390 == 1 {
  9210. insutype = "390"
  9211. }
  9212. if is310 == 1 {
  9213. insutype = "310"
  9214. }
  9215. if len(insutypes) == 0 {
  9216. insutype = "310"
  9217. }
  9218. var InsuplcAdmdvs string
  9219. for _, item := range rf {
  9220. if item.Insutype == insutype {
  9221. InsuplcAdmdvs = item.InsuplcAdmdvs
  9222. }
  9223. }
  9224. psn := &models.HisPsn{
  9225. PsnNo: res.Output.Baseinfo.PsnNo,
  9226. PatientId: patient.ID,
  9227. Certno: res.Output.Baseinfo.Certno,
  9228. Gend: res.Output.Baseinfo.Gend,
  9229. Naty: res.Output.Baseinfo.Naty,
  9230. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9231. PsnName: res.Output.Baseinfo.PsnName,
  9232. Idetinfo: idetinfoStr,
  9233. Insuinfo: infoStr,
  9234. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9235. CardInfo: SFZStr,
  9236. VerifyNumber: "",
  9237. InsuplcAdmdvs: InsuplcAdmdvs,
  9238. }
  9239. service.CreateHisPsn(psn)
  9240. c.ServeSuccessJSON(map[string]interface{}{
  9241. "patient": patient,
  9242. "number": card_no,
  9243. "insutype": insutype,
  9244. })
  9245. }
  9246. } else {
  9247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9248. return
  9249. }
  9250. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9251. var res ResultTwo
  9252. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9253. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9254. "&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)
  9255. resp, requestErr := http.Get(api)
  9256. if requestErr != nil {
  9257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9258. return
  9259. }
  9260. body, ioErr := ioutil.ReadAll(resp.Body)
  9261. if ioErr != nil {
  9262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9264. return
  9265. }
  9266. var respJSON map[string]interface{}
  9267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9270. return
  9271. }
  9272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9273. result, _ := json.Marshal(respJSON)
  9274. fmt.Println("log")
  9275. fmt.Println(string(result))
  9276. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9277. utils.ErrorLog("解析失败:%v", err)
  9278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9279. return
  9280. }
  9281. if res.Infcode == 0 {
  9282. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9283. if err == gorm.ErrRecordNotFound {
  9284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9285. return
  9286. } else if err != nil {
  9287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9288. return
  9289. } else {
  9290. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9291. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9292. infoStr := string(Iinfos)
  9293. idetinfoStr := string(Idetinfos)
  9294. psn := &models.HisPsn{
  9295. PsnNo: res.Output.Baseinfo.PsnNo,
  9296. PatientId: patient.ID,
  9297. Certno: res.Output.Baseinfo.Certno,
  9298. Gend: res.Output.Baseinfo.Gend,
  9299. Naty: res.Output.Baseinfo.Naty,
  9300. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9301. PsnName: res.Output.Baseinfo.PsnName,
  9302. Idetinfo: idetinfoStr,
  9303. Insuinfo: infoStr,
  9304. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9305. }
  9306. service.CreateHisPsn(psn)
  9307. c.ServeSuccessJSON(map[string]interface{}{
  9308. "patient": patient,
  9309. "number": res.Output.Baseinfo.Certno,
  9310. })
  9311. }
  9312. } else {
  9313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9314. return
  9315. }
  9316. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9317. var res ResultTwo
  9318. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9319. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9320. "&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)
  9321. resp, requestErr := http.Get(api)
  9322. if requestErr != nil {
  9323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9324. return
  9325. }
  9326. body, ioErr := ioutil.ReadAll(resp.Body)
  9327. if ioErr != nil {
  9328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9330. return
  9331. }
  9332. var respJSON map[string]interface{}
  9333. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9336. return
  9337. }
  9338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9339. result, _ := json.Marshal(respJSON)
  9340. fmt.Println("log")
  9341. fmt.Println(string(result))
  9342. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9343. utils.ErrorLog("解析失败:%v", err)
  9344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9345. return
  9346. }
  9347. if res.Infcode == 0 {
  9348. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9349. if err == gorm.ErrRecordNotFound {
  9350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9351. return
  9352. } else if err != nil {
  9353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9354. return
  9355. } else {
  9356. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9357. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9358. infoStr := string(Iinfos)
  9359. idetinfoStr := string(Idetinfos)
  9360. psn := &models.HisPsn{
  9361. PsnNo: res.Output.Baseinfo.PsnNo,
  9362. PatientId: patient.ID,
  9363. Certno: res.Output.Baseinfo.Certno,
  9364. Gend: res.Output.Baseinfo.Gend,
  9365. Naty: res.Output.Baseinfo.Naty,
  9366. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9367. PsnName: res.Output.Baseinfo.PsnName,
  9368. Idetinfo: idetinfoStr,
  9369. Insuinfo: infoStr,
  9370. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9371. }
  9372. service.CreateHisPsn(psn)
  9373. c.ServeSuccessJSON(map[string]interface{}{
  9374. "patient": patient,
  9375. "number": res.Output.Baseinfo.Certno,
  9376. })
  9377. }
  9378. } else {
  9379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9380. return
  9381. }
  9382. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9383. var res ResultTwo
  9384. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9385. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9386. "&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)
  9387. resp, requestErr := http.Get(api)
  9388. if requestErr != nil {
  9389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9390. return
  9391. }
  9392. body, ioErr := ioutil.ReadAll(resp.Body)
  9393. if ioErr != nil {
  9394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9396. return
  9397. }
  9398. var respJSON map[string]interface{}
  9399. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9402. return
  9403. }
  9404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9405. result, _ := json.Marshal(respJSON)
  9406. fmt.Println("log")
  9407. fmt.Println(string(result))
  9408. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9409. utils.ErrorLog("解析失败:%v", err)
  9410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9411. return
  9412. }
  9413. if res.Infcode == 0 {
  9414. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9415. if err == gorm.ErrRecordNotFound {
  9416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9417. return
  9418. } else if err != nil {
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9420. return
  9421. } else {
  9422. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9423. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9424. infoStr := string(Iinfos)
  9425. idetinfoStr := string(Idetinfos)
  9426. var rf []*ResultFive
  9427. json.Unmarshal([]byte(infoStr), &rf)
  9428. var insutypes []*ResultFive
  9429. var insutype string
  9430. var is390 int = 0
  9431. var is310 int = 0
  9432. for _, item := range rf {
  9433. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9434. insutypes = append(insutypes, item)
  9435. }
  9436. }
  9437. if len(insutypes) == 1 {
  9438. insutype = insutypes[0].Insutype
  9439. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9440. } else {
  9441. for _, i := range insutypes {
  9442. if i.Insutype == "390" {
  9443. is390 = 1
  9444. }
  9445. if i.Insutype == "310" {
  9446. is310 = 1
  9447. }
  9448. }
  9449. }
  9450. if is390 == 1 {
  9451. insutype = "390"
  9452. }
  9453. if is310 == 1 {
  9454. insutype = "310"
  9455. }
  9456. if len(insutypes) == 0 {
  9457. insutype = "390"
  9458. }
  9459. var insuplc_admdvs string
  9460. for _, item := range rf {
  9461. if item.Insutype == insutype {
  9462. insuplc_admdvs = item.InsuplcAdmdvs
  9463. }
  9464. }
  9465. psn := &models.HisPsn{
  9466. PsnNo: res.Output.Baseinfo.PsnNo,
  9467. PatientId: patient.ID,
  9468. Certno: res.Output.Baseinfo.Certno,
  9469. Gend: res.Output.Baseinfo.Gend,
  9470. Naty: res.Output.Baseinfo.Naty,
  9471. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9472. PsnName: res.Output.Baseinfo.PsnName,
  9473. Idetinfo: idetinfoStr,
  9474. Insuinfo: infoStr,
  9475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9476. InsuplcAdmdvs: insuplc_admdvs,
  9477. }
  9478. service.CreateHisPsn(psn)
  9479. c.ServeSuccessJSON(map[string]interface{}{
  9480. "patient": patient,
  9481. "number": res.Output.Baseinfo.Certno,
  9482. })
  9483. }
  9484. } else {
  9485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9486. return
  9487. }
  9488. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9489. res := c.GetoleInfo()
  9490. if res.Infcode == 0 {
  9491. var result string
  9492. if res.Output.MdtrtCertType == "01" {
  9493. 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)
  9494. } else if res.Output.MdtrtCertType == "02" {
  9495. 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)
  9496. } else if res.Output.MdtrtCertType == "03" {
  9497. 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)
  9498. }
  9499. var dat map[string]interface{}
  9500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9501. fmt.Println(dat)
  9502. } else {
  9503. fmt.Println(err)
  9504. }
  9505. userJSONBytes, _ := json.Marshal(dat)
  9506. var res2 ResultTwo
  9507. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9508. utils.ErrorLog("解析失败:%v", err)
  9509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9510. return
  9511. }
  9512. if res2.Infcode == 0 {
  9513. patient, err := service.GetPatientByNumber(res.Output.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(res2.Output.Iinfo)
  9522. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9523. infoStr := string(Iinfos)
  9524. idetinfoStr := string(Idetinfos)
  9525. var rf []*ResultFive
  9526. json.Unmarshal([]byte(infoStr), &rf)
  9527. var insutypes []*ResultFive
  9528. var insutype string
  9529. var is390 int = 0
  9530. var is310 int = 0
  9531. //var insuplc_admdvs string
  9532. for _, item := range rf {
  9533. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9534. insutypes = append(insutypes, item)
  9535. }
  9536. }
  9537. if len(insutypes) == 1 {
  9538. insutype = insutypes[0].Insutype
  9539. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9540. } else {
  9541. for _, i := range insutypes {
  9542. if i.Insutype == "390" {
  9543. is390 = 1
  9544. }
  9545. if i.Insutype == "310" {
  9546. is310 = 1
  9547. }
  9548. }
  9549. }
  9550. if is390 == 1 {
  9551. insutype = "390"
  9552. }
  9553. if is310 == 1 {
  9554. insutype = "310"
  9555. }
  9556. if len(insutypes) == 0 {
  9557. insutype = "310"
  9558. }
  9559. psn := &models.HisPsn{
  9560. PsnNo: res2.Output.Baseinfo.PsnNo,
  9561. PatientId: patient.ID,
  9562. //Brdy: res2.Output.Baseinfo.Brdy,
  9563. Certno: res2.Output.Baseinfo.Certno,
  9564. Gend: res2.Output.Baseinfo.Gend,
  9565. Naty: res2.Output.Baseinfo.Naty,
  9566. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9567. PsnName: res2.Output.Baseinfo.PsnName,
  9568. Idetinfo: idetinfoStr,
  9569. Insuinfo: infoStr,
  9570. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9571. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9572. VerifyNumber: res.Output.EcToken,
  9573. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9574. }
  9575. service.CreateHisPsn(psn)
  9576. var balc float64
  9577. for _, item := range rf {
  9578. if item.Insutype == insutype {
  9579. balc = item.Balc
  9580. }
  9581. }
  9582. c.ServeSuccessJSON(map[string]interface{}{
  9583. "patient": patient,
  9584. "number": res.Output.CardNo,
  9585. "insutype": insutype,
  9586. "blac": balc,
  9587. "desc": idetinfoStr,
  9588. })
  9589. }
  9590. } else {
  9591. c.ServeSuccessJSON(map[string]interface{}{
  9592. "failed_code": -10,
  9593. "msg": res2.ErrMsg,
  9594. })
  9595. }
  9596. } else {
  9597. c.ServeSuccessJSON(map[string]interface{}{
  9598. "failed_code": -10,
  9599. "msg": res.ErrMsg,
  9600. })
  9601. }
  9602. } else {
  9603. SFZStr := c.GetSFZBaseInfo()
  9604. id_card_str := strings.Split(SFZStr, "^")
  9605. id_card_number := id_card_str[0]
  9606. card_sn := ""
  9607. 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)
  9608. var dat map[string]interface{}
  9609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9610. fmt.Println(dat)
  9611. } else {
  9612. fmt.Println(err)
  9613. }
  9614. userJSONBytes, _ := json.Marshal(dat)
  9615. var res ResultTwo
  9616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9617. utils.ErrorLog("解析失败:%v", err)
  9618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9619. return
  9620. }
  9621. if res.Infcode == 0 {
  9622. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9623. if err == gorm.ErrRecordNotFound {
  9624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9625. return
  9626. } else if err != nil {
  9627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9628. return
  9629. } else {
  9630. c.ServeSuccessJSON(map[string]interface{}{
  9631. "patient": patient,
  9632. "number": id_card_number,
  9633. })
  9634. }
  9635. } else {
  9636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9637. return
  9638. }
  9639. }
  9640. break
  9641. case 3:
  9642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9643. var api string
  9644. if miConfig.MdtrtareaAdmvs == "320921" {
  9645. 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 +
  9646. "&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
  9647. fmt.Println(api)
  9648. } else {
  9649. 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 +
  9650. "&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)
  9651. }
  9652. resp, requestErr := http.Get(api)
  9653. if requestErr != nil {
  9654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9655. return
  9656. }
  9657. body, ioErr := ioutil.ReadAll(resp.Body)
  9658. if ioErr != nil {
  9659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9661. return
  9662. }
  9663. var respJSON map[string]interface{}
  9664. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9667. return
  9668. }
  9669. var status string
  9670. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9671. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9672. var token string
  9673. var res ResultTwo //1101结果
  9674. var res10265 ResultTwo10265 //1101结果
  9675. var card_info string //卡信息
  9676. var busi_card_info string
  9677. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9678. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9679. if status == "0" { //读卡成功
  9680. if card_type == "1" {
  9681. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9682. result, _ := json.Marshal(respJSON)
  9683. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9684. utils.ErrorLog("解析失败:%v", err)
  9685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9686. return
  9687. }
  9688. res.ErrMsg = res10265.ErrMsg
  9689. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9690. res.Infcode = infocode
  9691. res.Output = res10265.Output
  9692. res.InfRefmsgid = res10265.InfRefmsgid
  9693. } else {
  9694. //var card_info string //卡信息
  9695. //var busi_card_info string
  9696. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9697. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9698. //fmt.Println(card_info)
  9699. //fmt.Println(busi_card_info)
  9700. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9701. result, _ := json.Marshal(respJSON)
  9702. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9703. utils.ErrorLog("解析失败:%v", err)
  9704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9705. return
  9706. }
  9707. res.ErrMsg = res10265.ErrMsg
  9708. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9709. res.Infcode = infocode
  9710. res.Output = res10265.Output
  9711. res.InfRefmsgid = res10265.InfRefmsgid
  9712. }
  9713. if res.Infcode == 0 {
  9714. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9715. if err == gorm.ErrRecordNotFound {
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9717. return
  9718. } else if err != nil {
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9720. return
  9721. } else {
  9722. if card_type == "1" {
  9723. bas := strings.Split(card_info, "|")
  9724. basNumber := bas[2]
  9725. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9726. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9727. infoStr := string(Iinfos)
  9728. idetinfoStr := string(Idetinfos)
  9729. psn := &models.HisPsn{
  9730. PsnNo: res.Output.Baseinfo.PsnNo,
  9731. PatientId: patient.ID,
  9732. Certno: res.Output.Baseinfo.Certno,
  9733. //Brdy: res.Output.Baseinfo.Brdy,
  9734. Gend: res.Output.Baseinfo.Gend,
  9735. Naty: res.Output.Baseinfo.Naty,
  9736. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9737. PsnName: res.Output.Baseinfo.PsnName,
  9738. Idetinfo: idetinfoStr,
  9739. Insuinfo: infoStr,
  9740. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9741. CardInfo: card_info,
  9742. VerifyNumber: busi_card_info,
  9743. }
  9744. service.CreateHisPsn(psn)
  9745. c.ServeSuccessJSON(map[string]interface{}{
  9746. "patient": patient,
  9747. "number": basNumber,
  9748. })
  9749. } else {
  9750. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9751. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9752. infoStr := string(Iinfos)
  9753. idetinfoStr := string(Idetinfos)
  9754. psn := &models.HisPsn{
  9755. PsnNo: res.Output.Baseinfo.PsnNo,
  9756. PatientId: patient.ID,
  9757. Certno: res.Output.Baseinfo.Certno,
  9758. Gend: res.Output.Baseinfo.Gend,
  9759. Naty: res.Output.Baseinfo.Naty,
  9760. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9761. PsnName: res.Output.Baseinfo.PsnName,
  9762. Idetinfo: idetinfoStr,
  9763. Insuinfo: infoStr,
  9764. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9765. CardInfo: card_info,
  9766. VerifyNumber: token,
  9767. }
  9768. service.CreateHisPsn(psn)
  9769. var rf []*ResultFive
  9770. json.Unmarshal([]byte(infoStr), &rf)
  9771. var insutypes []*ResultFive
  9772. var insutype string
  9773. var is390 int = 0
  9774. var is310 int = 0
  9775. for _, item := range rf {
  9776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9777. insutypes = append(insutypes, item)
  9778. }
  9779. }
  9780. if len(insutypes) == 1 {
  9781. insutype = insutypes[0].Insutype
  9782. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9783. } else {
  9784. for _, i := range insutypes {
  9785. if i.Insutype == "390" {
  9786. is390 = 1
  9787. }
  9788. if i.Insutype == "310" {
  9789. is310 = 1
  9790. }
  9791. }
  9792. }
  9793. if is390 == 1 {
  9794. insutype = "390"
  9795. }
  9796. if is310 == 1 {
  9797. insutype = "310"
  9798. }
  9799. if len(insutypes) == 0 {
  9800. insutype = "310"
  9801. }
  9802. c.ServeSuccessJSON(map[string]interface{}{
  9803. "patient": patient,
  9804. "number": token,
  9805. "insutype": insutype,
  9806. })
  9807. }
  9808. }
  9809. } else {
  9810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9811. return
  9812. }
  9813. } else { //读卡失败
  9814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9815. return
  9816. }
  9817. }
  9818. break
  9819. case 4:
  9820. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9821. var api string
  9822. if miConfig.MdtrtareaAdmvs == "320921" {
  9823. 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 +
  9824. "&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
  9825. fmt.Println(api)
  9826. } else {
  9827. 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 +
  9828. "&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)
  9829. }
  9830. resp, requestErr := http.Get(api)
  9831. if requestErr != nil {
  9832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9833. return
  9834. }
  9835. body, ioErr := ioutil.ReadAll(resp.Body)
  9836. if ioErr != nil {
  9837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9839. return
  9840. }
  9841. var respJSON map[string]interface{}
  9842. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9845. return
  9846. }
  9847. var status string
  9848. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9849. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9850. var token string
  9851. var res ResultTwo //1101结果
  9852. var res10265 ResultTwo10265 //1101结果
  9853. if status == "0" { //读卡成功
  9854. var card_info string //卡信息
  9855. var busi_card_info string
  9856. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9857. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9858. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9859. fmt.Println(card_info)
  9860. fmt.Println(busi_card_info)
  9861. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9862. result, _ := json.Marshal(respJSON)
  9863. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9864. utils.ErrorLog("解析失败:%v", err)
  9865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9866. return
  9867. }
  9868. res.ErrMsg = res10265.ErrMsg
  9869. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9870. res.Infcode = infocode
  9871. res.Output = res10265.Output
  9872. res.InfRefmsgid = res10265.InfRefmsgid
  9873. if res.Infcode == 0 {
  9874. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9875. if err == gorm.ErrRecordNotFound {
  9876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9877. return
  9878. } else if err != nil {
  9879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9880. return
  9881. } else {
  9882. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9883. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9884. infoStr := string(Iinfos)
  9885. idetinfoStr := string(Idetinfos)
  9886. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9887. psn := &models.HisPsn{
  9888. PsnNo: res.Output.Baseinfo.PsnNo,
  9889. PatientId: patient.ID,
  9890. Certno: res.Output.Baseinfo.Certno,
  9891. Brdy: b,
  9892. Age: float64(age),
  9893. //Brdy: res.Output.Baseinfo.Brdy,
  9894. Gend: res.Output.Baseinfo.Gend,
  9895. Naty: res.Output.Baseinfo.Naty,
  9896. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9897. PsnName: res.Output.Baseinfo.PsnName,
  9898. Idetinfo: idetinfoStr,
  9899. Insuinfo: infoStr,
  9900. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9901. CardInfo: card_info,
  9902. VerifyNumber: token,
  9903. }
  9904. var rf []*ResultFive
  9905. json.Unmarshal([]byte(infoStr), &rf)
  9906. var insutypes []*ResultFive
  9907. var insutype string
  9908. var is390 int = 0
  9909. var is310 int = 0
  9910. for _, item := range rf {
  9911. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9912. insutypes = append(insutypes, item)
  9913. }
  9914. }
  9915. if len(insutypes) == 1 {
  9916. insutype = insutypes[0].Insutype
  9917. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9918. } else {
  9919. for _, i := range insutypes {
  9920. if i.Insutype == "390" {
  9921. is390 = 1
  9922. }
  9923. if i.Insutype == "310" {
  9924. is310 = 1
  9925. }
  9926. }
  9927. }
  9928. if is390 == 1 {
  9929. insutype = "390"
  9930. }
  9931. if is310 == 1 {
  9932. insutype = "310"
  9933. }
  9934. if len(insutypes) == 0 {
  9935. insutype = "310"
  9936. }
  9937. service.CreateHisPsn(psn)
  9938. c.ServeSuccessJSON(map[string]interface{}{
  9939. "patient": patient,
  9940. "number": token,
  9941. "insutype": insutype,
  9942. })
  9943. }
  9944. } else {
  9945. c.ServeSuccessJSON(map[string]interface{}{
  9946. "failed_code": -10,
  9947. "msg": res.ErrMsg,
  9948. })
  9949. }
  9950. } else { //读卡失败
  9951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9952. return
  9953. }
  9954. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9955. var api string
  9956. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9957. "&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
  9958. resp, requestErr := http.Get(api)
  9959. if requestErr != nil {
  9960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9961. return
  9962. }
  9963. body, ioErr := ioutil.ReadAll(resp.Body)
  9964. if ioErr != nil {
  9965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9967. return
  9968. }
  9969. var respJSON map[string]interface{}
  9970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9973. return
  9974. }
  9975. var status string
  9976. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9977. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9978. var token string
  9979. var res ResultTwo //1101结果
  9980. if status == "1" { //读卡成功
  9981. var card_info string //卡信息
  9982. var busi_card_info string
  9983. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9984. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9985. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9986. fmt.Println(card_info)
  9987. fmt.Println(busi_card_info)
  9988. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9989. result, _ := json.Marshal(respJSON)
  9990. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9991. utils.ErrorLog("解析失败:%v", err)
  9992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9993. return
  9994. }
  9995. if res.Infcode == 0 {
  9996. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9997. if err == gorm.ErrRecordNotFound {
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9999. return
  10000. } else if err != nil {
  10001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10002. return
  10003. } else {
  10004. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10005. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10006. infoStr := string(Iinfos)
  10007. idetinfoStr := string(Idetinfos)
  10008. psn := &models.HisPsn{
  10009. PsnNo: res.Output.Baseinfo.PsnNo,
  10010. PatientId: patient.ID,
  10011. Certno: res.Output.Baseinfo.Certno,
  10012. Gend: res.Output.Baseinfo.Gend,
  10013. Naty: res.Output.Baseinfo.Naty,
  10014. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10015. PsnName: res.Output.Baseinfo.PsnName,
  10016. Idetinfo: idetinfoStr,
  10017. Insuinfo: infoStr,
  10018. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10019. CardInfo: card_info,
  10020. VerifyNumber: token,
  10021. }
  10022. var rf []*ResultFive
  10023. json.Unmarshal([]byte(infoStr), &rf)
  10024. var insutypes []*ResultFive
  10025. var insutype string
  10026. var is390 int = 0
  10027. var is310 int = 0
  10028. for _, item := range rf {
  10029. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10030. insutypes = append(insutypes, item)
  10031. }
  10032. }
  10033. if len(insutypes) == 1 {
  10034. insutype = insutypes[0].Insutype
  10035. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10036. } else {
  10037. for _, i := range insutypes {
  10038. if i.Insutype == "390" {
  10039. is390 = 1
  10040. }
  10041. if i.Insutype == "310" {
  10042. is310 = 1
  10043. }
  10044. }
  10045. }
  10046. if is390 == 1 {
  10047. insutype = "390"
  10048. }
  10049. if is310 == 1 {
  10050. insutype = "310"
  10051. }
  10052. if len(insutypes) == 0 {
  10053. insutype = "310"
  10054. }
  10055. service.CreateHisPsn(psn)
  10056. c.ServeSuccessJSON(map[string]interface{}{
  10057. "patient": patient,
  10058. "number": token,
  10059. "insutype": insutype,
  10060. })
  10061. }
  10062. } else {
  10063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10064. return
  10065. }
  10066. } else { //读卡失败
  10067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10068. return
  10069. }
  10070. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10071. idNo := c.GetString("idNo")
  10072. userName := c.GetString("userName")
  10073. ecToken := c.GetString("ecToken")
  10074. insuOrg := c.GetString("insuOrg")
  10075. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10076. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10077. var res ResultTwo
  10078. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10079. utils.ErrorLog("解析失败:%v", err)
  10080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10081. return
  10082. }
  10083. if res.Infcode == 0 {
  10084. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10085. if err == gorm.ErrRecordNotFound {
  10086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10087. return
  10088. } else if err != nil {
  10089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10090. return
  10091. } else {
  10092. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10093. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10094. infoStr := string(Iinfos)
  10095. idetinfoStr := string(Idetinfos)
  10096. psn := &models.HisPsn{
  10097. PsnNo: res.Output.Baseinfo.PsnNo,
  10098. PatientId: patient.ID,
  10099. Certno: res.Output.Baseinfo.Certno,
  10100. Gend: res.Output.Baseinfo.Gend,
  10101. Naty: res.Output.Baseinfo.Naty,
  10102. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10103. PsnName: res.Output.Baseinfo.PsnName,
  10104. Idetinfo: idetinfoStr,
  10105. Insuinfo: infoStr,
  10106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10107. CardInfo: "",
  10108. Stage: "1",
  10109. VerifyNumber: ecToken,
  10110. InsuplcAdmdvs: insuOrg,
  10111. }
  10112. service.CreateHisPsn(psn)
  10113. var rf []*ResultFive
  10114. json.Unmarshal([]byte(infoStr), &rf)
  10115. var insutypes []*ResultFive
  10116. var insutype string
  10117. var is390 int = 0
  10118. var is310 int = 0
  10119. for _, item := range rf {
  10120. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10121. insutypes = append(insutypes, item)
  10122. }
  10123. }
  10124. if len(insutypes) == 1 {
  10125. insutype = insutypes[0].Insutype
  10126. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10127. } else {
  10128. for _, i := range insutypes {
  10129. if i.Insutype == "390" {
  10130. is390 = 1
  10131. }
  10132. if i.Insutype == "310" {
  10133. is310 = 1
  10134. }
  10135. }
  10136. }
  10137. if is390 == 1 {
  10138. insutype = "390"
  10139. }
  10140. if is310 == 1 {
  10141. insutype = "310"
  10142. }
  10143. if len(insutypes) == 0 {
  10144. insutype = "310"
  10145. }
  10146. c.ServeSuccessJSON(map[string]interface{}{
  10147. "patient": patient,
  10148. "number": ecToken,
  10149. "insutype": insutype,
  10150. })
  10151. }
  10152. } else {
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10154. return
  10155. }
  10156. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10157. //if initFlag == 0 {
  10158. //c.TestGetJiangXiBasBaseInit()
  10159. //}
  10160. //if initEleFlag == 0 {
  10161. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10162. //}
  10163. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10164. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10165. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10166. type ELeData struct {
  10167. Data struct {
  10168. IdNo string `json:"idNo"`
  10169. IdType string `json:"idType"`
  10170. UserName string `json:"userName"`
  10171. EcToken string `json:"ecToken"`
  10172. InsuOrg string `json:"insuOrg"`
  10173. Gender string `json:"gender"`
  10174. Birthday string `json:"birthday"`
  10175. Nationality string `json:"nationality"`
  10176. Email string `json:"email"`
  10177. Extra string `json:"extra"`
  10178. } `json:"data"`
  10179. Code int `json:"code"`
  10180. Message string `json:"message"`
  10181. }
  10182. var ele ELeData
  10183. err := json.Unmarshal([]byte(result), &ele)
  10184. if err != nil {
  10185. utils.ErrorLog("解析失败:%v", err)
  10186. }
  10187. token := ele.Data.EcToken
  10188. token = Remove0000(token)
  10189. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  10190. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10191. var res ResultTwo
  10192. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10193. utils.ErrorLog("解析失败:%v", err)
  10194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10195. return
  10196. }
  10197. if res.Infcode == 0 {
  10198. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10199. if err == gorm.ErrRecordNotFound {
  10200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10201. return
  10202. } else if err != nil {
  10203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10204. return
  10205. } else {
  10206. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10207. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10208. infoStr := string(Iinfos)
  10209. idetinfoStr := string(Idetinfos)
  10210. psn := &models.HisPsn{
  10211. PsnNo: res.Output.Baseinfo.PsnNo,
  10212. PatientId: patient.ID,
  10213. Certno: res.Output.Baseinfo.Certno,
  10214. Gend: res.Output.Baseinfo.Gend,
  10215. Naty: res.Output.Baseinfo.Naty,
  10216. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10217. PsnName: res.Output.Baseinfo.PsnName,
  10218. Idetinfo: idetinfoStr,
  10219. Insuinfo: infoStr,
  10220. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10221. CardInfo: "",
  10222. VerifyNumber: token,
  10223. }
  10224. service.CreateHisPsn(psn)
  10225. var rf []*ResultFive
  10226. json.Unmarshal([]byte(infoStr), &rf)
  10227. var insutypes []*ResultFive
  10228. var insutype string
  10229. var is390 int = 0
  10230. var is310 int = 0
  10231. for _, item := range rf {
  10232. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10233. insutypes = append(insutypes, item)
  10234. }
  10235. }
  10236. if len(insutypes) == 1 {
  10237. insutype = insutypes[0].Insutype
  10238. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10239. } else {
  10240. for _, i := range insutypes {
  10241. if i.Insutype == "390" {
  10242. is390 = 1
  10243. }
  10244. if i.Insutype == "310" {
  10245. is310 = 1
  10246. }
  10247. }
  10248. }
  10249. if is390 == 1 {
  10250. insutype = "390"
  10251. }
  10252. if is310 == 1 {
  10253. insutype = "310"
  10254. }
  10255. if len(insutypes) == 0 {
  10256. insutype = "310"
  10257. }
  10258. c.ServeSuccessJSON(map[string]interface{}{
  10259. "patient": patient,
  10260. "number": token,
  10261. "insutype": insutype,
  10262. })
  10263. }
  10264. } else {
  10265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10266. return
  10267. }
  10268. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10269. //if initFlag == 0 {
  10270. c.TestGetJiangXiBasBaseInit()
  10271. //}
  10272. //if initEleFlag == 0 {
  10273. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10274. //}
  10275. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10276. type ELeData struct {
  10277. Data struct {
  10278. IdNo string `json:"idNo"`
  10279. IdType string `json:"idType"`
  10280. UserName string `json:"userName"`
  10281. EcToken string `json:"ecToken"`
  10282. InsuOrg string `json:"insuOrg"`
  10283. Gender string `json:"gender"`
  10284. Birthday string `json:"birthday"`
  10285. Nationality string `json:"nationality"`
  10286. Email string `json:"email"`
  10287. Extra string `json:"extra"`
  10288. } `json:"data"`
  10289. Code int `json:"code"`
  10290. Message string `json:"message"`
  10291. }
  10292. var ele ELeData
  10293. err := json.Unmarshal([]byte(json_result), &ele)
  10294. if err != nil {
  10295. utils.ErrorLog("解析失败:%v", err)
  10296. }
  10297. token := ele.Data.EcToken
  10298. token = Remove0000(token)
  10299. 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)
  10300. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10301. var res ResultTwo
  10302. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10303. utils.ErrorLog("解析失败:%v", err)
  10304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10305. return
  10306. }
  10307. if res.Infcode == 0 {
  10308. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10309. if err == gorm.ErrRecordNotFound {
  10310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10311. return
  10312. } else if err != nil {
  10313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10314. return
  10315. } else {
  10316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10317. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10318. infoStr := string(Iinfos)
  10319. idetinfoStr := string(Idetinfos)
  10320. psn := &models.HisPsn{
  10321. PsnNo: res.Output.Baseinfo.PsnNo,
  10322. PatientId: patient.ID,
  10323. Certno: res.Output.Baseinfo.Certno,
  10324. Gend: res.Output.Baseinfo.Gend,
  10325. Naty: res.Output.Baseinfo.Naty,
  10326. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10327. PsnName: res.Output.Baseinfo.PsnName,
  10328. Idetinfo: idetinfoStr,
  10329. Insuinfo: infoStr,
  10330. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10331. CardInfo: "",
  10332. VerifyNumber: token,
  10333. }
  10334. service.CreateHisPsn(psn)
  10335. var rf []*ResultFive
  10336. json.Unmarshal([]byte(infoStr), &rf)
  10337. var insutypes []*ResultFive
  10338. var insutype string
  10339. var is390 int = 0
  10340. var is310 int = 0
  10341. for _, item := range rf {
  10342. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10343. insutypes = append(insutypes, item)
  10344. }
  10345. }
  10346. if len(insutypes) == 1 {
  10347. insutype = insutypes[0].Insutype
  10348. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10349. } else {
  10350. for _, i := range insutypes {
  10351. if i.Insutype == "390" {
  10352. is390 = 1
  10353. }
  10354. if i.Insutype == "310" {
  10355. is310 = 1
  10356. }
  10357. }
  10358. }
  10359. if is390 == 1 {
  10360. insutype = "390"
  10361. }
  10362. if is310 == 1 {
  10363. insutype = "310"
  10364. }
  10365. if len(insutypes) == 0 {
  10366. insutype = "310"
  10367. }
  10368. c.ServeSuccessJSON(map[string]interface{}{
  10369. "patient": patient,
  10370. "number": token,
  10371. "insutype": insutype,
  10372. })
  10373. }
  10374. } else {
  10375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10376. return
  10377. }
  10378. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10379. type ELeData struct {
  10380. Code string `json:"code"`
  10381. Data struct {
  10382. Aac002 string `json:"aac002"`
  10383. Aaz500 string `json:"aaz500"`
  10384. ActCardNo string `json:"actCardNo"`
  10385. Bab520 string `json:"bab520"`
  10386. Bkz543 string `json:"bkz543"`
  10387. BusinessType string `json:"businessType"`
  10388. CertfCodg string `json:"certfCodg"`
  10389. EcIndexNo string `json:"ecIndexNo"`
  10390. EcToken string `json:"ecToken"`
  10391. ID0000 string `json:"id0000"`
  10392. IDNo string `json:"idNo"`
  10393. IDType string `json:"idType"`
  10394. Idcode string `json:"idcode"`
  10395. IdentityToken string `json:"identity_token"`
  10396. InsuOrg string `json:"insuOrg"`
  10397. OfficeID string `json:"officeId"`
  10398. OfficeName string `json:"officeName"`
  10399. OperatorID string `json:"operatorId"`
  10400. OperatorName string `json:"operatorName"`
  10401. OrgID string `json:"orgId"`
  10402. UserName string `json:"userName"`
  10403. } `json:"data"`
  10404. Infno interface{} `json:"infno"`
  10405. Message string `json:"message"`
  10406. OrgID string `json:"orgId"`
  10407. TransType string `json:"transType"`
  10408. }
  10409. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10410. outPutInfo = Remove0000(outPutInfo)
  10411. if len(outPutInfo) > 0 {
  10412. var ele ELeData
  10413. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10414. if err != nil {
  10415. utils.ErrorLog("解析失败:%v", err)
  10416. }
  10417. token := ele.Data.EcToken
  10418. fmt.Println(inputInfo)
  10419. fmt.Println(outPutInfo)
  10420. 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)
  10421. saveLog(result, requestLog, "1101", "获取人员信息")
  10422. var dat map[string]interface{}
  10423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10424. fmt.Println(dat)
  10425. } else {
  10426. fmt.Println(err)
  10427. }
  10428. userJSONBytes, _ := json.Marshal(dat)
  10429. var res ResultTwo
  10430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10431. utils.ErrorLog("解析失败:%v", err)
  10432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10433. return
  10434. }
  10435. res.ErrMsg = errMsgLog
  10436. if res.Infcode == 0 {
  10437. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10438. if err == gorm.ErrRecordNotFound {
  10439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10440. return
  10441. } else if err != nil {
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10443. return
  10444. } else {
  10445. fmt.Println(res)
  10446. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10447. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10448. infoStr := string(Iinfos)
  10449. idetinfoStr := string(Idetinfos)
  10450. psn := &models.HisPsn{
  10451. PsnNo: res.Output.Baseinfo.PsnNo,
  10452. PatientId: patient.ID,
  10453. Certno: res.Output.Baseinfo.Certno,
  10454. Gend: res.Output.Baseinfo.Gend,
  10455. Naty: res.Output.Baseinfo.Naty,
  10456. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10457. PsnName: res.Output.Baseinfo.PsnName,
  10458. Idetinfo: idetinfoStr,
  10459. Insuinfo: infoStr,
  10460. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10461. CardInfo: outPutInfo,
  10462. VerifyNumber: token,
  10463. InsuplcAdmdvs: ele.Data.InsuOrg,
  10464. }
  10465. service.CreateHisPsn(psn)
  10466. var rf []*ResultFive
  10467. json.Unmarshal([]byte(infoStr), &rf)
  10468. var insutypes []*ResultFive
  10469. var insutype string
  10470. var is390 int = 0
  10471. var is310 int = 0
  10472. for _, item := range rf {
  10473. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10474. insutypes = append(insutypes, item)
  10475. }
  10476. }
  10477. if len(insutypes) == 1 {
  10478. insutype = insutypes[0].Insutype
  10479. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10480. } else {
  10481. for _, i := range insutypes {
  10482. if i.Insutype == "390" {
  10483. is390 = 1
  10484. }
  10485. if i.Insutype == "310" {
  10486. is310 = 1
  10487. }
  10488. }
  10489. }
  10490. if is390 == 1 {
  10491. insutype = "390"
  10492. }
  10493. if is310 == 1 {
  10494. insutype = "310"
  10495. }
  10496. if len(insutypes) == 0 {
  10497. insutype = "310"
  10498. }
  10499. c.ServeSuccessJSON(map[string]interface{}{
  10500. "patient": patient,
  10501. "number": token,
  10502. "insutype": insutype,
  10503. })
  10504. }
  10505. } else {
  10506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10507. return
  10508. }
  10509. }
  10510. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10511. var api string
  10512. 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 +
  10513. "&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
  10514. resp, requestErr := http.Get(api)
  10515. if requestErr != nil {
  10516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10517. return
  10518. }
  10519. body, ioErr := ioutil.ReadAll(resp.Body)
  10520. if ioErr != nil {
  10521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10523. return
  10524. }
  10525. var respJSON map[string]interface{}
  10526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10529. return
  10530. }
  10531. var status string
  10532. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10533. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10534. var token string
  10535. var res ResultTwo //1101结果
  10536. var res10265 ResultTwo10265 //1101结果
  10537. if status == "0" { //读卡成功
  10538. var card_info string //卡信息
  10539. var busi_card_info string
  10540. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10541. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10542. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10543. fmt.Println(card_info)
  10544. fmt.Println(busi_card_info)
  10545. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10546. result, _ := json.Marshal(respJSON)
  10547. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10548. utils.ErrorLog("解析失败:%v", err)
  10549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10550. return
  10551. }
  10552. res.ErrMsg = res10265.ErrMsg
  10553. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10554. res.Infcode = infocode
  10555. res.Output = res10265.Output
  10556. res.InfRefmsgid = res10265.InfRefmsgid
  10557. if res.Infcode == 0 {
  10558. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10559. if err == gorm.ErrRecordNotFound {
  10560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10561. return
  10562. } else if err != nil {
  10563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10564. return
  10565. } else {
  10566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10567. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10568. infoStr := string(Iinfos)
  10569. idetinfoStr := string(Idetinfos)
  10570. psn := &models.HisPsn{
  10571. PsnNo: res.Output.Baseinfo.PsnNo,
  10572. PatientId: patient.ID,
  10573. Certno: res.Output.Baseinfo.Certno,
  10574. Gend: res.Output.Baseinfo.Gend,
  10575. Naty: res.Output.Baseinfo.Naty,
  10576. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10577. PsnName: res.Output.Baseinfo.PsnName,
  10578. Idetinfo: idetinfoStr,
  10579. Insuinfo: infoStr,
  10580. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10581. CardInfo: card_info,
  10582. VerifyNumber: token,
  10583. }
  10584. var rf []*ResultFive
  10585. json.Unmarshal([]byte(infoStr), &rf)
  10586. var insutypes []*ResultFive
  10587. var insutype string
  10588. var is390 int = 0
  10589. var is310 int = 0
  10590. for _, item := range rf {
  10591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10592. insutypes = append(insutypes, item)
  10593. }
  10594. }
  10595. if len(insutypes) == 1 {
  10596. insutype = insutypes[0].Insutype
  10597. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10598. } else {
  10599. for _, i := range insutypes {
  10600. if i.Insutype == "390" {
  10601. is390 = 1
  10602. }
  10603. if i.Insutype == "310" {
  10604. is310 = 1
  10605. }
  10606. }
  10607. }
  10608. if is390 == 1 {
  10609. insutype = "390"
  10610. }
  10611. if is310 == 1 {
  10612. insutype = "310"
  10613. }
  10614. if len(insutypes) == 0 {
  10615. insutype = "310"
  10616. }
  10617. service.CreateHisPsn(psn)
  10618. c.ServeSuccessJSON(map[string]interface{}{
  10619. "patient": patient,
  10620. "number": token,
  10621. "insutype": insutype,
  10622. })
  10623. }
  10624. } else {
  10625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10626. return
  10627. }
  10628. } else { //读卡失败
  10629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10630. return
  10631. }
  10632. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10633. res := c.GetoleInfo()
  10634. if res.Infcode == 0 {
  10635. var result string
  10636. if res.Output.MdtrtCertType == "01" {
  10637. 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)
  10638. } else if res.Output.MdtrtCertType == "02" {
  10639. 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)
  10640. } else if res.Output.MdtrtCertType == "03" {
  10641. 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)
  10642. }
  10643. var dat map[string]interface{}
  10644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10645. fmt.Println(dat)
  10646. } else {
  10647. fmt.Println(err)
  10648. }
  10649. userJSONBytes, _ := json.Marshal(dat)
  10650. var res2 ResultTwo
  10651. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10652. utils.ErrorLog("解析失败:%v", err)
  10653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10654. return
  10655. }
  10656. if res2.Infcode == 0 {
  10657. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10658. if err == gorm.ErrRecordNotFound {
  10659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10660. return
  10661. } else if err != nil {
  10662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10663. return
  10664. } else {
  10665. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10666. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10667. infoStr := string(Iinfos)
  10668. idetinfoStr := string(Idetinfos)
  10669. var rf []*ResultFive
  10670. json.Unmarshal([]byte(infoStr), &rf)
  10671. var insutypes []*ResultFive
  10672. var insutype string
  10673. var is390 int = 0
  10674. var is310 int = 0
  10675. //var insuplc_admdvs string
  10676. for _, item := range rf {
  10677. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10678. insutypes = append(insutypes, item)
  10679. }
  10680. }
  10681. if len(insutypes) == 1 {
  10682. insutype = insutypes[0].Insutype
  10683. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10684. } else {
  10685. for _, i := range insutypes {
  10686. if i.Insutype == "390" {
  10687. is390 = 1
  10688. }
  10689. if i.Insutype == "310" {
  10690. is310 = 1
  10691. }
  10692. }
  10693. }
  10694. if is390 == 1 {
  10695. insutype = "390"
  10696. }
  10697. if is310 == 1 {
  10698. insutype = "310"
  10699. }
  10700. if len(insutypes) == 0 {
  10701. insutype = "310"
  10702. }
  10703. psn := &models.HisPsn{
  10704. PsnNo: res2.Output.Baseinfo.PsnNo,
  10705. PatientId: patient.ID,
  10706. Certno: res2.Output.Baseinfo.Certno,
  10707. Gend: res2.Output.Baseinfo.Gend,
  10708. Naty: res2.Output.Baseinfo.Naty,
  10709. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10710. PsnName: res2.Output.Baseinfo.PsnName,
  10711. Idetinfo: idetinfoStr,
  10712. Insuinfo: infoStr,
  10713. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10714. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10715. VerifyNumber: res.Output.EcToken,
  10716. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10717. }
  10718. if res.Output.MdtrtCertType == "01" {
  10719. psn.VerifyNumber = res.Output.EcToken
  10720. //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)
  10721. } else if res.Output.MdtrtCertType == "02" {
  10722. psn.VerifyNumber = res.Output.CardNo
  10723. //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)
  10724. } else if res.Output.MdtrtCertType == "03" {
  10725. psn.VerifyNumber = res.Output.MdtrtCertNo
  10726. //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)
  10727. }
  10728. service.CreateHisPsn(psn)
  10729. var balc float64
  10730. for _, item := range rf {
  10731. if item.Insutype == insutype {
  10732. balc = item.Balc
  10733. }
  10734. }
  10735. c.ServeSuccessJSON(map[string]interface{}{
  10736. "patient": patient,
  10737. "number": res.Output.CardNo,
  10738. "insutype": insutype,
  10739. "blac": balc,
  10740. "desc": idetinfoStr,
  10741. })
  10742. }
  10743. } else {
  10744. c.ServeSuccessJSON(map[string]interface{}{
  10745. "failed_code": -10,
  10746. "msg": res2.ErrMsg,
  10747. })
  10748. }
  10749. } else {
  10750. c.ServeSuccessJSON(map[string]interface{}{
  10751. "failed_code": -10,
  10752. "msg": res.ErrMsg,
  10753. })
  10754. }
  10755. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10756. var res ResultTwo
  10757. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10758. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10759. "&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)
  10760. resp, requestErr := http.Get(api)
  10761. if requestErr != nil {
  10762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10763. return
  10764. }
  10765. body, ioErr := ioutil.ReadAll(resp.Body)
  10766. if ioErr != nil {
  10767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10769. return
  10770. }
  10771. var respJSON map[string]interface{}
  10772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10775. return
  10776. }
  10777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10778. result, _ := json.Marshal(respJSON)
  10779. fmt.Println("log")
  10780. fmt.Println(string(result))
  10781. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10782. utils.ErrorLog("解析失败:%v", err)
  10783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10784. return
  10785. }
  10786. if res.Infcode == 0 {
  10787. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10788. if err == gorm.ErrRecordNotFound {
  10789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10790. return
  10791. } else if err != nil {
  10792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10793. return
  10794. } else {
  10795. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10796. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10797. infoStr := string(Iinfos)
  10798. idetinfoStr := string(Idetinfos)
  10799. var rf []*ResultFive
  10800. json.Unmarshal([]byte(infoStr), &rf)
  10801. var insutypes []*ResultFive
  10802. var insutype string
  10803. var is390 int = 0
  10804. var is310 int = 0
  10805. for _, item := range rf {
  10806. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10807. insutypes = append(insutypes, item)
  10808. }
  10809. }
  10810. if len(insutypes) == 1 {
  10811. insutype = insutypes[0].Insutype
  10812. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10813. } else {
  10814. for _, i := range insutypes {
  10815. if i.Insutype == "390" {
  10816. is390 = 1
  10817. }
  10818. if i.Insutype == "310" {
  10819. is310 = 1
  10820. }
  10821. }
  10822. }
  10823. if is390 == 1 {
  10824. insutype = "390"
  10825. }
  10826. if is310 == 1 {
  10827. insutype = "310"
  10828. }
  10829. if len(insutypes) == 0 {
  10830. insutype = "390"
  10831. }
  10832. var insuplc_admdvs string
  10833. for _, item := range rf {
  10834. if item.Insutype == insutype {
  10835. insuplc_admdvs = item.InsuplcAdmdvs
  10836. }
  10837. }
  10838. psn := &models.HisPsn{
  10839. PsnNo: res.Output.Baseinfo.PsnNo,
  10840. PatientId: patient.ID,
  10841. Certno: res.Output.Baseinfo.Certno,
  10842. Gend: res.Output.Baseinfo.Gend,
  10843. Naty: res.Output.Baseinfo.Naty,
  10844. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10845. PsnName: res.Output.Baseinfo.PsnName,
  10846. Idetinfo: idetinfoStr,
  10847. Insuinfo: infoStr,
  10848. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10849. InsuplcAdmdvs: insuplc_admdvs,
  10850. }
  10851. service.CreateHisPsn(psn)
  10852. c.ServeSuccessJSON(map[string]interface{}{
  10853. "patient": patient,
  10854. "number": res.Output.Baseinfo.Certno,
  10855. })
  10856. }
  10857. } else {
  10858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10859. return
  10860. }
  10861. } else {
  10862. type ELeData struct {
  10863. Code string `json:"code"`
  10864. Data struct {
  10865. Aac002 string `json:"aac002"`
  10866. Aaz500 string `json:"aaz500"`
  10867. ActCardNo string `json:"actCardNo"`
  10868. Bab520 string `json:"bab520"`
  10869. Bkz543 string `json:"bkz543"`
  10870. BusinessType string `json:"businessType"`
  10871. CertfCodg string `json:"certfCodg"`
  10872. EcIndexNo string `json:"ecIndexNo"`
  10873. EcToken string `json:"ecToken"`
  10874. ID0000 string `json:"id0000"`
  10875. IDNo string `json:"idNo"`
  10876. IDType string `json:"idType"`
  10877. Idcode string `json:"idcode"`
  10878. IdentityToken string `json:"identity_token"`
  10879. InsuOrg string `json:"insuOrg"`
  10880. OfficeID string `json:"officeId"`
  10881. OfficeName string `json:"officeName"`
  10882. OperatorID string `json:"operatorId"`
  10883. OperatorName string `json:"operatorName"`
  10884. OrgID string `json:"orgId"`
  10885. UserName string `json:"userName"`
  10886. } `json:"data"`
  10887. Infno interface{} `json:"infno"`
  10888. Message string `json:"message"`
  10889. OrgID string `json:"orgId"`
  10890. TransType string `json:"transType"`
  10891. }
  10892. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10893. fmt.Println(result)
  10894. outPutInfo := Remove0000(result)
  10895. fmt.Println(outPutInfo)
  10896. if len(outPutInfo) > 0 {
  10897. var ele ELeData
  10898. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10899. if err != nil {
  10900. utils.ErrorLog("解析失败:%v", err)
  10901. }
  10902. token := ele.Data.EcToken
  10903. fmt.Println(outPutInfo)
  10904. 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)
  10905. saveLog(result, requestLog, "1101", "获取人员信息")
  10906. var dat map[string]interface{}
  10907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10908. fmt.Println(dat)
  10909. } else {
  10910. fmt.Println(err)
  10911. }
  10912. userJSONBytes, _ := json.Marshal(dat)
  10913. var res ResultTwo
  10914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10915. utils.ErrorLog("解析失败:%v", err)
  10916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10917. return
  10918. }
  10919. if res.Infcode == 0 {
  10920. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10921. if err == gorm.ErrRecordNotFound {
  10922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10923. return
  10924. } else if err != nil {
  10925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10926. return
  10927. } else {
  10928. fmt.Println(res)
  10929. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10930. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10931. infoStr := string(Iinfos)
  10932. idetinfoStr := string(Idetinfos)
  10933. psn := &models.HisPsn{
  10934. PsnNo: res.Output.Baseinfo.PsnNo,
  10935. PatientId: patient.ID,
  10936. Certno: res.Output.Baseinfo.Certno,
  10937. Gend: res.Output.Baseinfo.Gend,
  10938. Naty: res.Output.Baseinfo.Naty,
  10939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10940. PsnName: res.Output.Baseinfo.PsnName,
  10941. Idetinfo: idetinfoStr,
  10942. Insuinfo: infoStr,
  10943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10944. CardInfo: outPutInfo,
  10945. VerifyNumber: token,
  10946. InsuplcAdmdvs: ele.Data.InsuOrg,
  10947. }
  10948. service.CreateHisPsn(psn)
  10949. var rf []*ResultFive
  10950. json.Unmarshal([]byte(infoStr), &rf)
  10951. var insutypes []*ResultFive
  10952. var insutype string
  10953. var is390 int = 0
  10954. var is310 int = 0
  10955. for _, item := range rf {
  10956. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10957. insutypes = append(insutypes, item)
  10958. }
  10959. }
  10960. if len(insutypes) == 1 {
  10961. insutype = insutypes[0].Insutype
  10962. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10963. } else {
  10964. for _, i := range insutypes {
  10965. if i.Insutype == "390" {
  10966. is390 = 1
  10967. }
  10968. if i.Insutype == "310" {
  10969. is310 = 1
  10970. }
  10971. }
  10972. }
  10973. if is390 == 1 {
  10974. insutype = "390"
  10975. }
  10976. if is310 == 1 {
  10977. insutype = "310"
  10978. }
  10979. if len(insutypes) == 0 {
  10980. insutype = "310"
  10981. }
  10982. c.ServeSuccessJSON(map[string]interface{}{
  10983. "patient": patient,
  10984. "number": token,
  10985. "insutype": insutype,
  10986. })
  10987. }
  10988. } else {
  10989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10990. return
  10991. }
  10992. }
  10993. //fmt.Println(result)
  10994. //
  10995. //if initFlag == 0 {
  10996. // c.TestGetBasBaseInit()
  10997. //}
  10998. //token := c.GetEleBaseInfo()
  10999. //
  11000. //token = Remove0000(token)
  11001. //
  11002. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  11003. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  11004. ////
  11005. //var res ResultTwo
  11006. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11007. // utils.ErrorLog("解析失败:%v", err)
  11008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11009. // return
  11010. //}
  11011. //
  11012. //if res.Infcode == 0 {
  11013. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11014. // if err == gorm.ErrRecordNotFound {
  11015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11016. // return
  11017. // } else if err != nil {
  11018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11019. // return
  11020. //
  11021. // } else {
  11022. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11023. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11024. // infoStr := string(Iinfos)
  11025. // idetinfoStr := string(Idetinfos)
  11026. //
  11027. //
  11028. //
  11029. //
  11030. // var rf []*ResultFive
  11031. // json.Unmarshal([]byte(infoStr), &rf)
  11032. //
  11033. // var insutypes []*ResultFive
  11034. // var insutype string
  11035. // var is390 int = 0
  11036. // var is310 int = 0
  11037. // var insuplc_admdvs string
  11038. //
  11039. // for _, item := range rf {
  11040. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11041. // insutypes = append(insutypes, item)
  11042. // }
  11043. // }
  11044. //
  11045. // if len(insutypes) == 1 {
  11046. // insutype = insutypes[0].Insutype
  11047. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11048. // } else {
  11049. // for _, i := range insutypes {
  11050. // if i.Insutype == "390" {
  11051. // is390 = 1
  11052. // }
  11053. //
  11054. // if i.Insutype == "310" {
  11055. // is310 = 1
  11056. // }
  11057. // }
  11058. // }
  11059. // if is390 == 1 {
  11060. // insutype = "390"
  11061. // }
  11062. //
  11063. // if is310 == 1 {
  11064. // insutype = "310"
  11065. // }
  11066. // if len(insutypes) == 0 {
  11067. // insutype = "310"
  11068. // }
  11069. // for _, item := range rf {
  11070. // if item.Insutype == insutype {
  11071. // insuplc_admdvs = item.InsuplcAdmdvs
  11072. // }
  11073. // }
  11074. // psn := &models.HisPsn{
  11075. // PsnNo: res.Output.Baseinfo.PsnNo,
  11076. // Age: res.Output.Baseinfo.Age,
  11077. // PatientId: patient.ID,
  11078. // Certno: res.Output.Baseinfo.Certno,
  11079. // Brdy: res.Output.Baseinfo.Brdy,
  11080. // Gend: res.Output.Baseinfo.Gend,
  11081. // Naty: res.Output.Baseinfo.Naty,
  11082. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11083. // PsnName: res.Output.Baseinfo.PsnName,
  11084. // Idetinfo: idetinfoStr,
  11085. // Insuinfo: infoStr,
  11086. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11087. // CardInfo: "",
  11088. // VerifyNumber: token,
  11089. // InsuplcAdmdvs: insuplc_admdvs,
  11090. // }
  11091. // service.CreateHisPsn(psn)
  11092. //
  11093. // c.ServeSuccessJSON(map[string]interface{}{
  11094. // "patient": patient,
  11095. // "number": token,
  11096. // })
  11097. // }
  11098. //} else {
  11099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11100. // return
  11101. //}
  11102. }
  11103. break
  11104. case 5:
  11105. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11106. var api string
  11107. if miConfig.MdtrtareaAdmvs == "320921" {
  11108. 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 +
  11109. "&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
  11110. fmt.Println(api)
  11111. } else {
  11112. 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 +
  11113. "&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)
  11114. }
  11115. resp, requestErr := http.Get(api)
  11116. if requestErr != nil {
  11117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11118. return
  11119. }
  11120. body, ioErr := ioutil.ReadAll(resp.Body)
  11121. if ioErr != nil {
  11122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11124. return
  11125. }
  11126. var respJSON map[string]interface{}
  11127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11130. return
  11131. }
  11132. var status string
  11133. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11134. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11135. var token string
  11136. var res ResultTwo //1101结果
  11137. var res10265 ResultTwo10265 //1101结果
  11138. if status == "0" { //读卡成功
  11139. var card_info string //卡信息
  11140. //var busi_card_info string
  11141. var auth_info string
  11142. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11143. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11144. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11145. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  11146. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11147. result, _ := json.Marshal(respJSON)
  11148. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11149. utils.ErrorLog("解析失败:%v", err)
  11150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11151. return
  11152. }
  11153. res.ErrMsg = res10265.ErrMsg
  11154. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11155. res.Infcode = infocode
  11156. res.Output = res10265.Output
  11157. res.InfRefmsgid = res10265.InfRefmsgid
  11158. if res.Infcode == 0 {
  11159. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11160. if err == gorm.ErrRecordNotFound {
  11161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11162. return
  11163. } else if err != nil {
  11164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11165. return
  11166. } else {
  11167. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11168. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11169. infoStr := string(Iinfos)
  11170. idetinfoStr := string(Idetinfos)
  11171. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11172. psn := &models.HisPsn{
  11173. PsnNo: res.Output.Baseinfo.PsnNo,
  11174. PatientId: patient.ID,
  11175. Certno: res.Output.Baseinfo.Certno,
  11176. Gend: res.Output.Baseinfo.Gend,
  11177. Brdy: b,
  11178. Age: float64(age),
  11179. Naty: res.Output.Baseinfo.Naty,
  11180. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11181. PsnName: res.Output.Baseinfo.PsnName,
  11182. Idetinfo: idetinfoStr,
  11183. Insuinfo: infoStr,
  11184. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11185. CardInfo: card_info,
  11186. VerifyNumber: token,
  11187. AuthInfo: auth_info,
  11188. }
  11189. var rf []*ResultFive
  11190. json.Unmarshal([]byte(infoStr), &rf)
  11191. var insutypes []*ResultFive
  11192. var insutype string
  11193. var is390 int = 0
  11194. var is310 int = 0
  11195. for _, item := range rf {
  11196. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11197. insutypes = append(insutypes, item)
  11198. }
  11199. }
  11200. if len(insutypes) == 1 {
  11201. insutype = insutypes[0].Insutype
  11202. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11203. } else {
  11204. for _, i := range insutypes {
  11205. if i.Insutype == "390" {
  11206. is390 = 1
  11207. }
  11208. if i.Insutype == "310" {
  11209. is310 = 1
  11210. }
  11211. }
  11212. }
  11213. if is390 == 1 {
  11214. insutype = "390"
  11215. }
  11216. if is310 == 1 {
  11217. insutype = "310"
  11218. }
  11219. if len(insutypes) == 0 {
  11220. insutype = "310"
  11221. }
  11222. service.CreateHisPsn(psn)
  11223. c.ServeSuccessJSON(map[string]interface{}{
  11224. "patient": patient,
  11225. "number": token,
  11226. "insutype": insutype,
  11227. })
  11228. }
  11229. } else {
  11230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11231. return
  11232. }
  11233. } else { //读卡失败
  11234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11235. return
  11236. }
  11237. }
  11238. break
  11239. }
  11240. }
  11241. var initFlag int64 = 0
  11242. var initEleFlag int64 = 0
  11243. func (c *HisApiController) TestGetBasBaseInit() {
  11244. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11245. Iinit := DllDef.MustFindProc("Init")
  11246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11247. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11248. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11249. if ret != 0 {
  11250. fmt.Println("SSCard的报错原因:", err)
  11251. fmt.Println("SSCard的运算结果为:", ret)
  11252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11253. return
  11254. }
  11255. result := int(ret)
  11256. fmt.Println("SSCard的运算结果为1:", result)
  11257. initFlag = 1
  11258. return
  11259. }
  11260. func (c *HisApiController) HandleJiangXiReadCard() {
  11261. fmt.Println("~~~~~~")
  11262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11263. admin_user_id, _ := c.GetInt64("admin_user_id")
  11264. id_card_type, _ := c.GetInt64("id_card_type")
  11265. //certificates, _ := c.GetInt64("certificates")
  11266. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11267. if initFlag == 0 {
  11268. c.TestGetJiangXiBasBaseInit()
  11269. }
  11270. basStr := c.GetBasBaseInfo()
  11271. if len(basStr) == 0 {
  11272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11273. return
  11274. }
  11275. fmt.Println(basStr)
  11276. bas := strings.Split(basStr, "|")
  11277. basNumber := bas[1]
  11278. fmt.Println(basNumber)
  11279. card_sn := bas[3]
  11280. fmt.Println(card_sn)
  11281. 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, "")
  11282. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11283. var dat map[string]interface{}
  11284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11285. fmt.Println(dat)
  11286. } else {
  11287. fmt.Println(err)
  11288. }
  11289. userJSONBytes, _ := json.Marshal(dat)
  11290. var res ResultTwo
  11291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11292. utils.ErrorLog("解析失败:%v", err)
  11293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11294. return
  11295. }
  11296. if res.Infcode == 0 {
  11297. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11298. if err == gorm.ErrRecordNotFound {
  11299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11300. return
  11301. } else if err != nil {
  11302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11303. return
  11304. } else {
  11305. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11306. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11307. infoStr := string(Iinfos)
  11308. idetinfoStr := string(Idetinfos)
  11309. psn := &models.HisPsn{
  11310. PsnNo: res.Output.Baseinfo.PsnNo,
  11311. PatientId: patient.ID,
  11312. Certno: res.Output.Baseinfo.Certno,
  11313. Gend: res.Output.Baseinfo.Gend,
  11314. Naty: res.Output.Baseinfo.Naty,
  11315. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11316. PsnName: res.Output.Baseinfo.PsnName,
  11317. Idetinfo: idetinfoStr,
  11318. Insuinfo: infoStr,
  11319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11320. CardInfo: basStr,
  11321. VerifyNumber: "",
  11322. }
  11323. service.CreateHisPsn(psn)
  11324. c.ServeSuccessJSON(map[string]interface{}{
  11325. "patient": patient,
  11326. "number": basNumber,
  11327. })
  11328. }
  11329. } else {
  11330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11331. return
  11332. }
  11333. }
  11334. func (c *HisApiController) TestGetHnBasBaseInit() {
  11335. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11336. Iinit := DllDef.MustFindProc("Init")
  11337. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11338. //http://10.77.211.236/CSB/hsa-fsi-1303
  11339. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11340. if ret != 0 {
  11341. fmt.Println("SSCard的报错原因:", err)
  11342. fmt.Println("SSCard的运算结果为:", ret)
  11343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11344. return
  11345. }
  11346. result := int(ret)
  11347. fmt.Println("SSCard的运算结果为1:", result)
  11348. initFlag = 1
  11349. return
  11350. }
  11351. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11352. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11353. Iinit := DllDef.MustFindProc("Init")
  11354. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11355. //http://10.77.211.236/CSB/hsa-fsi-1303
  11356. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11357. if ret != 0 {
  11358. fmt.Println("SSCard的报错原因:", err)
  11359. fmt.Println("SSCard的运算结果为:", ret)
  11360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11361. return
  11362. }
  11363. result := int(ret)
  11364. fmt.Println("SSCard的运算结果为1:", result)
  11365. initFlag = 1
  11366. return
  11367. }
  11368. func (c *HisApiController) GetSFZBaseInfo() string {
  11369. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11370. readCard := DllDef.MustFindProc("ReadSFZ")
  11371. if readCard == nil {
  11372. fmt.Println("readcard is nil")
  11373. readCard = DllDef.MustFindProc("ReadSFZ")
  11374. }
  11375. str := make([]byte, 8096)
  11376. str1 := make([]byte, 8096)
  11377. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11378. fmt.Println(r)
  11379. return Remove0000(string(str))
  11380. }
  11381. func (c *HisApiController) GetEleBaseInfo() string {
  11382. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11383. readCard := DllDef.MustFindProc("GetQRBase")
  11384. fmt.Println(readCard)
  11385. if readCard == nil {
  11386. fmt.Println("readcard is nil")
  11387. readCard = DllDef.MustFindProc("GetQRBase")
  11388. }
  11389. str := make([]byte, 1024)
  11390. str1 := make([]byte, 1024)
  11391. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11392. fmt.Println(ret2)
  11393. fmt.Println(string(str1))
  11394. fmt.Println(string(str))
  11395. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11396. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11397. if ret2 != 0 {
  11398. return ""
  11399. }
  11400. return string(str)
  11401. }
  11402. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11403. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11404. readCard := DllDef.MustFindProc("NationEcTrans")
  11405. fmt.Println(readCard)
  11406. fmt.Println("!!!!!")
  11407. pBusiCardInfo := make([]byte, 2048)
  11408. input := make(map[string]interface{})
  11409. inputData := make(map[string]interface{})
  11410. inputData["orgId"] = code
  11411. inputData["businessType"] = "01101"
  11412. inputData["operatorId"] = "1"
  11413. inputData["operatorName"] = "admin"
  11414. inputData["officeId"] = "001"
  11415. inputData["officeName"] = "血透室"
  11416. inputData["deviceType"] = ""
  11417. input["data"] = inputData
  11418. input["orgId"] = code
  11419. input["transType"] = "ec.query"
  11420. bytesData, _ := json.Marshal(input)
  11421. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11422. fmt.Println(ret2)
  11423. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11424. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11425. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11426. }
  11427. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11428. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11429. readCard := DllDef.MustFindProc("NationEcTrans")
  11430. fmt.Println(readCard)
  11431. fmt.Println("!!!!!")
  11432. pBusiCardInfo := make([]byte, 2048)
  11433. input := make(map[string]interface{})
  11434. inputData := make(map[string]interface{})
  11435. inputData["orgId"] = code
  11436. inputData["businessType"] = "01101"
  11437. inputData["operatorId"] = "9"
  11438. inputData["operatorName"] = "admin"
  11439. inputData["officeId"] = "001"
  11440. inputData["officeName"] = "血透室"
  11441. inputData["deviceType"] = ""
  11442. input["data"] = inputData
  11443. input["orgId"] = code
  11444. input["transType"] = "ec.query"
  11445. bytesData, _ := json.Marshal(input)
  11446. 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])))
  11447. fmt.Println(ret2)
  11448. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11449. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11450. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11451. }
  11452. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11453. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11454. readCard := DllDef.MustFindProc("NationEcTrans")
  11455. fmt.Println(readCard)
  11456. fmt.Println("!!!!!")
  11457. pBusiCardInfo := make([]byte, 2048)
  11458. input := make(map[string]interface{})
  11459. inputData := make(map[string]interface{})
  11460. inputData["orgId"] = code
  11461. inputData["businessType"] = "01301"
  11462. inputData["operatorId"] = "9"
  11463. inputData["operatorName"] = "admin"
  11464. inputData["officeId"] = "001"
  11465. inputData["officeName"] = "血透室"
  11466. inputData["deviceType"] = ""
  11467. input["data"] = inputData
  11468. input["orgId"] = code
  11469. input["transType"] = "ec.query"
  11470. bytesData, _ := json.Marshal(input)
  11471. 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])))
  11472. fmt.Println(ret2)
  11473. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11474. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11475. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11476. }
  11477. func GetJxEleBaseInfo(org_id int64) string {
  11478. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11479. readCard := DllDef.MustFindProc("NationEcTrans")
  11480. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11481. if readCard == nil {
  11482. fmt.Println("readcard is nil")
  11483. readCard = DllDef.MustFindProc("NationEcTrans")
  11484. }
  11485. str1 := make([]byte, 1024)
  11486. data := make(map[string]interface{})
  11487. inputData := make(map[string]interface{})
  11488. inputData["orgId"] = miConfig.Code
  11489. inputData["businessType"] = "01101"
  11490. inputData["operatorId"] = "test001"
  11491. inputData["operatorName"] = "cn"
  11492. inputData["officeId"] = "32760"
  11493. inputData["officeName"] = "waike"
  11494. inputData["deviceType"] = ""
  11495. data["data"] = inputData
  11496. data["transType"] = "ec.query"
  11497. data["extra "] = ""
  11498. data["orgId"] = miConfig.Code
  11499. bytesData, _ := json.Marshal(data)
  11500. //bytesData, _ := json.Marshal(data)
  11501. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11502. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11503. fmt.Println(ret2)
  11504. fmt.Println(string(str1))
  11505. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11506. if ret2 != 0 {
  11507. return ""
  11508. }
  11509. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11510. }
  11511. func GetJxEleBaseInitInfo(org_id int64) string {
  11512. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11513. readCard := DllDef.MustFindProc("NationEcTrans")
  11514. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11515. if readCard == nil {
  11516. fmt.Println("readcard is nil")
  11517. readCard = DllDef.MustFindProc("NationEcTrans")
  11518. }
  11519. str1 := make([]byte, 2048)
  11520. data := make(map[string]interface{})
  11521. inputData := make(map[string]interface{})
  11522. inputData["orgId"] = miConfig.Code
  11523. inputData["businessType"] = "01101"
  11524. inputData["operatorId"] = "1"
  11525. inputData["operatorName"] = "huangchuang"
  11526. inputData["officeId"] = "101"
  11527. inputData["officeName"] = "xuetou"
  11528. inputData["deviceType"] = ""
  11529. data["data"] = inputData
  11530. data["transType"] = "ec.query"
  11531. data["orgId"] = miConfig.Code
  11532. bytesData, _ := json.Marshal(data)
  11533. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11534. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11535. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11536. fmt.Println(ret2)
  11537. fmt.Println(string(str1))
  11538. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11539. if ret2 != 0 {
  11540. return ""
  11541. }
  11542. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11543. initEleFlag = 1
  11544. }
  11545. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11546. }
  11547. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11548. // // 构建命令
  11549. // cmd := exec.Command("python", "b.py")
  11550. //
  11551. // // 执行命令并等待完成
  11552. // output, err := cmd.CombinedOutput()
  11553. // if err != nil {
  11554. // fmt.Println("Error executing Python script:", err)
  11555. // return
  11556. // }
  11557. //
  11558. // // 打印Python脚本的输出
  11559. // fmt.Println(string(output))
  11560. //}
  11561. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11562. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11563. readCard := DllDef.MustFindProc("gxyb_call")
  11564. if readCard == nil {
  11565. fmt.Println("readcard is nil")
  11566. readCard = DllDef.MustFindProc("gxyb_call")
  11567. }
  11568. str := make([]byte, 1024)
  11569. str1 := make([]byte, 1024)
  11570. //data := make(map[string]interface{})
  11571. currentTime := time.Now()
  11572. // 格式化时间为 "YYYYMMDDHH24MISS"
  11573. formattedTime := currentTime.Format("20060102150405")
  11574. inputData := make(map[string]interface{})
  11575. inputData2 := make(map[string]interface{})
  11576. inputData["transNo"] = "1401"
  11577. inputData["transType"] = "passwordCheck"
  11578. inputData["timestamp"] = formattedTime
  11579. inputData2["fixmedinsCode"] = code
  11580. inputData2["psnNo"] = ""
  11581. inputData["data"] = inputData2
  11582. jsonBytes, err := json.Marshal(inputData)
  11583. if err != nil {
  11584. fmt.Println("Error encoding map to JSON:", err)
  11585. }
  11586. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11587. fmt.Println(string(str1))
  11588. fmt.Println(string(str))
  11589. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11590. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11591. if ret2 != 0 {
  11592. return ""
  11593. }
  11594. return string(str)
  11595. }
  11596. func (c *HisApiController) GetoleInfo() Response {
  11597. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11598. defer ole.CoUninitialize()
  11599. // Replace with the ProgID or CLSID of your COM object
  11600. progID := "YinHai.XJ.Actual.Interface.New"
  11601. // Create COM object
  11602. unknown, err := oleutil.CreateObject(progID)
  11603. if err != nil {
  11604. fmt.Println("Unable to create COM object:", err)
  11605. }
  11606. defer unknown.Release()
  11607. // Query for the IDispatch interface
  11608. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11609. if err != nil {
  11610. fmt.Println("Unable to get IDispatch interface:", err)
  11611. }
  11612. defer dispatch.Release()
  11613. // Prepare parameters
  11614. transNo := "1401"
  11615. transType := "passwordCheck"
  11616. timestamp := time.Now().Unix()
  11617. fixmedinsCode := "H45072101171"
  11618. psnNo := ""
  11619. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11620. result2 := ""
  11621. // Call COM object's method using the IDispatch interface
  11622. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11623. fmt.Println(resulr)
  11624. fmt.Println(result2)
  11625. if err != nil {
  11626. fmt.Println("调用COM对象方法失败:", err)
  11627. }
  11628. var response Response
  11629. err2 := json.Unmarshal([]byte(result2), &response)
  11630. if err2 != nil {
  11631. fmt.Println("解析JSON失败:", err)
  11632. }
  11633. return response
  11634. }
  11635. func (c *HisApiController) GetBasBaseInfo() string {
  11636. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11637. readCard := DllDef.MustFindProc("ReadCardBas")
  11638. if readCard == nil {
  11639. fmt.Println("readcard is nil")
  11640. readCard = DllDef.MustFindProc("ReadCardBas")
  11641. }
  11642. str := make([]byte, 1024)
  11643. str1 := make([]byte, 1024)
  11644. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11645. fmt.Println(string(str1))
  11646. fmt.Println(string(str))
  11647. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11648. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11649. if ret2 != 0 {
  11650. return ""
  11651. }
  11652. return string(str)
  11653. }
  11654. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11655. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11656. readCard := DllDef.MustFindProc("read_cardinfo")
  11657. if readCard == nil {
  11658. fmt.Println("readcard is nil")
  11659. readCard = DllDef.MustFindProc("read_cardinfo")
  11660. }
  11661. str := make([]byte, 1024) //卡号
  11662. str1 := make([]byte, 1024) //卡识别码
  11663. str2 := make([]byte, 1024) //身份证号
  11664. str3 := make([]byte, 1024) //姓名
  11665. str4 := make([]byte, 1024) //错误信息
  11666. 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])))
  11667. fmt.Println(string(str1))
  11668. fmt.Println(string(str))
  11669. fmt.Println(string(str2))
  11670. fmt.Println(string(str3))
  11671. fmt.Println(string(str4))
  11672. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11673. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11674. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11675. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11676. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11677. if ret2 != 0 {
  11678. return "", "", "", "", ""
  11679. }
  11680. return string(str), string(str1), string(str2), string(str3), string(str4)
  11681. }
  11682. type CustomFundPay struct {
  11683. FundPayType string `json:"fund_pay_type"`
  11684. FundPayamt float64 `json:"fund_payamt"`
  11685. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11686. }
  11687. //func (c *HisApiController) GetBatchSettleList() {
  11688. // start_time_str := c.GetString("start_time")
  11689. // //end_time_str := c.GetString("end_time")
  11690. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11691. //
  11692. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11693. //
  11694. // for _, item := range orders {
  11695. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11696. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11697. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11698. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11699. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11700. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11701. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11702. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11703. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11704. //
  11705. // if order.ID == 0 {
  11706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11707. // return
  11708. // }
  11709. //
  11710. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11711. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11712. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11713. // //fmt.Println(count)
  11714. // //var zero string
  11715. // //number := count + 1
  11716. // //if number >= 1000 {
  11717. // // zero = "0000" + strconv.FormatInt(number, 10)
  11718. // //} else if number >= 10000 {
  11719. // // zero = "000" + strconv.FormatInt(number, 10)
  11720. // //} else if number >= 100000 {
  11721. // // zero = "00" + strconv.FormatInt(number, 10)
  11722. // //} else if number >= 1000000 {
  11723. // // zero = "0" + strconv.FormatInt(number, 10)
  11724. // //} else {
  11725. // // zero = strconv.FormatInt(number, 10)
  11726. // //}
  11727. // //fmt.Println(zero)
  11728. //
  11729. // struct4101 := service.Struct4101{
  11730. // PsnNo: order.PsnNo,
  11731. // MdtrtId: order.MdtrtId,
  11732. // SetlId: order.SetlId,
  11733. // PsnName: order.PsnName,
  11734. // Gend: order.Gend,
  11735. // Brdy: his.Brdy,
  11736. // Age: his.Age,
  11737. // Naty: order.Naty,
  11738. // PatnCertType: "01",
  11739. // Certno: order.Certno,
  11740. // Prfs: "90",
  11741. // ConerName: roles[0].UserName,
  11742. // PatnRlts: "99",
  11743. // ConerAddr: miConfig.OrgName,
  11744. // ConerTel: admin.Mobile,
  11745. // HiType: order.Insutype,
  11746. // Insuplc: miConfig.InsuplcAdmdvs,
  11747. // MaindiagFlag: "1",
  11748. // BillCode: order.SetlId,
  11749. // BillNo: order.SetlId,
  11750. // BizSn: order.Number,
  11751. // PsnSelfPay: order.PsnPartAmt,
  11752. // PsnOwnPay: order.PsnPartAmt,
  11753. // AcctPay: order.AcctPay,
  11754. // PsnCashpay: order.PsnCashPay,
  11755. // HiPaymtd: "1",
  11756. // Hsorg: miConfig.InsuplcAdmdvs,
  11757. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11758. // MedinsFillPsn: curRoles.UserName,
  11759. // MedinsFillDept: miConfig.OrgName,
  11760. // IptMedType: "2",
  11761. // }
  11762. // struct4101.SetlBegnDate = order.SetlTime
  11763. // struct4101.SetlEndDate = order.SetlTime
  11764. // time_arr := strings.Split(order.SetlTime, " ")
  11765. // struct4101.AdmTime = time_arr[0]
  11766. // struct4101.AdmEndTime = time_arr[0]
  11767. //
  11768. // var rf []CustomFundPay
  11769. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11770. //
  11771. // var tempFunPays []service.CustomStruct
  11772. // for _, item := range rf {
  11773. // var tempFunPay service.CustomStruct
  11774. // tempFunPay.FundPayamt = item.FundPayamt
  11775. // tempFunPay.FundPayType = item.FundPayType
  11776. // tempFunPays = append(tempFunPays, tempFunPay)
  11777. // }
  11778. // struct4101.CustomStruct = tempFunPays
  11779. //
  11780. // var tempDiaginfos []service.DiaginfoStructTwo
  11781. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11782. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11783. //
  11784. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11785. // var config []*models.HisXtDiagnoseConfig
  11786. // for _, item := range diagnosis_ids {
  11787. // id, _ := strconv.ParseInt(item, 10, 64)
  11788. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11789. // config = append(config, &diagnosisConfig)
  11790. // }
  11791. //
  11792. // for index, item := range config {
  11793. // if index == 0 {
  11794. // var tempDiaginfo service.DiaginfoStructTwo
  11795. // tempDiaginfo.DiagCode = item.CountryCode
  11796. // tempDiaginfo.DiagName = item.CountryContentName
  11797. // tempDiaginfo.DiagType = "1"
  11798. // tempDiaginfo.MaindiagFlag = "1"
  11799. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11800. // } else {
  11801. // var tempDiaginfo service.DiaginfoStructTwo
  11802. // tempDiaginfo.DiagCode = item.CountryCode
  11803. // tempDiaginfo.DiagName = item.CountryContentName
  11804. // tempDiaginfo.DiagType = "1"
  11805. // tempDiaginfo.MaindiagFlag = "0"
  11806. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11807. // }
  11808. // }
  11809. // struct4101.Diseinfo = tempDiaginfos
  11810. //
  11811. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11812. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11813. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11814. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11815. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11816. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11817. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11818. //
  11819. // var iteminfo service.IteminfoStruct
  11820. //
  11821. // var bedCostTotal float64 = 0 //床位总费
  11822. // var bedCostSelfTotal float64 = 0 //床位自费
  11823. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11824. //
  11825. // var operationCostTotal float64 = 0 //手术费
  11826. // var operationCostSelfTotal float64 = 0 //手术费
  11827. // var operationCostPartSelfTotal float64 = 0 //手术费
  11828. //
  11829. // var otherCostTotal float64 = 0 //其他费用
  11830. // var otherCostSelfTotal float64 = 0 //其他费用
  11831. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11832. //
  11833. // var materialCostTotal float64 = 0 //材料费
  11834. // var materialCostSelfTotal float64 = 0 //材料费
  11835. // var materialCostPartSelfTotal float64 = 0 //材料费
  11836. //
  11837. // var westernMedicineCostTotal float64 = 0 //西药费
  11838. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11839. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11840. //
  11841. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11842. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11843. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11844. //
  11845. // var checkCostTotal float64 = 0 //检查费
  11846. // var checkCostSelfTotal float64 = 0 //检查费
  11847. // var checkCostPartSelfTotal float64 = 0 //检查费
  11848. //
  11849. // var laboratoryCostTotal float64 = 0 //化验费
  11850. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11851. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11852. //
  11853. // var treatCostTotal float64 = 0 //治疗费用
  11854. // var treatCostSelfTotal float64 = 0 //治疗费用
  11855. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11856. //
  11857. // decimal.DivisionPrecision = 2
  11858. //
  11859. // var bed_fulamt_ownpay_amt float64 = 0
  11860. // var operation_fulamt_ownpay_amt float64 = 0
  11861. // var other_fulamt_ownpay_amt float64 = 0
  11862. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11863. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11864. // var check_fulamt_ownpay_amt float64 = 0
  11865. // var material_fulamt_ownpay_amt float64 = 0
  11866. // var laboratory_fulamt_ownpay_amt float64 = 0
  11867. // var treat_fulamt_ownpay_amt float64 = 0
  11868. //
  11869. // var bed_claa_sunmfee float64 = 0
  11870. // var bed_clab_amt float64 = 0
  11871. // var bed_other_amt float64 = 0
  11872. //
  11873. // var operation_claa_sunmfee float64 = 0
  11874. // var operation_clab_amt float64 = 0
  11875. // var operation_other_amt float64 = 0
  11876. //
  11877. // var other_claa_sunmfee float64 = 0
  11878. // var other_clab_amt float64 = 0
  11879. // var other_other_amt float64 = 0
  11880. //
  11881. // var westernMedicine_claa_sunmfee float64 = 0
  11882. // var westernMedicine_clab_amt float64 = 0
  11883. // var westernMedicine_other_amt float64 = 0
  11884. //
  11885. // var chineseTraditional_claa_sunmfee float64 = 0
  11886. // var chineseTraditional_clab_amt float64 = 0
  11887. // var chineseTraditional_other_amt float64 = 0
  11888. //
  11889. // var check_claa_sunmfee float64 = 0
  11890. // var check_clab_amt float64 = 0
  11891. // var check_other_amt float64 = 0
  11892. //
  11893. // var material_claa_sunmfee float64 = 0
  11894. // var material_clab_amt float64 = 0
  11895. // var material_other_amt float64 = 0
  11896. //
  11897. // var laboratory_claa_sunmfee float64 = 0
  11898. // var laboratory_clab_amt float64 = 0
  11899. // var laboratory_other_amt float64 = 0
  11900. //
  11901. // var treat_claa_sunmfee float64 = 0
  11902. // var treat_clab_amt float64 = 0
  11903. // var treat_other_amt float64 = 0
  11904. //
  11905. // for _, item := range order.HisOrderInfo {
  11906. // if item.MedChrgitmType == "01" { //床位费
  11907. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11908. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11909. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11910. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11911. // if item.ChrgitmLv == "1" {
  11912. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11913. // }
  11914. // if item.ChrgitmLv == "2" {
  11915. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11916. //
  11917. // }
  11918. // if item.ChrgitmLv == "3" {
  11919. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11920. // }
  11921. //
  11922. // }
  11923. //
  11924. // if item.MedChrgitmType == "03" { //检查费
  11925. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11926. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11927. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11928. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11929. // if item.ChrgitmLv == "1" {
  11930. //
  11931. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11932. //
  11933. // }
  11934. // if item.ChrgitmLv == "2" {
  11935. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11936. //
  11937. // }
  11938. // if item.ChrgitmLv == "3" {
  11939. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11940. // }
  11941. // }
  11942. //
  11943. // if item.MedChrgitmType == "04" { //化验费
  11944. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11945. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11946. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11947. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11948. // if item.ChrgitmLv == "1" {
  11949. //
  11950. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11951. //
  11952. // }
  11953. // if item.ChrgitmLv == "2" {
  11954. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11955. //
  11956. // }
  11957. // if item.ChrgitmLv == "3" {
  11958. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11959. // }
  11960. // }
  11961. //
  11962. // if item.MedChrgitmType == "05" { //治疗费
  11963. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11964. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11965. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11966. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11967. // if item.ChrgitmLv == "1" {
  11968. //
  11969. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11970. //
  11971. // }
  11972. // if item.ChrgitmLv == "2" {
  11973. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11974. //
  11975. // }
  11976. // if item.ChrgitmLv == "3" {
  11977. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11978. // }
  11979. // }
  11980. //
  11981. // if item.MedChrgitmType == "06" { //手术费
  11982. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11983. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11984. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11985. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11986. //
  11987. // if item.ChrgitmLv == "1" {
  11988. //
  11989. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11990. //
  11991. // }
  11992. // if item.ChrgitmLv == "2" {
  11993. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11994. //
  11995. // }
  11996. // if item.ChrgitmLv == "3" {
  11997. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11998. // }
  11999. // }
  12000. //
  12001. // if item.MedChrgitmType == "08" { //材料费
  12002. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12003. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12004. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12005. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12006. // if item.ChrgitmLv == "1" {
  12007. //
  12008. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12009. //
  12010. // }
  12011. // if item.ChrgitmLv == "2" {
  12012. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12013. //
  12014. // }
  12015. // if item.ChrgitmLv == "3" {
  12016. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12017. // }
  12018. // }
  12019. //
  12020. // if item.MedChrgitmType == "09" { //西药费
  12021. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12022. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12023. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12024. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12025. // if item.ChrgitmLv == "1" {
  12026. //
  12027. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12028. //
  12029. // }
  12030. // if item.ChrgitmLv == "2" {
  12031. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12032. //
  12033. // }
  12034. // if item.ChrgitmLv == "3" {
  12035. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12036. // }
  12037. // }
  12038. //
  12039. // if item.MedChrgitmType == "11" { //中成费
  12040. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12041. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12042. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12043. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12044. // if item.ChrgitmLv == "1" {
  12045. //
  12046. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12047. //
  12048. // }
  12049. // if item.ChrgitmLv == "2" {
  12050. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12051. //
  12052. // }
  12053. // if item.ChrgitmLv == "3" {
  12054. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12055. // }
  12056. // }
  12057. //
  12058. // if item.MedChrgitmType == "14" { //其他费
  12059. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12060. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12061. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12062. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12063. // if item.ChrgitmLv == "1" {
  12064. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12065. //
  12066. // }
  12067. // if item.ChrgitmLv == "2" {
  12068. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12069. //
  12070. // }
  12071. // if item.ChrgitmLv == "3" {
  12072. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12073. // }
  12074. // }
  12075. //
  12076. // }
  12077. //
  12078. // var iteminfoStructs []service.IteminfoStruct
  12079. //
  12080. // if bedCostTotal != 0 {
  12081. // iteminfo.MedChrgitm = "01"
  12082. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12083. // iteminfo.Amt = bedCostTotal
  12084. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  12085. // iteminfo.ClabAmt = bed_clab_amt
  12086. // iteminfo.OthAmt = bed_other_amt
  12087. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12088. // }
  12089. //
  12090. // if checkCostTotal != 0 {
  12091. // iteminfo.MedChrgitm = "03"
  12092. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12093. // iteminfo.Amt = checkCostTotal
  12094. // iteminfo.ClaaSumfee = check_claa_sunmfee
  12095. // iteminfo.ClabAmt = check_clab_amt
  12096. // iteminfo.OthAmt = check_other_amt
  12097. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12098. //
  12099. // }
  12100. //
  12101. // if laboratoryCostTotal != 0 {
  12102. // iteminfo.MedChrgitm = "04"
  12103. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12104. // iteminfo.Amt = laboratoryCostTotal
  12105. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12106. // iteminfo.ClabAmt = laboratory_clab_amt
  12107. // iteminfo.OthAmt = laboratory_other_amt
  12108. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12109. //
  12110. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12111. //
  12112. // }
  12113. //
  12114. // if treatCostTotal != 0 {
  12115. // iteminfo.MedChrgitm = "05"
  12116. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12117. // iteminfo.Amt = treatCostTotal
  12118. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  12119. // iteminfo.ClabAmt = treat_clab_amt
  12120. // iteminfo.OthAmt = treat_other_amt
  12121. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12122. // //(struct4101.IteminfoStruct, iteminfo)
  12123. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12124. // }
  12125. //
  12126. // if operationCostTotal != 0 {
  12127. // iteminfo.MedChrgitm = "06"
  12128. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12129. // iteminfo.Amt = operationCostTotal
  12130. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  12131. // iteminfo.ClabAmt = operation_clab_amt
  12132. // iteminfo.OthAmt = operation_other_amt
  12133. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12134. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12135. // }
  12136. //
  12137. // if materialCostTotal != 0 {
  12138. // iteminfo.MedChrgitm = "08"
  12139. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12140. // iteminfo.Amt = materialCostTotal
  12141. // iteminfo.ClaaSumfee = material_claa_sunmfee
  12142. // iteminfo.ClabAmt = material_clab_amt
  12143. // iteminfo.OthAmt = material_other_amt
  12144. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12145. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12146. // }
  12147. //
  12148. // if westernMedicineCostTotal != 0 {
  12149. // iteminfo.MedChrgitm = "09"
  12150. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12151. // iteminfo.Amt = westernMedicineCostTotal
  12152. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12153. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12154. // iteminfo.OthAmt = westernMedicine_other_amt
  12155. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12156. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12157. //
  12158. // }
  12159. // if chineseTraditionalMedicineCostTotal != 0 {
  12160. // iteminfo.MedChrgitm = "11"
  12161. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12162. // iteminfo.Amt = westernMedicineCostTotal
  12163. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12164. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12165. // iteminfo.OthAmt = westernMedicine_other_amt
  12166. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12167. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12168. //
  12169. // }
  12170. // if otherCostTotal != 0 {
  12171. // iteminfo.MedChrgitm = "14"
  12172. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12173. // iteminfo.Amt = otherCostTotal
  12174. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12175. // iteminfo.ClabAmt = other_clab_amt
  12176. // iteminfo.OthAmt = other_other_amt
  12177. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12178. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12179. //
  12180. // }
  12181. // struct4101.IteminfoStruct = iteminfoStructs
  12182. // struct4101.Ntly = "中国"
  12183. // struct4101.AdmCaty = "A03.06"
  12184. //
  12185. // struct4101.DoctorName = doctor.UserName
  12186. // struct4101.DoctorCode = doctor.DoctorNumber
  12187. //
  12188. // var res ResultSeventeen
  12189. //
  12190. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12191. // struct4101.BillCode = order.Number
  12192. // struct4101.BillNo = order.SetlId
  12193. // var resOther ResultSeventeenOther
  12194. // var pp models.PublicParams
  12195. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12196. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12197. // pp.FixmedinsName = miConfig.OrgName
  12198. // pp.FixmedinsCode = miConfig.Code
  12199. // pp.RequestUrl = miConfig.Url
  12200. // pp.Cainfo = miConfig.Cainfo
  12201. // pp.SecretKey = miConfig.SecretKey
  12202. // pp.AccessKey = miConfig.AccessKey
  12203. // pp.OpterName = curRoles.UserName
  12204. //
  12205. // client := &http.Client{}
  12206. // var req *http.Request
  12207. // data := make(map[string]interface{})
  12208. // data["struct4101"] = struct4101
  12209. // data["pp"] = pp
  12210. // bytesData, _ := json.Marshal(data)
  12211. // if miConfig.MdtrtareaAdmvs == "320921" {
  12212. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12213. // } else {
  12214. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12215. // }
  12216. // resp, _ := client.Do(req)
  12217. // defer resp.Body.Close()
  12218. // body, ioErr := ioutil.ReadAll(resp.Body)
  12219. // if ioErr != nil {
  12220. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12222. // return
  12223. // }
  12224. // var respJSON map[string]interface{}
  12225. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12226. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12228. // return
  12229. // }
  12230. //
  12231. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12232. // userJSONBytes, _ := json.Marshal(respJSON)
  12233. // fmt.Println("log")
  12234. // fmt.Println(string(userJSONBytes))
  12235. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12236. // utils.ErrorLog("解析失败:%v", err)
  12237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12238. // return
  12239. // }
  12240. // res.InfRefmsgid = resOther.InfRefmsgid
  12241. // res.Output = resOther.Output
  12242. // res.ErrMsg = resOther.ErrMsg
  12243. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12244. // res.Infcode = infocode
  12245. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12246. //
  12247. // var pp models.PublicParams
  12248. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12249. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12250. // pp.FixmedinsName = miConfig.OrgName
  12251. // pp.FixmedinsCode = miConfig.Code
  12252. // pp.RequestUrl = miConfig.Url
  12253. // pp.Cainfo = miConfig.Cainfo
  12254. // pp.SecretKey = miConfig.SecretKey
  12255. // pp.AccessKey = miConfig.AccessKey
  12256. // pp.OpterName = curRoles.UserName
  12257. // result, _ := service.Jxyb4101(struct4101, pp)
  12258. // var dat map[string]interface{}
  12259. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12260. // fmt.Println(dat)
  12261. // } else {
  12262. // fmt.Println(err)
  12263. // }
  12264. // userJSONBytes, _ := json.Marshal(dat)
  12265. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12266. // utils.ErrorLog("解析失败:%v", err)
  12267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12268. // return
  12269. // }
  12270. //
  12271. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12272. // var pp models.PublicParams
  12273. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12274. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12275. // pp.FixmedinsName = miConfig.OrgName
  12276. // pp.FixmedinsCode = miConfig.Code
  12277. // pp.RequestUrl = miConfig.Url
  12278. // pp.Cainfo = miConfig.Cainfo
  12279. // pp.SecretKey = miConfig.SecretKey
  12280. // pp.AccessKey = miConfig.AccessKey
  12281. // pp.OpterName = curRoles.UserName
  12282. // result, _ := service.Hnyb4101(struct4101, pp)
  12283. // var dat map[string]interface{}
  12284. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12285. // fmt.Println(dat)
  12286. // } else {
  12287. // fmt.Println(err)
  12288. // }
  12289. // userJSONBytes, _ := json.Marshal(dat)
  12290. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12291. // utils.ErrorLog("解析失败:%v", err)
  12292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12293. // return
  12294. // }
  12295. //
  12296. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12297. // var resOther ResultSeventeenOther
  12298. //
  12299. // var pp models.PublicParams
  12300. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12301. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12302. // pp.FixmedinsName = miConfig.OrgName
  12303. // pp.FixmedinsCode = miConfig.Code
  12304. // pp.RequestUrl = miConfig.Url
  12305. // pp.Cainfo = miConfig.Cainfo
  12306. // pp.SecretKey = miConfig.SecretKey
  12307. // pp.AccessKey = miConfig.AccessKey
  12308. // pp.OpterName = curRoles.UserName
  12309. // client := &http.Client{}
  12310. // var req *http.Request
  12311. // data := make(map[string]interface{})
  12312. // data["struct4101"] = struct4101
  12313. // data["pp"] = pp
  12314. // bytesData, _ := json.Marshal(data)
  12315. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12316. // resp, _ := client.Do(req)
  12317. // defer resp.Body.Close()
  12318. // body, ioErr := ioutil.ReadAll(resp.Body)
  12319. // if ioErr != nil {
  12320. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12322. // return
  12323. // }
  12324. // var respJSON map[string]interface{}
  12325. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12326. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12328. // return
  12329. // }
  12330. //
  12331. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12332. // userJSONBytes, _ := json.Marshal(respJSON)
  12333. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12334. // utils.ErrorLog("解析失败:%v", err)
  12335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12336. // return
  12337. // }
  12338. // res.InfRefmsgid = resOther.InfRefmsgid
  12339. // res.Output = resOther.Output
  12340. // res.ErrMsg = resOther.ErrMsg
  12341. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12342. // res.Infcode = infocode
  12343. //
  12344. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12345. // var pp models.PublicParams
  12346. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12347. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12348. // pp.FixmedinsName = miConfig.OrgName
  12349. // pp.FixmedinsCode = miConfig.Code
  12350. // pp.RequestUrl = miConfig.Url
  12351. // pp.Cainfo = miConfig.Cainfo
  12352. // pp.SecretKey = miConfig.SecretKey
  12353. // pp.AccessKey = miConfig.AccessKey
  12354. // pp.OpterName = curRoles.UserName
  12355. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12356. // fmt.Println(requestLog)
  12357. // fmt.Println(errMsgLog)
  12358. //
  12359. // saveLog(result, requestLog, "4101a", "上传清单")
  12360. //
  12361. // var dat map[string]interface{}
  12362. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12363. // fmt.Println(dat)
  12364. // } else {
  12365. // fmt.Println(err)
  12366. // }
  12367. // userJSONBytes, _ := json.Marshal(dat)
  12368. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12369. // utils.ErrorLog("解析失败:%v", err)
  12370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12371. // return
  12372. // }
  12373. //
  12374. // } else {
  12375. //
  12376. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12377. // var dat map[string]interface{}
  12378. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12379. // fmt.Println(dat)
  12380. // } else {
  12381. // fmt.Println(err)
  12382. // }
  12383. // userJSONBytes, _ := json.Marshal(dat)
  12384. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12385. // utils.ErrorLog("解析失败:%v", err)
  12386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. // return
  12388. // }
  12389. // }
  12390. //
  12391. // if res.Infcode != 0 {
  12392. // adminUser := c.GetAdminUserInfo()
  12393. // errlog := &models.HisOrderError{
  12394. // UserOrgId: adminUser.CurrentOrgId,
  12395. // Ctime: time.Now().Unix(),
  12396. // Mtime: time.Now().Unix(),
  12397. // ErrMsg: res.ErrMsg,
  12398. // Status: 1,
  12399. // PatientId: order.ID,
  12400. // Stage: 10265,
  12401. // }
  12402. // service.CreateErrMsgLog(errlog)
  12403. // continue
  12404. // } else {
  12405. // //order.FaPiaoNumber = zero
  12406. // //order.FaPiaoCode = last_order.FaPiaoCode
  12407. // //service.UpdateOrder(order)
  12408. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12409. // Number: res.Output.SetlListId,
  12410. // Status: 1,
  12411. // Ctime: time.Now().Unix(),
  12412. // Mtime: time.Now().Unix(),
  12413. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12414. // IsUpload: 1,
  12415. // OrderId: order.ID,
  12416. // }
  12417. // service.CreateUploadRecord(hisFundSettleListResult)
  12418. // c.ServeSuccessJSON(map[string]interface{}{
  12419. // "msg": "上传成功",
  12420. // "result": hisFundSettleListResult,
  12421. // })
  12422. // continue
  12423. // }
  12424. // }
  12425. //}
  12426. func (c *HisApiController) GetbatchSettleList() {
  12427. //order_id, _ := c.GetInt64("order_id")
  12428. admin_user_id, _ := c.GetInt64("admin_user_id")
  12429. orders, _ := service.GetAllHisOrderTwo10485()
  12430. for _, item := range orders {
  12431. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12432. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12433. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12434. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12435. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12436. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12437. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12438. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12439. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12440. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12441. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12442. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12443. //fmt.Println(count)
  12444. //var zero string
  12445. //number := count + 1
  12446. //if number >= 1000 {
  12447. // zero = "0000" + strconv.FormatInt(number, 10)
  12448. //} else if number >= 10000 {
  12449. // zero = "000" + strconv.FormatInt(number, 10)
  12450. //} else if number >= 100000 {
  12451. // zero = "00" + strconv.FormatInt(number, 10)
  12452. //} else if number >= 1000000 {
  12453. // zero = "0" + strconv.FormatInt(number, 10)
  12454. //} else {
  12455. // zero = strconv.FormatInt(number, 10)
  12456. //}
  12457. //fmt.Println(zero)
  12458. struct4101 := service.Struct4101{
  12459. PsnNo: order.PsnNo,
  12460. MdtrtId: order.MdtrtId,
  12461. SetlId: order.SetlId,
  12462. PsnName: order.PsnName,
  12463. Gend: order.Gend,
  12464. Brdy: his.Brdy,
  12465. Age: his.Age,
  12466. Naty: order.Naty,
  12467. PatnCertType: "01",
  12468. Certno: order.Certno,
  12469. Prfs: "90",
  12470. ConerName: roles[0].UserName,
  12471. PatnRlts: "99",
  12472. ConerAddr: miConfig.OrgName,
  12473. ConerTel: admin.Mobile,
  12474. HiType: order.Insutype,
  12475. Insuplc: miConfig.InsuplcAdmdvs,
  12476. MaindiagFlag: "1",
  12477. BillCode: order.SetlId,
  12478. BillNo: order.SetlId,
  12479. BizSn: order.Number,
  12480. PsnSelfPay: order.PsnPartAmt,
  12481. PsnOwnPay: order.PsnPartAmt,
  12482. AcctPay: order.AcctPay,
  12483. PsnCashpay: order.PsnCashPay,
  12484. HiPaymtd: "1",
  12485. Hsorg: miConfig.InsuplcAdmdvs,
  12486. HsorgOpter: miConfig.InsuplcAdmdvs,
  12487. MedinsFillPsn: curRoles.UserName,
  12488. MedinsFillDept: miConfig.OrgName,
  12489. IptMedType: "2",
  12490. }
  12491. struct4101.SetlBegnDate = order.SetlTime
  12492. struct4101.SetlEndDate = order.SetlTime
  12493. time_arr := strings.Split(order.SetlTime, " ")
  12494. struct4101.AdmTime = time_arr[0]
  12495. struct4101.AdmEndTime = time_arr[0]
  12496. //var rf []CustomFundPay
  12497. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12498. //
  12499. //var tempFunPays []service.CustomStruct
  12500. //for _, item := range rf {
  12501. // var tempFunPay service.CustomStruct
  12502. // tempFunPay.FundPayamt = item.FundPayamt
  12503. // tempFunPay.FundPayType = item.FundPayType
  12504. // tempFunPays = append(tempFunPays, tempFunPay)
  12505. //}
  12506. //struct4101.CustomStruct = tempFunPays
  12507. var tempDiaginfos []service.DiaginfoStructTwo
  12508. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12509. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12510. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12511. var config []*models.HisXtDiagnoseConfig
  12512. for _, item := range diagnosis_ids {
  12513. id, _ := strconv.ParseInt(item, 10, 64)
  12514. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12515. config = append(config, &diagnosisConfig)
  12516. }
  12517. for index, item := range config {
  12518. if index == 0 {
  12519. var tempDiaginfo service.DiaginfoStructTwo
  12520. tempDiaginfo.DiagCode = item.CountryCode
  12521. tempDiaginfo.DiagName = item.CountryContentName
  12522. tempDiaginfo.DiagType = "1"
  12523. tempDiaginfo.MaindiagFlag = "1"
  12524. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12525. } else {
  12526. var tempDiaginfo service.DiaginfoStructTwo
  12527. tempDiaginfo.DiagCode = item.CountryCode
  12528. tempDiaginfo.DiagName = item.CountryContentName
  12529. tempDiaginfo.DiagType = "1"
  12530. tempDiaginfo.MaindiagFlag = "0"
  12531. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12532. }
  12533. }
  12534. struct4101.Diseinfo = tempDiaginfos
  12535. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12536. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12537. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12538. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12539. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12540. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12541. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12542. var iteminfo service.IteminfoStruct
  12543. var bedCostTotal float64 = 0 //床位总费
  12544. var bedCostSelfTotal float64 = 0 //床位自费
  12545. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12546. var operationCostTotal float64 = 0 //手术费
  12547. var operationCostSelfTotal float64 = 0 //手术费
  12548. var operationCostPartSelfTotal float64 = 0 //手术费
  12549. var otherCostTotal float64 = 0 //其他费用
  12550. var otherCostSelfTotal float64 = 0 //其他费用
  12551. var otherCostPartSelfTotal float64 = 0 //其他费用
  12552. var materialCostTotal float64 = 0 //材料费
  12553. var materialCostSelfTotal float64 = 0 //材料费
  12554. var materialCostPartSelfTotal float64 = 0 //材料费
  12555. var westernMedicineCostTotal float64 = 0 //西药费
  12556. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12557. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12558. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12559. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12560. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12561. var checkCostTotal float64 = 0 //检查费
  12562. var checkCostSelfTotal float64 = 0 //检查费
  12563. var checkCostPartSelfTotal float64 = 0 //检查费
  12564. var laboratoryCostTotal float64 = 0 //化验费
  12565. var laboratoryCostSelfTotal float64 = 0 //化验费
  12566. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12567. var treatCostTotal float64 = 0 //治疗费用
  12568. var treatCostSelfTotal float64 = 0 //治疗费用
  12569. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12570. decimal.DivisionPrecision = 2
  12571. var bed_fulamt_ownpay_amt float64 = 0
  12572. var operation_fulamt_ownpay_amt float64 = 0
  12573. var other_fulamt_ownpay_amt float64 = 0
  12574. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12575. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12576. var check_fulamt_ownpay_amt float64 = 0
  12577. var material_fulamt_ownpay_amt float64 = 0
  12578. var laboratory_fulamt_ownpay_amt float64 = 0
  12579. var treat_fulamt_ownpay_amt float64 = 0
  12580. var bed_claa_sunmfee float64 = 0
  12581. var bed_clab_amt float64 = 0
  12582. var bed_other_amt float64 = 0
  12583. var operation_claa_sunmfee float64 = 0
  12584. var operation_clab_amt float64 = 0
  12585. var operation_other_amt float64 = 0
  12586. var other_claa_sunmfee float64 = 0
  12587. var other_clab_amt float64 = 0
  12588. var other_other_amt float64 = 0
  12589. var westernMedicine_claa_sunmfee float64 = 0
  12590. var westernMedicine_clab_amt float64 = 0
  12591. var westernMedicine_other_amt float64 = 0
  12592. var chineseTraditional_claa_sunmfee float64 = 0
  12593. var chineseTraditional_clab_amt float64 = 0
  12594. var chineseTraditional_other_amt float64 = 0
  12595. var check_claa_sunmfee float64 = 0
  12596. var check_clab_amt float64 = 0
  12597. var check_other_amt float64 = 0
  12598. var material_claa_sunmfee float64 = 0
  12599. var material_clab_amt float64 = 0
  12600. var material_other_amt float64 = 0
  12601. var laboratory_claa_sunmfee float64 = 0
  12602. var laboratory_clab_amt float64 = 0
  12603. var laboratory_other_amt float64 = 0
  12604. var treat_claa_sunmfee float64 = 0
  12605. var treat_clab_amt float64 = 0
  12606. var treat_other_amt float64 = 0
  12607. for _, item := range order.HisOrderInfo {
  12608. if item.MedChrgitmType == "01" { //床位费
  12609. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12610. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12611. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12612. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12613. if item.ChrgitmLv == "1" {
  12614. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12615. }
  12616. if item.ChrgitmLv == "2" {
  12617. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12618. }
  12619. if item.ChrgitmLv == "3" {
  12620. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12621. }
  12622. }
  12623. if item.MedChrgitmType == "03" { //检查费
  12624. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12625. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12626. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12627. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12628. if item.ChrgitmLv == "1" {
  12629. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12630. }
  12631. if item.ChrgitmLv == "2" {
  12632. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12633. }
  12634. if item.ChrgitmLv == "3" {
  12635. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12636. }
  12637. }
  12638. if item.MedChrgitmType == "04" { //化验费
  12639. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12640. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12641. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12642. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12643. if item.ChrgitmLv == "1" {
  12644. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12645. }
  12646. if item.ChrgitmLv == "2" {
  12647. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12648. }
  12649. if item.ChrgitmLv == "3" {
  12650. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12651. }
  12652. }
  12653. if item.MedChrgitmType == "05" { //治疗费
  12654. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12655. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12656. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12657. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12658. if item.ChrgitmLv == "1" {
  12659. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12660. }
  12661. if item.ChrgitmLv == "2" {
  12662. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12663. }
  12664. if item.ChrgitmLv == "3" {
  12665. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12666. }
  12667. }
  12668. if item.MedChrgitmType == "06" { //手术费
  12669. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12670. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12671. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12672. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12673. if item.ChrgitmLv == "1" {
  12674. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12675. }
  12676. if item.ChrgitmLv == "2" {
  12677. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12678. }
  12679. if item.ChrgitmLv == "3" {
  12680. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12681. }
  12682. }
  12683. if item.MedChrgitmType == "08" { //材料费
  12684. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12685. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12686. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12687. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12688. if item.ChrgitmLv == "1" {
  12689. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12690. }
  12691. if item.ChrgitmLv == "2" {
  12692. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12693. }
  12694. if item.ChrgitmLv == "3" {
  12695. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12696. }
  12697. }
  12698. if item.MedChrgitmType == "09" { //西药费
  12699. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12700. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12701. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12702. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12703. if item.ChrgitmLv == "1" {
  12704. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12705. }
  12706. if item.ChrgitmLv == "2" {
  12707. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12708. }
  12709. if item.ChrgitmLv == "3" {
  12710. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12711. }
  12712. }
  12713. if item.MedChrgitmType == "11" { //中成费
  12714. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12715. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12716. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12717. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12718. if item.ChrgitmLv == "1" {
  12719. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12720. }
  12721. if item.ChrgitmLv == "2" {
  12722. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12723. }
  12724. if item.ChrgitmLv == "3" {
  12725. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12726. }
  12727. }
  12728. if item.MedChrgitmType == "14" { //其他费
  12729. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12730. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12731. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12732. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12733. if item.ChrgitmLv == "1" {
  12734. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12735. }
  12736. if item.ChrgitmLv == "2" {
  12737. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12738. }
  12739. if item.ChrgitmLv == "3" {
  12740. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12741. }
  12742. }
  12743. }
  12744. var iteminfoStructs []service.IteminfoStruct
  12745. if bedCostTotal != 0 {
  12746. iteminfo.MedChrgitm = "01"
  12747. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12748. iteminfo.Amt = bedCostTotal
  12749. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12750. iteminfo.ClabAmt = bed_clab_amt
  12751. iteminfo.OthAmt = bed_other_amt
  12752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12753. }
  12754. if checkCostTotal != 0 {
  12755. iteminfo.MedChrgitm = "03"
  12756. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12757. iteminfo.Amt = checkCostTotal
  12758. iteminfo.ClaaSumfee = check_claa_sunmfee
  12759. iteminfo.ClabAmt = check_clab_amt
  12760. iteminfo.OthAmt = check_other_amt
  12761. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12762. }
  12763. if laboratoryCostTotal != 0 {
  12764. iteminfo.MedChrgitm = "04"
  12765. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12766. iteminfo.Amt = laboratoryCostTotal
  12767. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12768. iteminfo.ClabAmt = laboratory_clab_amt
  12769. iteminfo.OthAmt = laboratory_other_amt
  12770. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12771. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12772. }
  12773. if treatCostTotal != 0 {
  12774. iteminfo.MedChrgitm = "05"
  12775. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12776. iteminfo.Amt = treatCostTotal
  12777. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12778. iteminfo.ClabAmt = treat_clab_amt
  12779. iteminfo.OthAmt = treat_other_amt
  12780. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12781. //(struct4101.IteminfoStruct, iteminfo)
  12782. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12783. }
  12784. if operationCostTotal != 0 {
  12785. iteminfo.MedChrgitm = "06"
  12786. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12787. iteminfo.Amt = operationCostTotal
  12788. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12789. iteminfo.ClabAmt = operation_clab_amt
  12790. iteminfo.OthAmt = operation_other_amt
  12791. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12792. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12793. }
  12794. if materialCostTotal != 0 {
  12795. iteminfo.MedChrgitm = "08"
  12796. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12797. iteminfo.Amt = materialCostTotal
  12798. iteminfo.ClaaSumfee = material_claa_sunmfee
  12799. iteminfo.ClabAmt = material_clab_amt
  12800. iteminfo.OthAmt = material_other_amt
  12801. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12802. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12803. }
  12804. if westernMedicineCostTotal != 0 {
  12805. iteminfo.MedChrgitm = "09"
  12806. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12807. iteminfo.Amt = westernMedicineCostTotal
  12808. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12809. iteminfo.ClabAmt = westernMedicine_clab_amt
  12810. iteminfo.OthAmt = westernMedicine_other_amt
  12811. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12812. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12813. }
  12814. if chineseTraditionalMedicineCostTotal != 0 {
  12815. iteminfo.MedChrgitm = "11"
  12816. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12817. iteminfo.Amt = westernMedicineCostTotal
  12818. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12819. iteminfo.ClabAmt = westernMedicine_clab_amt
  12820. iteminfo.OthAmt = westernMedicine_other_amt
  12821. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12822. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12823. }
  12824. if otherCostTotal != 0 {
  12825. iteminfo.MedChrgitm = "14"
  12826. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12827. iteminfo.Amt = otherCostTotal
  12828. iteminfo.ClaaSumfee = other_claa_sunmfee
  12829. iteminfo.ClabAmt = other_clab_amt
  12830. iteminfo.OthAmt = other_other_amt
  12831. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12832. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12833. }
  12834. struct4101.IteminfoStruct = iteminfoStructs
  12835. struct4101.Ntly = "中国"
  12836. struct4101.AdmCaty = "A03.06"
  12837. struct4101.DoctorName = doctor.UserName
  12838. struct4101.DoctorCode = doctor.DoctorNumber
  12839. var res ResultSeventeen
  12840. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12841. struct4101.BillCode = order.Number
  12842. struct4101.BillNo = order.SetlId
  12843. var resOther ResultSeventeenOther
  12844. var pp models.PublicParams
  12845. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12846. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12847. pp.FixmedinsName = miConfig.OrgName
  12848. pp.FixmedinsCode = miConfig.Code
  12849. pp.RequestUrl = miConfig.Url
  12850. pp.Cainfo = miConfig.Cainfo
  12851. pp.SecretKey = miConfig.SecretKey
  12852. pp.AccessKey = miConfig.AccessKey
  12853. pp.OpterName = curRoles.UserName
  12854. client := &http.Client{}
  12855. var req *http.Request
  12856. data := make(map[string]interface{})
  12857. data["struct4101"] = struct4101
  12858. data["pp"] = pp
  12859. bytesData, _ := json.Marshal(data)
  12860. if miConfig.MdtrtareaAdmvs == "320921" {
  12861. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12862. } else {
  12863. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12864. }
  12865. resp, _ := client.Do(req)
  12866. defer resp.Body.Close()
  12867. body, ioErr := ioutil.ReadAll(resp.Body)
  12868. if ioErr != nil {
  12869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12871. return
  12872. }
  12873. var respJSON map[string]interface{}
  12874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12877. return
  12878. }
  12879. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12880. userJSONBytes, _ := json.Marshal(respJSON)
  12881. fmt.Println("log")
  12882. fmt.Println(string(userJSONBytes))
  12883. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12884. utils.ErrorLog("解析失败:%v", err)
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12886. return
  12887. }
  12888. res.InfRefmsgid = resOther.InfRefmsgid
  12889. res.Output = resOther.Output
  12890. res.ErrMsg = resOther.ErrMsg
  12891. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12892. res.Infcode = infocode
  12893. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12894. var pp models.PublicParams
  12895. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12896. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12897. pp.FixmedinsName = miConfig.OrgName
  12898. pp.FixmedinsCode = miConfig.Code
  12899. pp.RequestUrl = miConfig.Url
  12900. pp.Cainfo = miConfig.Cainfo
  12901. pp.SecretKey = miConfig.SecretKey
  12902. pp.AccessKey = miConfig.AccessKey
  12903. pp.OpterName = curRoles.UserName
  12904. result, _ := service.Jxyb4101(struct4101, pp)
  12905. var dat map[string]interface{}
  12906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12907. fmt.Println(dat)
  12908. } else {
  12909. fmt.Println(err)
  12910. }
  12911. userJSONBytes, _ := json.Marshal(dat)
  12912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12913. utils.ErrorLog("解析失败:%v", err)
  12914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12915. return
  12916. }
  12917. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12918. var pp models.PublicParams
  12919. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12920. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12921. pp.FixmedinsName = miConfig.OrgName
  12922. pp.FixmedinsCode = miConfig.Code
  12923. pp.RequestUrl = miConfig.Url
  12924. pp.Cainfo = miConfig.Cainfo
  12925. pp.SecretKey = miConfig.SecretKey
  12926. pp.AccessKey = miConfig.AccessKey
  12927. pp.OpterName = curRoles.UserName
  12928. result, _ := service.Hnyb4101(struct4101, pp)
  12929. var dat map[string]interface{}
  12930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12931. fmt.Println(dat)
  12932. } else {
  12933. fmt.Println(err)
  12934. }
  12935. userJSONBytes, _ := json.Marshal(dat)
  12936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12937. utils.ErrorLog("解析失败:%v", err)
  12938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12939. return
  12940. }
  12941. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12942. var resOther ResultSeventeenOther
  12943. var pp models.PublicParams
  12944. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12945. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12946. pp.FixmedinsName = miConfig.OrgName
  12947. pp.FixmedinsCode = miConfig.Code
  12948. pp.RequestUrl = miConfig.Url
  12949. pp.Cainfo = miConfig.Cainfo
  12950. pp.SecretKey = miConfig.SecretKey
  12951. pp.AccessKey = miConfig.AccessKey
  12952. pp.OpterName = curRoles.UserName
  12953. client := &http.Client{}
  12954. var req *http.Request
  12955. data := make(map[string]interface{})
  12956. data["struct4101"] = struct4101
  12957. data["pp"] = pp
  12958. bytesData, _ := json.Marshal(data)
  12959. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12960. resp, _ := client.Do(req)
  12961. defer resp.Body.Close()
  12962. body, ioErr := ioutil.ReadAll(resp.Body)
  12963. if ioErr != nil {
  12964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12966. return
  12967. }
  12968. var respJSON map[string]interface{}
  12969. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12972. return
  12973. }
  12974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12975. userJSONBytes, _ := json.Marshal(respJSON)
  12976. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12977. utils.ErrorLog("解析失败:%v", err)
  12978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12979. return
  12980. }
  12981. res.InfRefmsgid = resOther.InfRefmsgid
  12982. res.Output = resOther.Output
  12983. res.ErrMsg = resOther.ErrMsg
  12984. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12985. res.Infcode = infocode
  12986. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12987. var pp models.PublicParams
  12988. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12989. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12990. pp.FixmedinsName = miConfig.OrgName
  12991. pp.FixmedinsCode = miConfig.Code
  12992. pp.RequestUrl = miConfig.Url
  12993. pp.Cainfo = miConfig.Cainfo
  12994. pp.SecretKey = miConfig.SecretKey
  12995. pp.AccessKey = miConfig.AccessKey
  12996. pp.OpterName = curRoles.UserName
  12997. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12998. fmt.Println(requestLog)
  12999. fmt.Println(errMsgLog)
  13000. saveLog(result, requestLog, "4101a", "上传清单")
  13001. var dat map[string]interface{}
  13002. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13003. fmt.Println(dat)
  13004. } else {
  13005. fmt.Println(err)
  13006. }
  13007. userJSONBytes, _ := json.Marshal(dat)
  13008. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13009. utils.ErrorLog("解析失败:%v", err)
  13010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13011. return
  13012. }
  13013. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13014. var pp models.PublicParams
  13015. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13016. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13017. pp.FixmedinsName = miConfig.OrgName
  13018. pp.FixmedinsCode = miConfig.Code
  13019. pp.RequestUrl = miConfig.Url
  13020. pp.Cainfo = miConfig.Cainfo
  13021. pp.SecretKey = miConfig.SecretKey
  13022. pp.AccessKey = miConfig.AccessKey
  13023. pp.OpterName = curRoles.UserName
  13024. client := &http.Client{}
  13025. var req *http.Request
  13026. data := make(map[string]interface{})
  13027. data["struct4101"] = struct4101
  13028. data["pp"] = pp
  13029. bytesData, _ := json.Marshal(data)
  13030. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13031. resp, _ := client.Do(req)
  13032. defer resp.Body.Close()
  13033. body, ioErr := ioutil.ReadAll(resp.Body)
  13034. if ioErr != nil {
  13035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13037. return
  13038. }
  13039. var respJSON map[string]interface{}
  13040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13043. return
  13044. }
  13045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13046. userJSONBytes, _ := json.Marshal(respJSON)
  13047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13048. utils.ErrorLog("解析失败:%v", err)
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return
  13051. }
  13052. } else {
  13053. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13054. var dat map[string]interface{}
  13055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13056. fmt.Println(dat)
  13057. } else {
  13058. fmt.Println(err)
  13059. }
  13060. userJSONBytes, _ := json.Marshal(dat)
  13061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13062. utils.ErrorLog("解析失败:%v", err)
  13063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13064. return
  13065. }
  13066. }
  13067. if res.Infcode != 0 {
  13068. errlog := &models.HisOrderError{
  13069. UserOrgId: order.UserOrgId,
  13070. Ctime: time.Now().Unix(),
  13071. Mtime: time.Now().Unix(),
  13072. ErrMsg: res.ErrMsg + "解析失败",
  13073. Status: 1,
  13074. PatientId: order.ID,
  13075. Stage: 10485,
  13076. }
  13077. service.CreateErrMsgLog(errlog)
  13078. continue
  13079. //c.ServeSuccessJSON(map[string]interface{}{
  13080. // "failed_code": -10,
  13081. // "msg": res.ErrMsg,
  13082. //})
  13083. } else {
  13084. //order.FaPiaoNumber = zero
  13085. //order.FaPiaoCode = last_order.FaPiaoCode
  13086. //service.UpdateOrder(order)
  13087. hisFundSettleListResult := &models.HisFundSettleListResult{
  13088. Number: res.Output.SetlListId,
  13089. Status: 1,
  13090. Ctime: time.Now().Unix(),
  13091. Mtime: time.Now().Unix(),
  13092. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13093. IsUpload: 1,
  13094. OrderId: order.ID,
  13095. }
  13096. service.CreateUploadRecord(hisFundSettleListResult)
  13097. continue
  13098. }
  13099. }
  13100. }
  13101. func (c *HisApiController) GetSettleList() {
  13102. order_id, _ := c.GetInt64("order_id")
  13103. admin_user_id, _ := c.GetInt64("admin_user_id")
  13104. order, _ := service.GetHisOrderByIDTwo(order_id)
  13105. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13106. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13107. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13108. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13109. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13111. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13112. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13113. if order.ID == 0 {
  13114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13115. return
  13116. }
  13117. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13118. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13119. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13120. //fmt.Println(count)
  13121. //var zero string
  13122. //number := count + 1
  13123. //if number >= 1000 {
  13124. // zero = "0000" + strconv.FormatInt(number, 10)
  13125. //} else if number >= 10000 {
  13126. // zero = "000" + strconv.FormatInt(number, 10)
  13127. //} else if number >= 100000 {
  13128. // zero = "00" + strconv.FormatInt(number, 10)
  13129. //} else if number >= 1000000 {
  13130. // zero = "0" + strconv.FormatInt(number, 10)
  13131. //} else {
  13132. // zero = strconv.FormatInt(number, 10)
  13133. //}
  13134. //fmt.Println(zero)
  13135. struct4101 := service.Struct4101{
  13136. PsnNo: order.PsnNo,
  13137. MdtrtId: order.MdtrtId,
  13138. SetlId: order.SetlId,
  13139. PsnName: order.PsnName,
  13140. Gend: order.Gend,
  13141. Brdy: his.Brdy,
  13142. Age: his.Age,
  13143. Naty: order.Naty,
  13144. PatnCertType: "01",
  13145. Certno: order.Certno,
  13146. Prfs: "90",
  13147. ConerName: roles[0].UserName,
  13148. PatnRlts: "99",
  13149. ConerAddr: miConfig.OrgName,
  13150. ConerTel: admin.Mobile,
  13151. HiType: order.Insutype,
  13152. Insuplc: miConfig.InsuplcAdmdvs,
  13153. MaindiagFlag: "1",
  13154. BillCode: order.SetlId,
  13155. BillNo: order.SetlId,
  13156. BizSn: order.Number,
  13157. PsnSelfPay: order.PsnPartAmt,
  13158. PsnOwnPay: order.PsnPartAmt,
  13159. AcctPay: order.AcctPay,
  13160. PsnCashpay: order.PsnCashPay,
  13161. HiPaymtd: "1",
  13162. Hsorg: miConfig.InsuplcAdmdvs,
  13163. HsorgOpter: miConfig.InsuplcAdmdvs,
  13164. MedinsFillPsn: curRoles.UserName,
  13165. MedinsFillDept: miConfig.OrgName,
  13166. IptMedType: "2",
  13167. }
  13168. struct4101.SetlBegnDate = order.SetlTime
  13169. struct4101.SetlEndDate = order.SetlTime
  13170. time_arr := strings.Split(order.SetlTime, " ")
  13171. struct4101.AdmTime = time_arr[0]
  13172. struct4101.AdmEndTime = time_arr[0]
  13173. //
  13174. //var rf []CustomFundPay
  13175. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13176. //
  13177. //var tempFunPays []service.CustomStruct
  13178. //for _, item := range rf {
  13179. // var tempFunPay service.CustomStruct
  13180. // tempFunPay.FundPayamt = item.FundPayamt
  13181. // tempFunPay.FundPayType = item.FundPayType
  13182. // tempFunPays = append(tempFunPays, tempFunPay)
  13183. //}
  13184. //struct4101.CustomStruct = tempFunPays
  13185. var tempDiaginfos []service.DiaginfoStructTwo
  13186. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13187. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13188. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13189. var config []*models.HisXtDiagnoseConfig
  13190. for _, item := range diagnosis_ids {
  13191. id, _ := strconv.ParseInt(item, 10, 64)
  13192. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13193. config = append(config, &diagnosisConfig)
  13194. }
  13195. if miConfig.Code == "H15049901371" {
  13196. //for _, item := range config {
  13197. // if item.ID == 138 {
  13198. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13199. var tempDiaginfo service.DiaginfoStructTwo
  13200. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13201. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13202. tempDiaginfo.DiagType = "1"
  13203. tempDiaginfo.MaindiagFlag = "1"
  13204. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13205. //}
  13206. //}
  13207. for _, item := range config {
  13208. if item.ID != 138 {
  13209. var tempDiaginfo service.DiaginfoStructTwo
  13210. tempDiaginfo.DiagCode = item.CountryCode
  13211. tempDiaginfo.DiagName = item.CountryContentName
  13212. tempDiaginfo.DiagType = "1"
  13213. tempDiaginfo.MaindiagFlag = "0"
  13214. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13215. }
  13216. }
  13217. } else {
  13218. for index, item := range config {
  13219. if index == 0 {
  13220. var tempDiaginfo service.DiaginfoStructTwo
  13221. tempDiaginfo.DiagCode = item.CountryCode
  13222. tempDiaginfo.DiagName = item.CountryContentName
  13223. tempDiaginfo.DiagType = "1"
  13224. tempDiaginfo.MaindiagFlag = "1"
  13225. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13226. } else {
  13227. var tempDiaginfo service.DiaginfoStructTwo
  13228. tempDiaginfo.DiagCode = item.CountryCode
  13229. tempDiaginfo.DiagName = item.CountryContentName
  13230. tempDiaginfo.DiagType = "1"
  13231. tempDiaginfo.MaindiagFlag = "0"
  13232. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13233. }
  13234. }
  13235. }
  13236. struct4101.Diseinfo = tempDiaginfos
  13237. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13238. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13239. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13240. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13241. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13242. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13243. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13244. var iteminfo service.IteminfoStruct
  13245. var bedCostTotal float64 = 0 //床位总费
  13246. var bedCostSelfTotal float64 = 0 //床位自费
  13247. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13248. var operationCostTotal float64 = 0 //手术费
  13249. var operationCostSelfTotal float64 = 0 //手术费
  13250. var operationCostPartSelfTotal float64 = 0 //手术费
  13251. var otherCostTotal float64 = 0 //其他费用
  13252. var otherCostSelfTotal float64 = 0 //其他费用
  13253. var otherCostPartSelfTotal float64 = 0 //其他费用
  13254. var materialCostTotal float64 = 0 //材料费
  13255. var materialCostSelfTotal float64 = 0 //材料费
  13256. var materialCostPartSelfTotal float64 = 0 //材料费
  13257. var westernMedicineCostTotal float64 = 0 //西药费
  13258. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13259. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13260. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13261. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13262. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13263. var checkCostTotal float64 = 0 //检查费
  13264. var checkCostSelfTotal float64 = 0 //检查费
  13265. var checkCostPartSelfTotal float64 = 0 //检查费
  13266. var laboratoryCostTotal float64 = 0 //化验费
  13267. var laboratoryCostSelfTotal float64 = 0 //化验费
  13268. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13269. var treatCostTotal float64 = 0 //治疗费用
  13270. var treatCostSelfTotal float64 = 0 //治疗费用
  13271. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13272. decimal.DivisionPrecision = 2
  13273. var bed_fulamt_ownpay_amt float64 = 0
  13274. var operation_fulamt_ownpay_amt float64 = 0
  13275. var other_fulamt_ownpay_amt float64 = 0
  13276. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13277. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13278. var check_fulamt_ownpay_amt float64 = 0
  13279. var material_fulamt_ownpay_amt float64 = 0
  13280. var laboratory_fulamt_ownpay_amt float64 = 0
  13281. var treat_fulamt_ownpay_amt float64 = 0
  13282. var bed_claa_sunmfee float64 = 0
  13283. var bed_clab_amt float64 = 0
  13284. var bed_other_amt float64 = 0
  13285. var operation_claa_sunmfee float64 = 0
  13286. var operation_clab_amt float64 = 0
  13287. var operation_other_amt float64 = 0
  13288. var other_claa_sunmfee float64 = 0
  13289. var other_clab_amt float64 = 0
  13290. var other_other_amt float64 = 0
  13291. var westernMedicine_claa_sunmfee float64 = 0
  13292. var westernMedicine_clab_amt float64 = 0
  13293. var westernMedicine_other_amt float64 = 0
  13294. var chineseTraditional_claa_sunmfee float64 = 0
  13295. var chineseTraditional_clab_amt float64 = 0
  13296. var chineseTraditional_other_amt float64 = 0
  13297. var check_claa_sunmfee float64 = 0
  13298. var check_clab_amt float64 = 0
  13299. var check_other_amt float64 = 0
  13300. var material_claa_sunmfee float64 = 0
  13301. var material_clab_amt float64 = 0
  13302. var material_other_amt float64 = 0
  13303. var laboratory_claa_sunmfee float64 = 0
  13304. var laboratory_clab_amt float64 = 0
  13305. var laboratory_other_amt float64 = 0
  13306. var treat_claa_sunmfee float64 = 0
  13307. var treat_clab_amt float64 = 0
  13308. var treat_other_amt float64 = 0
  13309. for _, item := range order.HisOrderInfo {
  13310. if item.MedChrgitmType == "01" { //床位费
  13311. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13312. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13313. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13314. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13315. if item.ChrgitmLv == "1" {
  13316. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13317. }
  13318. if item.ChrgitmLv == "2" {
  13319. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13320. }
  13321. if item.ChrgitmLv == "3" {
  13322. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13323. }
  13324. }
  13325. if item.MedChrgitmType == "03" { //检查费
  13326. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13327. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13328. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13329. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13330. if item.ChrgitmLv == "1" {
  13331. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13332. }
  13333. if item.ChrgitmLv == "2" {
  13334. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13335. }
  13336. if item.ChrgitmLv == "3" {
  13337. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13338. }
  13339. }
  13340. if item.MedChrgitmType == "04" { //化验费
  13341. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13342. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13343. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13344. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13345. if item.ChrgitmLv == "1" {
  13346. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13347. }
  13348. if item.ChrgitmLv == "2" {
  13349. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13350. }
  13351. if item.ChrgitmLv == "3" {
  13352. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13353. }
  13354. }
  13355. if item.MedChrgitmType == "05" { //治疗费
  13356. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13357. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13358. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13359. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13360. if item.ChrgitmLv == "1" {
  13361. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13362. }
  13363. if item.ChrgitmLv == "2" {
  13364. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13365. }
  13366. if item.ChrgitmLv == "3" {
  13367. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13368. }
  13369. }
  13370. if item.MedChrgitmType == "06" { //手术费
  13371. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13372. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13373. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13374. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13375. if item.ChrgitmLv == "1" {
  13376. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13377. }
  13378. if item.ChrgitmLv == "2" {
  13379. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13380. }
  13381. if item.ChrgitmLv == "3" {
  13382. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13383. }
  13384. }
  13385. if item.MedChrgitmType == "08" { //材料费
  13386. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13387. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13388. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13389. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13390. if item.ChrgitmLv == "1" {
  13391. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13392. }
  13393. if item.ChrgitmLv == "2" {
  13394. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13395. }
  13396. if item.ChrgitmLv == "3" {
  13397. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13398. }
  13399. }
  13400. if item.MedChrgitmType == "09" { //西药费
  13401. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13402. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13403. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13404. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13405. if item.ChrgitmLv == "1" {
  13406. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13407. }
  13408. if item.ChrgitmLv == "2" {
  13409. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13410. }
  13411. if item.ChrgitmLv == "3" {
  13412. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13413. }
  13414. }
  13415. if item.MedChrgitmType == "11" { //中成费
  13416. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13417. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13418. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13419. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13420. if item.ChrgitmLv == "1" {
  13421. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13422. }
  13423. if item.ChrgitmLv == "2" {
  13424. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13425. }
  13426. if item.ChrgitmLv == "3" {
  13427. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13428. }
  13429. }
  13430. if item.MedChrgitmType == "14" { //其他费
  13431. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13432. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13433. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13434. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13435. if item.ChrgitmLv == "1" {
  13436. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13437. }
  13438. if item.ChrgitmLv == "2" {
  13439. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13440. }
  13441. if item.ChrgitmLv == "3" {
  13442. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13443. }
  13444. }
  13445. }
  13446. var iteminfoStructs []service.IteminfoStruct
  13447. if bedCostTotal != 0 {
  13448. iteminfo.MedChrgitm = "01"
  13449. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13450. iteminfo.Amt = bedCostTotal
  13451. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13452. iteminfo.ClabAmt = bed_clab_amt
  13453. iteminfo.OthAmt = bed_other_amt
  13454. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13455. }
  13456. if checkCostTotal != 0 {
  13457. iteminfo.MedChrgitm = "03"
  13458. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13459. iteminfo.Amt = checkCostTotal
  13460. iteminfo.ClaaSumfee = check_claa_sunmfee
  13461. iteminfo.ClabAmt = check_clab_amt
  13462. iteminfo.OthAmt = check_other_amt
  13463. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13464. }
  13465. if laboratoryCostTotal != 0 {
  13466. iteminfo.MedChrgitm = "04"
  13467. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13468. iteminfo.Amt = laboratoryCostTotal
  13469. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13470. iteminfo.ClabAmt = laboratory_clab_amt
  13471. iteminfo.OthAmt = laboratory_other_amt
  13472. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13473. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13474. }
  13475. if treatCostTotal != 0 {
  13476. iteminfo.MedChrgitm = "05"
  13477. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13478. iteminfo.Amt = treatCostTotal
  13479. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13480. iteminfo.ClabAmt = treat_clab_amt
  13481. iteminfo.OthAmt = treat_other_amt
  13482. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13483. //(struct4101.IteminfoStruct, iteminfo)
  13484. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13485. }
  13486. if operationCostTotal != 0 {
  13487. iteminfo.MedChrgitm = "06"
  13488. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13489. iteminfo.Amt = operationCostTotal
  13490. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13491. iteminfo.ClabAmt = operation_clab_amt
  13492. iteminfo.OthAmt = operation_other_amt
  13493. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13494. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13495. }
  13496. if materialCostTotal != 0 {
  13497. iteminfo.MedChrgitm = "08"
  13498. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13499. iteminfo.Amt = materialCostTotal
  13500. iteminfo.ClaaSumfee = material_claa_sunmfee
  13501. iteminfo.ClabAmt = material_clab_amt
  13502. iteminfo.OthAmt = material_other_amt
  13503. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13504. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13505. }
  13506. if westernMedicineCostTotal != 0 {
  13507. iteminfo.MedChrgitm = "09"
  13508. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13509. iteminfo.Amt = westernMedicineCostTotal
  13510. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13511. iteminfo.ClabAmt = westernMedicine_clab_amt
  13512. iteminfo.OthAmt = westernMedicine_other_amt
  13513. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13514. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13515. }
  13516. if chineseTraditionalMedicineCostTotal != 0 {
  13517. iteminfo.MedChrgitm = "11"
  13518. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13519. iteminfo.Amt = westernMedicineCostTotal
  13520. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13521. iteminfo.ClabAmt = westernMedicine_clab_amt
  13522. iteminfo.OthAmt = westernMedicine_other_amt
  13523. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13524. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13525. }
  13526. if otherCostTotal != 0 {
  13527. iteminfo.MedChrgitm = "14"
  13528. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13529. iteminfo.Amt = otherCostTotal
  13530. iteminfo.ClaaSumfee = other_claa_sunmfee
  13531. iteminfo.ClabAmt = other_clab_amt
  13532. iteminfo.OthAmt = other_other_amt
  13533. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13534. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13535. }
  13536. struct4101.IteminfoStruct = iteminfoStructs
  13537. struct4101.Ntly = "中国"
  13538. struct4101.AdmCaty = "A03.06"
  13539. struct4101.DoctorName = doctor.UserName
  13540. struct4101.DoctorCode = doctor.DoctorNumber
  13541. var res ResultSeventeen
  13542. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13543. struct4101.BillCode = order.Number
  13544. struct4101.BillNo = order.SetlId
  13545. var resOther ResultSeventeenOther
  13546. var pp models.PublicParams
  13547. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13548. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13549. pp.FixmedinsName = miConfig.OrgName
  13550. pp.FixmedinsCode = miConfig.Code
  13551. pp.RequestUrl = miConfig.Url
  13552. pp.Cainfo = miConfig.Cainfo
  13553. pp.SecretKey = miConfig.SecretKey
  13554. pp.AccessKey = miConfig.AccessKey
  13555. pp.OpterName = curRoles.UserName
  13556. client := &http.Client{}
  13557. var req *http.Request
  13558. data := make(map[string]interface{})
  13559. data["struct4101"] = struct4101
  13560. data["pp"] = pp
  13561. bytesData, _ := json.Marshal(data)
  13562. if miConfig.MdtrtareaAdmvs == "320921" {
  13563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13564. } else {
  13565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13566. }
  13567. resp, _ := client.Do(req)
  13568. defer resp.Body.Close()
  13569. body, ioErr := ioutil.ReadAll(resp.Body)
  13570. if ioErr != nil {
  13571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13573. return
  13574. }
  13575. var respJSON map[string]interface{}
  13576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13579. return
  13580. }
  13581. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13582. userJSONBytes, _ := json.Marshal(respJSON)
  13583. fmt.Println("log")
  13584. fmt.Println(string(userJSONBytes))
  13585. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13586. utils.ErrorLog("解析失败:%v", err)
  13587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13588. return
  13589. }
  13590. res.InfRefmsgid = resOther.InfRefmsgid
  13591. res.Output = resOther.Output
  13592. res.ErrMsg = resOther.ErrMsg
  13593. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13594. res.Infcode = infocode
  13595. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13596. var pp models.PublicParams
  13597. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13598. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13599. pp.FixmedinsName = miConfig.OrgName
  13600. pp.FixmedinsCode = miConfig.Code
  13601. pp.RequestUrl = miConfig.Url
  13602. pp.Cainfo = miConfig.Cainfo
  13603. pp.SecretKey = miConfig.SecretKey
  13604. pp.AccessKey = miConfig.AccessKey
  13605. pp.OpterName = curRoles.UserName
  13606. result, _ := service.Jxyb4101(struct4101, pp)
  13607. var dat map[string]interface{}
  13608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13609. fmt.Println(dat)
  13610. } else {
  13611. fmt.Println(err)
  13612. }
  13613. userJSONBytes, _ := json.Marshal(dat)
  13614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13615. utils.ErrorLog("解析失败:%v", err)
  13616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13617. return
  13618. }
  13619. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13620. var pp models.PublicParams
  13621. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13622. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13623. pp.FixmedinsName = miConfig.OrgName
  13624. pp.FixmedinsCode = miConfig.Code
  13625. pp.RequestUrl = miConfig.Url
  13626. pp.Cainfo = miConfig.Cainfo
  13627. pp.SecretKey = miConfig.SecretKey
  13628. pp.AccessKey = miConfig.AccessKey
  13629. pp.OpterName = curRoles.UserName
  13630. result, _ := service.Hnyb4101(struct4101, pp)
  13631. var dat map[string]interface{}
  13632. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13633. fmt.Println(dat)
  13634. } else {
  13635. fmt.Println(err)
  13636. }
  13637. userJSONBytes, _ := json.Marshal(dat)
  13638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13639. utils.ErrorLog("解析失败:%v", err)
  13640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13641. return
  13642. }
  13643. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13644. var resOther ResultSeventeenOther
  13645. var pp models.PublicParams
  13646. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13647. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13648. pp.FixmedinsName = miConfig.OrgName
  13649. pp.FixmedinsCode = miConfig.Code
  13650. pp.RequestUrl = miConfig.Url
  13651. pp.Cainfo = miConfig.Cainfo
  13652. pp.SecretKey = miConfig.SecretKey
  13653. pp.AccessKey = miConfig.AccessKey
  13654. pp.OpterName = curRoles.UserName
  13655. client := &http.Client{}
  13656. var req *http.Request
  13657. data := make(map[string]interface{})
  13658. data["struct4101"] = struct4101
  13659. data["pp"] = pp
  13660. bytesData, _ := json.Marshal(data)
  13661. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13662. resp, _ := client.Do(req)
  13663. defer resp.Body.Close()
  13664. body, ioErr := ioutil.ReadAll(resp.Body)
  13665. if ioErr != nil {
  13666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13668. return
  13669. }
  13670. var respJSON map[string]interface{}
  13671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13674. return
  13675. }
  13676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13677. userJSONBytes, _ := json.Marshal(respJSON)
  13678. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13679. utils.ErrorLog("解析失败:%v", err)
  13680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13681. return
  13682. }
  13683. res.InfRefmsgid = resOther.InfRefmsgid
  13684. res.Output = resOther.Output
  13685. res.ErrMsg = resOther.ErrMsg
  13686. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13687. res.Infcode = infocode
  13688. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13689. var pp models.PublicParams
  13690. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13691. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13692. pp.FixmedinsName = miConfig.OrgName
  13693. pp.FixmedinsCode = miConfig.Code
  13694. pp.RequestUrl = miConfig.Url
  13695. pp.Cainfo = miConfig.Cainfo
  13696. pp.SecretKey = miConfig.SecretKey
  13697. pp.AccessKey = miConfig.AccessKey
  13698. pp.OpterName = curRoles.UserName
  13699. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13700. fmt.Println(requestLog)
  13701. fmt.Println(errMsgLog)
  13702. saveLog(result, requestLog, "4101a", "上传清单")
  13703. var dat map[string]interface{}
  13704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13705. fmt.Println(dat)
  13706. } else {
  13707. fmt.Println(err)
  13708. }
  13709. userJSONBytes, _ := json.Marshal(dat)
  13710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13711. utils.ErrorLog("解析失败:%v", err)
  13712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13713. return
  13714. }
  13715. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13716. var pp models.PublicParams
  13717. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13718. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13719. pp.FixmedinsName = miConfig.OrgName
  13720. pp.FixmedinsCode = miConfig.Code
  13721. pp.RequestUrl = miConfig.Url
  13722. pp.Cainfo = miConfig.Cainfo
  13723. pp.SecretKey = miConfig.SecretKey
  13724. pp.AccessKey = miConfig.AccessKey
  13725. pp.OpterName = curRoles.UserName
  13726. client := &http.Client{}
  13727. var req *http.Request
  13728. data := make(map[string]interface{})
  13729. data["struct4101"] = struct4101
  13730. data["pp"] = pp
  13731. bytesData, _ := json.Marshal(data)
  13732. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13733. resp, _ := client.Do(req)
  13734. defer resp.Body.Close()
  13735. body, ioErr := ioutil.ReadAll(resp.Body)
  13736. if ioErr != nil {
  13737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13739. return
  13740. }
  13741. var respJSON map[string]interface{}
  13742. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13745. return
  13746. }
  13747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13748. userJSONBytes, _ := json.Marshal(respJSON)
  13749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13750. utils.ErrorLog("解析失败:%v", err)
  13751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13752. return
  13753. }
  13754. } else {
  13755. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13756. var dat map[string]interface{}
  13757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13758. fmt.Println(dat)
  13759. } else {
  13760. fmt.Println(err)
  13761. }
  13762. userJSONBytes, _ := json.Marshal(dat)
  13763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13764. utils.ErrorLog("解析失败:%v", err)
  13765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13766. return
  13767. }
  13768. }
  13769. if res.Infcode != 0 {
  13770. c.ServeSuccessJSON(map[string]interface{}{
  13771. "failed_code": -10,
  13772. "msg": res.ErrMsg,
  13773. })
  13774. return
  13775. } else {
  13776. //order.FaPiaoNumber = zero
  13777. //order.FaPiaoCode = last_order.FaPiaoCode
  13778. //service.UpdateOrder(order)
  13779. hisFundSettleListResult := &models.HisFundSettleListResult{
  13780. Number: res.Output.SetlListId,
  13781. Status: 1,
  13782. Ctime: time.Now().Unix(),
  13783. Mtime: time.Now().Unix(),
  13784. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13785. IsUpload: 1,
  13786. OrderId: order_id,
  13787. }
  13788. service.CreateUploadRecord(hisFundSettleListResult)
  13789. c.ServeSuccessJSON(map[string]interface{}{
  13790. "msg": "上传成功",
  13791. "result": hisFundSettleListResult,
  13792. })
  13793. return
  13794. }
  13795. }
  13796. func (c *HisApiController) GetSettleListHospital() {
  13797. order_id, _ := c.GetInt64("order_id")
  13798. admin_user_id, _ := c.GetInt64("admin_user_id")
  13799. order, _ := service.GetHisOrderByIDTwo(order_id)
  13800. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13801. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13802. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13803. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13804. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13805. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13806. if order.ID == 0 {
  13807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13808. return
  13809. }
  13810. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13811. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13812. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13813. fmt.Println(count)
  13814. var zero string
  13815. number := count + 1
  13816. if number >= 1000 {
  13817. zero = "0000" + strconv.FormatInt(number, 10)
  13818. } else if number >= 10000 {
  13819. zero = "000" + strconv.FormatInt(number, 10)
  13820. } else if number >= 100000 {
  13821. zero = "00" + strconv.FormatInt(number, 10)
  13822. } else if number >= 1000000 {
  13823. zero = "0" + strconv.FormatInt(number, 10)
  13824. } else {
  13825. zero = strconv.FormatInt(number, 10)
  13826. }
  13827. fmt.Println(zero)
  13828. struct4101 := service.Struct4101{
  13829. PsnNo: order.PsnNo,
  13830. MdtrtId: order.MdtrtId,
  13831. SetlId: order.SetlId,
  13832. PsnName: order.PsnName,
  13833. Gend: order.Gend,
  13834. Brdy: his.Brdy,
  13835. Age: int64(order.Age),
  13836. Naty: order.Naty,
  13837. PatnCertType: "01",
  13838. Certno: order.Certno,
  13839. Prfs: "90",
  13840. ConerName: roles[0].UserName,
  13841. PatnRlts: "99",
  13842. ConerAddr: miConfig.OrgName,
  13843. ConerTel: admin.Mobile,
  13844. HiType: order.Insutype,
  13845. Insuplc: miConfig.InsuplcAdmdvs,
  13846. MaindiagFlag: "1",
  13847. BillCode: order.SetlId,
  13848. BillNo: order.SetlId,
  13849. BizSn: order.Number,
  13850. PsnSelfPay: order.PsnPartAmt,
  13851. PsnOwnPay: order.PsnPartAmt,
  13852. AcctPay: order.AcctPay,
  13853. PsnCashpay: order.PsnCashPay,
  13854. HiPaymtd: "1",
  13855. Hsorg: miConfig.InsuplcAdmdvs,
  13856. HsorgOpter: miConfig.InsuplcAdmdvs,
  13857. MedinsFillPsn: curRoles.UserName,
  13858. MedinsFillDept: depart.Name,
  13859. IptMedType: "2",
  13860. AdmTime: his.InHosptialTime,
  13861. AdmEndTime: his.OutHosptialTime,
  13862. }
  13863. struct4101.SetlBegnDate = order.SetlTime
  13864. struct4101.SetlEndDate = order.SetlTime
  13865. //var rf []CustomFundPay
  13866. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13867. //
  13868. //var tempFunPays []service.CustomStruct
  13869. //for _, item := range rf {
  13870. // var tempFunPay service.CustomStruct
  13871. // tempFunPay.FundPayamt = item.FundPayamt
  13872. // tempFunPay.FundPayType = item.FundPayType
  13873. // tempFunPays = append(tempFunPays, tempFunPay)
  13874. //}
  13875. //struct4101.CustomStruct = tempFunPays
  13876. var tempDiaginfos []service.DiaginfoStructTwo
  13877. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13878. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13879. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13880. //for _, item := range infos {
  13881. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13882. //}
  13883. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13884. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13885. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13886. fmt.Println(diagnosis_ids_arr)
  13887. if order.UserOrgId == 10210 {
  13888. var diagnosis_ids_arr_two []int64
  13889. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13890. var config []*models.HisXtDiagnoseConfig
  13891. for _, id := range diagnosis_ids_arr_two {
  13892. //id, _ := strconv.ParseInt(item, 10, 64)
  13893. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13894. if diagnosisConfig.ID > 0 {
  13895. config = append(config, &diagnosisConfig)
  13896. }
  13897. }
  13898. for index, item := range config {
  13899. if item.ID > 0 {
  13900. if index == 0 {
  13901. var tempDiaginfo service.DiaginfoStructTwo
  13902. tempDiaginfo.DiagCode = item.CountryCode
  13903. tempDiaginfo.DiagName = item.CountryContentName
  13904. tempDiaginfo.DiagType = "1"
  13905. tempDiaginfo.MaindiagFlag = "1"
  13906. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13907. } else {
  13908. var tempDiaginfo service.DiaginfoStructTwo
  13909. tempDiaginfo.DiagCode = item.CountryCode
  13910. tempDiaginfo.DiagName = item.CountryContentName
  13911. tempDiaginfo.DiagType = "1"
  13912. tempDiaginfo.MaindiagFlag = "0"
  13913. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13914. }
  13915. }
  13916. }
  13917. struct4101.Diseinfo = tempDiaginfos
  13918. } else {
  13919. var config []*models.HisXtDiagnoseConfig
  13920. for _, item := range diagnosis_ids_arr {
  13921. id, _ := strconv.ParseInt(item, 10, 64)
  13922. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13923. if diagnosisConfig.ID > 0 {
  13924. config = append(config, &diagnosisConfig)
  13925. }
  13926. }
  13927. for index, item := range config {
  13928. if item.ID > 0 {
  13929. if index == 0 {
  13930. var tempDiaginfo service.DiaginfoStructTwo
  13931. tempDiaginfo.DiagCode = item.CountryCode
  13932. tempDiaginfo.DiagName = item.CountryContentName
  13933. tempDiaginfo.DiagType = "1"
  13934. tempDiaginfo.MaindiagFlag = "1"
  13935. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13936. } else {
  13937. var tempDiaginfo service.DiaginfoStructTwo
  13938. tempDiaginfo.DiagCode = item.CountryCode
  13939. tempDiaginfo.DiagName = item.CountryContentName
  13940. tempDiaginfo.DiagType = "1"
  13941. tempDiaginfo.MaindiagFlag = "0"
  13942. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13943. }
  13944. }
  13945. }
  13946. struct4101.Diseinfo = tempDiaginfos
  13947. }
  13948. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13949. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13950. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13951. tempOpspdiseinfo2.OprnOprtCode = ""
  13952. tempOpspdiseinfo2.OprnOprtName = ""
  13953. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13954. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13955. var iteminfo service.IteminfoStruct
  13956. var bedCostTotal float64 = 0 //床位总费
  13957. var bedCostSelfTotal float64 = 0 //床位自费
  13958. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13959. var operationCostTotal float64 = 0 //手术费
  13960. var operationCostSelfTotal float64 = 0 //手术费
  13961. var operationCostPartSelfTotal float64 = 0 //手术费
  13962. var otherCostTotal float64 = 0 //其他费用
  13963. var otherCostSelfTotal float64 = 0 //其他费用
  13964. var otherCostPartSelfTotal float64 = 0 //其他费用
  13965. var materialCostTotal float64 = 0 //材料费
  13966. var materialCostSelfTotal float64 = 0 //材料费
  13967. var materialCostPartSelfTotal float64 = 0 //材料费
  13968. var westernMedicineCostTotal float64 = 0 //西药费
  13969. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13970. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13971. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13972. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13973. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13974. var checkCostTotal float64 = 0 //检查费
  13975. var checkCostSelfTotal float64 = 0 //检查费
  13976. var checkCostPartSelfTotal float64 = 0 //检查费
  13977. var laboratoryCostTotal float64 = 0 //化验费
  13978. var laboratoryCostSelfTotal float64 = 0 //化验费
  13979. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13980. var treatCostTotal float64 = 0 //治疗费用
  13981. var treatCostSelfTotal float64 = 0 //治疗费用
  13982. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13983. decimal.DivisionPrecision = 2
  13984. var bed_fulamt_ownpay_amt float64 = 0
  13985. var operation_fulamt_ownpay_amt float64 = 0
  13986. var other_fulamt_ownpay_amt float64 = 0
  13987. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13988. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13989. var check_fulamt_ownpay_amt float64 = 0
  13990. var material_fulamt_ownpay_amt float64 = 0
  13991. var laboratory_fulamt_ownpay_amt float64 = 0
  13992. var treat_fulamt_ownpay_amt float64 = 0
  13993. var bed_claa_sunmfee float64 = 0
  13994. var bed_clab_amt float64 = 0
  13995. var bed_other_amt float64 = 0
  13996. var operation_claa_sunmfee float64 = 0
  13997. var operation_clab_amt float64 = 0
  13998. var operation_other_amt float64 = 0
  13999. var other_claa_sunmfee float64 = 0
  14000. var other_clab_amt float64 = 0
  14001. var other_other_amt float64 = 0
  14002. var westernMedicine_claa_sunmfee float64 = 0
  14003. var westernMedicine_clab_amt float64 = 0
  14004. var westernMedicine_other_amt float64 = 0
  14005. var chineseTraditional_claa_sunmfee float64 = 0
  14006. var chineseTraditional_clab_amt float64 = 0
  14007. var chineseTraditional_other_amt float64 = 0
  14008. var check_claa_sunmfee float64 = 0
  14009. var check_clab_amt float64 = 0
  14010. var check_other_amt float64 = 0
  14011. var material_claa_sunmfee float64 = 0
  14012. var material_clab_amt float64 = 0
  14013. var material_other_amt float64 = 0
  14014. var laboratory_claa_sunmfee float64 = 0
  14015. var laboratory_clab_amt float64 = 0
  14016. var laboratory_other_amt float64 = 0
  14017. var treat_claa_sunmfee float64 = 0
  14018. var treat_clab_amt float64 = 0
  14019. var treat_other_amt float64 = 0
  14020. for _, item := range order.HisOrderInfo {
  14021. if item.MedChrgitmType == "01" { //床位费
  14022. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14023. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14024. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14025. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14026. if item.ChrgitmLv == "1" {
  14027. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14028. }
  14029. if item.ChrgitmLv == "2" {
  14030. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14031. }
  14032. if item.ChrgitmLv == "3" {
  14033. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14034. }
  14035. }
  14036. if item.MedChrgitmType == "03" { //检查费
  14037. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14038. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14039. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14040. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14041. if item.ChrgitmLv == "1" {
  14042. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14043. }
  14044. if item.ChrgitmLv == "2" {
  14045. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14046. }
  14047. if item.ChrgitmLv == "3" {
  14048. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14049. }
  14050. }
  14051. if item.MedChrgitmType == "04" { //化验费
  14052. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14053. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14054. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14055. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14056. if item.ChrgitmLv == "1" {
  14057. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14058. }
  14059. if item.ChrgitmLv == "2" {
  14060. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14061. }
  14062. if item.ChrgitmLv == "3" {
  14063. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14064. }
  14065. }
  14066. if item.MedChrgitmType == "05" { //治疗费
  14067. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14068. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14069. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14070. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14071. if item.ChrgitmLv == "1" {
  14072. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14073. }
  14074. if item.ChrgitmLv == "2" {
  14075. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14076. }
  14077. if item.ChrgitmLv == "3" {
  14078. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14079. }
  14080. }
  14081. if item.MedChrgitmType == "06" { //手术费
  14082. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14083. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14084. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14085. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14086. if item.ChrgitmLv == "1" {
  14087. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14088. }
  14089. if item.ChrgitmLv == "2" {
  14090. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14091. }
  14092. if item.ChrgitmLv == "3" {
  14093. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14094. }
  14095. }
  14096. if item.MedChrgitmType == "08" { //材料费
  14097. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14098. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14099. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14100. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14101. if item.ChrgitmLv == "1" {
  14102. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14103. }
  14104. if item.ChrgitmLv == "2" {
  14105. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14106. }
  14107. if item.ChrgitmLv == "3" {
  14108. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14109. }
  14110. }
  14111. if item.MedChrgitmType == "09" { //西药费
  14112. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14113. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14114. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14115. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14116. if item.ChrgitmLv == "1" {
  14117. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14118. }
  14119. if item.ChrgitmLv == "2" {
  14120. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14121. }
  14122. if item.ChrgitmLv == "3" {
  14123. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14124. }
  14125. }
  14126. if item.MedChrgitmType == "11" { //中成费
  14127. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14128. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14129. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14130. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14131. if item.ChrgitmLv == "1" {
  14132. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14133. }
  14134. if item.ChrgitmLv == "2" {
  14135. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14136. }
  14137. if item.ChrgitmLv == "3" {
  14138. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14139. }
  14140. }
  14141. if item.MedChrgitmType == "14" { //其他费
  14142. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14143. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14144. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14145. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14146. if item.ChrgitmLv == "1" {
  14147. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14148. }
  14149. if item.ChrgitmLv == "2" {
  14150. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14151. }
  14152. if item.ChrgitmLv == "3" {
  14153. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14154. }
  14155. }
  14156. }
  14157. var iteminfoStructs []service.IteminfoStruct
  14158. if bedCostTotal != 0 {
  14159. iteminfo.MedChrgitm = "01"
  14160. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14161. iteminfo.Amt = bedCostTotal
  14162. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14163. iteminfo.ClabAmt = bed_clab_amt
  14164. iteminfo.OthAmt = bed_other_amt
  14165. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14166. }
  14167. if checkCostTotal != 0 {
  14168. iteminfo.MedChrgitm = "03"
  14169. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14170. iteminfo.Amt = checkCostTotal
  14171. iteminfo.ClaaSumfee = check_claa_sunmfee
  14172. iteminfo.ClabAmt = check_clab_amt
  14173. iteminfo.OthAmt = check_other_amt
  14174. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14175. }
  14176. if laboratoryCostTotal != 0 {
  14177. iteminfo.MedChrgitm = "04"
  14178. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14179. iteminfo.Amt = laboratoryCostTotal
  14180. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14181. iteminfo.ClabAmt = laboratory_clab_amt
  14182. iteminfo.OthAmt = laboratory_other_amt
  14183. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14184. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14185. }
  14186. if treatCostTotal != 0 {
  14187. iteminfo.MedChrgitm = "05"
  14188. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14189. iteminfo.Amt = treatCostTotal
  14190. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14191. iteminfo.ClabAmt = treat_clab_amt
  14192. iteminfo.OthAmt = treat_other_amt
  14193. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14194. //(struct4101.IteminfoStruct, iteminfo)
  14195. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14196. }
  14197. if operationCostTotal != 0 {
  14198. iteminfo.MedChrgitm = "06"
  14199. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14200. iteminfo.Amt = operationCostTotal
  14201. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14202. iteminfo.ClabAmt = operation_clab_amt
  14203. iteminfo.OthAmt = operation_other_amt
  14204. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14205. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14206. }
  14207. if materialCostTotal != 0 {
  14208. iteminfo.MedChrgitm = "08"
  14209. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14210. iteminfo.Amt = materialCostTotal
  14211. iteminfo.ClaaSumfee = material_claa_sunmfee
  14212. iteminfo.ClabAmt = material_clab_amt
  14213. iteminfo.OthAmt = material_other_amt
  14214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14215. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14216. }
  14217. if westernMedicineCostTotal != 0 {
  14218. iteminfo.MedChrgitm = "09"
  14219. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14220. iteminfo.Amt = westernMedicineCostTotal
  14221. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14222. iteminfo.ClabAmt = westernMedicine_clab_amt
  14223. iteminfo.OthAmt = westernMedicine_other_amt
  14224. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14225. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14226. }
  14227. if chineseTraditionalMedicineCostTotal != 0 {
  14228. iteminfo.MedChrgitm = "11"
  14229. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14230. iteminfo.Amt = westernMedicineCostTotal
  14231. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14232. iteminfo.ClabAmt = westernMedicine_clab_amt
  14233. iteminfo.OthAmt = westernMedicine_other_amt
  14234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14236. }
  14237. if otherCostTotal != 0 {
  14238. iteminfo.MedChrgitm = "14"
  14239. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14240. iteminfo.Amt = otherCostTotal
  14241. iteminfo.ClaaSumfee = other_claa_sunmfee
  14242. iteminfo.ClabAmt = other_clab_amt
  14243. iteminfo.OthAmt = other_other_amt
  14244. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14245. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14246. }
  14247. struct4101.IteminfoStruct = iteminfoStructs
  14248. struct4101.Ntly = "中国"
  14249. struct4101.AdmCaty = "A03.06"
  14250. var resOther ResultSeventeenOther
  14251. var res ResultSeventeen
  14252. if miConfig.MdtrtareaAdmvs == "150499" {
  14253. var pp models.PublicParams
  14254. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14255. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14256. pp.FixmedinsName = miConfig.OrgName
  14257. pp.FixmedinsCode = miConfig.Code
  14258. pp.RequestUrl = miConfig.Url
  14259. pp.Cainfo = miConfig.Cainfo
  14260. pp.SecretKey = miConfig.SecretKey
  14261. pp.AccessKey = miConfig.AccessKey
  14262. pp.OpterName = curRoles.UserName
  14263. client := &http.Client{}
  14264. var req *http.Request
  14265. data := make(map[string]interface{})
  14266. data["struct4101"] = struct4101
  14267. data["pp"] = pp
  14268. bytesData, _ := json.Marshal(data)
  14269. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14270. resp, _ := client.Do(req)
  14271. defer resp.Body.Close()
  14272. body, ioErr := ioutil.ReadAll(resp.Body)
  14273. if ioErr != nil {
  14274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14276. return
  14277. }
  14278. var respJSON map[string]interface{}
  14279. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14282. return
  14283. }
  14284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14285. userJSONBytes, _ := json.Marshal(respJSON)
  14286. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14287. utils.ErrorLog("解析失败:%v", err)
  14288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14289. return
  14290. }
  14291. res.InfRefmsgid = resOther.InfRefmsgid
  14292. res.Output = resOther.Output
  14293. res.ErrMsg = resOther.ErrMsg
  14294. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14295. res.Infcode = infocode
  14296. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14297. var pp models.PublicParams
  14298. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14299. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14300. pp.FixmedinsName = miConfig.OrgName
  14301. pp.FixmedinsCode = miConfig.Code
  14302. pp.RequestUrl = miConfig.Url
  14303. pp.Cainfo = miConfig.Cainfo
  14304. pp.SecretKey = miConfig.SecretKey
  14305. pp.AccessKey = miConfig.AccessKey
  14306. pp.OpterName = curRoles.UserName
  14307. result, _ := service.Jxyb4101(struct4101, pp)
  14308. var dat map[string]interface{}
  14309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14310. fmt.Println(dat)
  14311. } else {
  14312. fmt.Println(err)
  14313. }
  14314. userJSONBytes, _ := json.Marshal(dat)
  14315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14316. utils.ErrorLog("解析失败:%v", err)
  14317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14318. return
  14319. }
  14320. } else {
  14321. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14322. var dat map[string]interface{}
  14323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14324. fmt.Println(dat)
  14325. } else {
  14326. fmt.Println(err)
  14327. }
  14328. userJSONBytes, _ := json.Marshal(dat)
  14329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14330. utils.ErrorLog("解析失败:%v", err)
  14331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14332. return
  14333. }
  14334. }
  14335. if res.Infcode != 0 {
  14336. c.ServeSuccessJSON(map[string]interface{}{
  14337. "failed_code": -10,
  14338. "msg": res.ErrMsg,
  14339. })
  14340. return
  14341. } else {
  14342. if miConfig.MdtrtareaAdmvs != "150499" {
  14343. order.FaPiaoNumber = zero
  14344. order.FaPiaoCode = last_order.FaPiaoCode
  14345. service.UpdateOrder(order)
  14346. }
  14347. hisFundSettleListResult := &models.HisFundSettleListResult{
  14348. Number: res.Output.SetlListId,
  14349. Status: 1,
  14350. Ctime: time.Now().Unix(),
  14351. Mtime: time.Now().Unix(),
  14352. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14353. IsUpload: 1,
  14354. OrderId: order_id,
  14355. }
  14356. service.CreateUploadRecord(hisFundSettleListResult)
  14357. c.ServeSuccessJSON(map[string]interface{}{
  14358. "msg": "上传成功",
  14359. "result": hisFundSettleListResult,
  14360. })
  14361. return
  14362. }
  14363. }
  14364. //func (c *HisApiController) GetBatchSettleList() {
  14365. // orders, _ := service.GetAllHisOrder(10106)
  14366. // for _, item := range orders {
  14367. // order_id := item.ID
  14368. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14369. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14370. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14371. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14372. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14373. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14374. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14375. //
  14376. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14377. //
  14378. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14379. //
  14380. // if order.ID == 0 {
  14381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14382. // return
  14383. // }
  14384. // if his.BalanceAccountsType == 2 {
  14385. // continue
  14386. // }
  14387. // struct4101 := service.Struct4101{
  14388. // PsnNo: order.PsnNo,
  14389. // MdtrtId: order.MdtrtId,
  14390. // SetlId: order.SetlId,
  14391. // PsnName: order.PsnName,
  14392. // Gend: order.Gend,
  14393. // Brdy: his.Brdy,
  14394. // Age: his.Age,
  14395. // Naty: order.Naty,
  14396. // PatnCertType: "01",
  14397. // Certno: order.Certno,
  14398. // Prfs: "90",
  14399. // ConerName: roles[0].UserName,
  14400. // PatnRlts: "99",
  14401. // ConerAddr: miConfig.OrgName,
  14402. // ConerTel: admin.Mobile,
  14403. // HiType: order.Insutype,
  14404. // Insuplc: his.InsuplcAdmdvs,
  14405. // MaindiagFlag: "1",
  14406. // BillCode: order.SetlId,
  14407. // BillNo: order.SetlId,
  14408. // BizSn: order.Number,
  14409. // PsnSelfPay: order.PsnPartAmt,
  14410. // PsnOwnPay: order.PsnPartAmt,
  14411. // AcctPay: order.AcctPay,
  14412. // PsnCashpay: order.PsnCashPay,
  14413. // HiPaymtd: "1",
  14414. // Hsorg: his.InsuplcAdmdvs,
  14415. // HsorgOpter: his.InsuplcAdmdvs,
  14416. // MedinsFillPsn: curRoles.UserName,
  14417. // MedinsFillDept: depart.Name,
  14418. // IptMedType: "2",
  14419. // }
  14420. // struct4101.SetlBegnDate = order.SetlTime
  14421. // struct4101.SetlEndDate = order.SetlTime
  14422. // //if order.SettleType == 1 {
  14423. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14424. // // dateStr := t.Format("2006-01-02")
  14425. // // struct4101.SetlBegnDate = dateStr
  14426. // // struct4101.SetlEndDate = dateStr
  14427. // //} else {
  14428. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14429. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14430. // // dateStartStr := t.Format("2006-01-02")
  14431. // // dateEndStr := t2.Format("2006-01-02")
  14432. // // struct4101.SetlBegnDate = dateStartStr
  14433. // // struct4101.SetlEndDate = dateEndStr
  14434. // //}
  14435. //
  14436. // var rf []CustomFundPay
  14437. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14438. //
  14439. // var tempFunPays []service.CustomStruct
  14440. // var tempFunPay610100 service.CustomStruct
  14441. //
  14442. // for _, item := range rf {
  14443. // if item.FundPayType == "610100" {
  14444. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14445. // tempFunPay610100.FundPayType = item.FundPayType
  14446. // } else {
  14447. // var tempFunPay service.CustomStruct
  14448. // tempFunPay.FundPayamt = item.FundPayamt
  14449. // tempFunPay.FundPayType = item.FundPayType
  14450. // tempFunPays = append(tempFunPays, tempFunPay)
  14451. // }
  14452. // }
  14453. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14454. // struct4101.CustomStruct = tempFunPays
  14455. //
  14456. // var tempDiaginfos []service.DiaginfoStructTwo
  14457. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14458. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14459. //
  14460. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14461. // var config []*models.HisXtDiagnoseConfig
  14462. // for _, item := range diagnosis_ids {
  14463. // id, _ := strconv.ParseInt(item, 10, 64)
  14464. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14465. // config = append(config, &diagnosisConfig)
  14466. // }
  14467. //
  14468. // for index, item := range config {
  14469. // if index == 0 {
  14470. // var tempDiaginfo service.DiaginfoStructTwo
  14471. // tempDiaginfo.DiagCode = item.CountryCode
  14472. // tempDiaginfo.DiagName = item.CountryContentName
  14473. // tempDiaginfo.DiagType = "1"
  14474. // tempDiaginfo.MaindiagFlag = "1"
  14475. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14476. // } else {
  14477. //
  14478. // var tempDiaginfo service.DiaginfoStructTwo
  14479. // tempDiaginfo.DiagCode = item.CountryCode
  14480. // tempDiaginfo.DiagName = item.CountryContentName
  14481. // tempDiaginfo.DiagType = "2"
  14482. // tempDiaginfo.MaindiagFlag = "0"
  14483. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14484. // }
  14485. // }
  14486. // struct4101.Diseinfo = tempDiaginfos
  14487. //
  14488. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14489. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14490. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14491. // tempOpspdiseinfo2.OprnOprtCode = ""
  14492. // tempOpspdiseinfo2.OprnOprtName = ""
  14493. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14494. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14495. //
  14496. // var iteminfo service.IteminfoStruct
  14497. //
  14498. // var bedCostTotal float64 = 0 //床位总费
  14499. // var bedCostSelfTotal float64 = 0 //床位自费
  14500. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14501. //
  14502. // var examineCostTotal float64 = 0 //诊查总费
  14503. // var examineCostSelfTotal float64 = 0 //诊查自费
  14504. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14505. //
  14506. // var nursingCostTotal float64 = 0 //护理总费
  14507. // var nursingCostSelfTotal float64 = 0 //护理自费
  14508. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14509. //
  14510. // var chineseMedicineCostTotal float64 = 0 //中成药
  14511. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14512. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14513. //
  14514. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14515. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14516. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14517. //
  14518. // var registerCostTotal float64 = 0 //一般诊疗费
  14519. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14520. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14521. //
  14522. // var operationCostTotal float64 = 0 //手术费
  14523. // var operationCostSelfTotal float64 = 0 //手术费
  14524. // var operationCostPartSelfTotal float64 = 0 //手术费
  14525. //
  14526. // var otherCostTotal float64 = 0 //其他费用
  14527. // var otherCostSelfTotal float64 = 0 //其他费用
  14528. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14529. //
  14530. // var materialCostTotal float64 = 0 //材料费
  14531. // var materialCostSelfTotal float64 = 0 //材料费
  14532. // var materialCostPartSelfTotal float64 = 0 //材料费
  14533. //
  14534. // var westernMedicineCostTotal float64 = 0 //西药费
  14535. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14536. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14537. //
  14538. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14539. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14540. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14541. //
  14542. // var checkCostTotal float64 = 0 //检查费
  14543. // var checkCostSelfTotal float64 = 0 //检查费
  14544. // var checkCostPartSelfTotal float64 = 0 //检查费
  14545. //
  14546. // var laboratoryCostTotal float64 = 0 //化验费
  14547. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14548. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14549. //
  14550. // var treatCostTotal float64 = 0 //治疗费用
  14551. // var treatCostSelfTotal float64 = 0 //治疗费用
  14552. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14553. //
  14554. // decimal.DivisionPrecision = 2
  14555. //
  14556. // var bed_fulamt_ownpay_amt float64 = 0
  14557. //
  14558. // var examine_fulamt_ownpay_amt float64 = 0
  14559. //
  14560. // var nursing_fulamt_ownpay_amt float64 = 0
  14561. //
  14562. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14563. //
  14564. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14565. //
  14566. // var register_fulamt_ownpay_amt float64 = 0
  14567. //
  14568. // var operation_fulamt_ownpay_amt float64 = 0
  14569. // var other_fulamt_ownpay_amt float64 = 0
  14570. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14571. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14572. // var check_fulamt_ownpay_amt float64 = 0
  14573. // var material_fulamt_ownpay_amt float64 = 0
  14574. // var laboratory_fulamt_ownpay_amt float64 = 0
  14575. // var treat_fulamt_ownpay_amt float64 = 0
  14576. //
  14577. // var bed_claa_sunmfee float64 = 0
  14578. // var bed_clab_amt float64 = 0
  14579. // var bed_other_amt float64 = 0
  14580. //
  14581. // var examine_claa_sunmfee float64 = 0
  14582. // var examine_clab_amt float64 = 0
  14583. // var examine_other_amt float64 = 0
  14584. //
  14585. // var nursing_claa_sunmfee float64 = 0
  14586. // var nursing_clab_amt float64 = 0
  14587. // var nursing_other_amt float64 = 0
  14588. //
  14589. // var chinese_medicine_claa_sunmfee float64 = 0
  14590. // var chinese_medicine_clab_amt float64 = 0
  14591. // var chinese_medicine_other_amt float64 = 0
  14592. //
  14593. // var commonly_treatment_claa_sunmfee float64 = 0
  14594. // var commonly_treatment_clab_amt float64 = 0
  14595. // var commonly_treatment_other_amt float64 = 0
  14596. //
  14597. // var operation_claa_sunmfee float64 = 0
  14598. // var operation_clab_amt float64 = 0
  14599. // var operation_other_amt float64 = 0
  14600. //
  14601. // var other_claa_sunmfee float64 = 0
  14602. // var other_clab_amt float64 = 0
  14603. // var other_other_amt float64 = 0
  14604. //
  14605. // var westernMedicine_claa_sunmfee float64 = 0
  14606. // var westernMedicine_clab_amt float64 = 0
  14607. // var westernMedicine_other_amt float64 = 0
  14608. //
  14609. // var chineseTraditional_claa_sunmfee float64 = 0
  14610. // var chineseTraditional_clab_amt float64 = 0
  14611. // var chineseTraditional_other_amt float64 = 0
  14612. //
  14613. // var check_claa_sunmfee float64 = 0
  14614. // var check_clab_amt float64 = 0
  14615. // var check_other_amt float64 = 0
  14616. //
  14617. // var material_claa_sunmfee float64 = 0
  14618. // var material_clab_amt float64 = 0
  14619. // var material_other_amt float64 = 0
  14620. //
  14621. // var laboratory_claa_sunmfee float64 = 0
  14622. // var laboratory_clab_amt float64 = 0
  14623. // var laboratory_other_amt float64 = 0
  14624. //
  14625. // var treat_claa_sunmfee float64 = 0
  14626. // var treat_clab_amt float64 = 0
  14627. // var treat_other_amt float64 = 0
  14628. //
  14629. // var register_claa_sunmfee float64 = 0
  14630. // var register_clab_amt float64 = 0
  14631. // var register_other_amt float64 = 0
  14632. //
  14633. // for _, item := range order.HisOrderInfo {
  14634. // if item.MedChrgitmType == "01" { //床位费
  14635. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14636. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14637. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14638. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14639. // if item.ChrgitmLv == "1" {
  14640. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14641. // }
  14642. // if item.ChrgitmLv == "2" {
  14643. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14644. //
  14645. // }
  14646. // if item.ChrgitmLv == "3" {
  14647. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14648. // }
  14649. //
  14650. // }
  14651. //
  14652. // if item.MedChrgitmType == "02" { //诊查
  14653. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14654. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14655. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14656. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14657. // if item.ChrgitmLv == "1" {
  14658. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14659. // }
  14660. // if item.ChrgitmLv == "2" {
  14661. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14662. //
  14663. // }
  14664. // if item.ChrgitmLv == "3" {
  14665. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14666. // }
  14667. //
  14668. // }
  14669. //
  14670. // if item.MedChrgitmType == "03" { //检查费
  14671. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14672. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14673. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14674. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14675. // if item.ChrgitmLv == "1" {
  14676. //
  14677. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14678. //
  14679. // }
  14680. // if item.ChrgitmLv == "2" {
  14681. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14682. //
  14683. // }
  14684. // if item.ChrgitmLv == "3" {
  14685. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14686. // }
  14687. // }
  14688. //
  14689. // if item.MedChrgitmType == "04" { //化验费
  14690. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14691. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14692. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14693. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14694. // if item.ChrgitmLv == "1" {
  14695. //
  14696. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14697. //
  14698. // }
  14699. // if item.ChrgitmLv == "2" {
  14700. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14701. //
  14702. // }
  14703. // if item.ChrgitmLv == "3" {
  14704. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14705. // }
  14706. // }
  14707. //
  14708. // if item.MedChrgitmType == "05" { //治疗费
  14709. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14710. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14711. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14712. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14713. // if item.ChrgitmLv == "1" {
  14714. //
  14715. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14716. //
  14717. // }
  14718. // if item.ChrgitmLv == "2" {
  14719. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14720. //
  14721. // }
  14722. // if item.ChrgitmLv == "3" {
  14723. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14724. // }
  14725. // }
  14726. //
  14727. // if item.MedChrgitmType == "06" { //手术费
  14728. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14729. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14730. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14731. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14732. //
  14733. // if item.ChrgitmLv == "1" {
  14734. //
  14735. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14736. //
  14737. // }
  14738. // if item.ChrgitmLv == "2" {
  14739. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14740. //
  14741. // }
  14742. // if item.ChrgitmLv == "3" {
  14743. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14744. // }
  14745. // }
  14746. //
  14747. // if item.MedChrgitmType == "07" { //手术费
  14748. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14749. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14750. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14751. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14752. //
  14753. // if item.ChrgitmLv == "1" {
  14754. //
  14755. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14756. //
  14757. // }
  14758. // if item.ChrgitmLv == "2" {
  14759. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14760. //
  14761. // }
  14762. // if item.ChrgitmLv == "3" {
  14763. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14764. // }
  14765. // }
  14766. //
  14767. // if item.MedChrgitmType == "08" { //材料费
  14768. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14769. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14770. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14771. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14772. // if item.ChrgitmLv == "1" {
  14773. //
  14774. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14775. //
  14776. // }
  14777. // if item.ChrgitmLv == "2" {
  14778. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14779. //
  14780. // }
  14781. // if item.ChrgitmLv == "3" {
  14782. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14783. // }
  14784. // }
  14785. // if item.MedChrgitmType == "09" { //西药费
  14786. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14787. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14788. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14789. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14790. // if item.ChrgitmLv == "1" {
  14791. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14792. // }
  14793. // if item.ChrgitmLv == "2" {
  14794. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14795. // }
  14796. // if item.ChrgitmLv == "3" {
  14797. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14798. // }
  14799. // }
  14800. // if item.MedChrgitmType == "10" { //中药饮片
  14801. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14802. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14803. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14804. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14805. // if item.ChrgitmLv == "1" {
  14806. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14807. // }
  14808. // if item.ChrgitmLv == "2" {
  14809. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14810. // }
  14811. // if item.ChrgitmLv == "3" {
  14812. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14813. // }
  14814. // }
  14815. //
  14816. // if item.MedChrgitmType == "11" { //中成费
  14817. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14818. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14819. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14820. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14821. // if item.ChrgitmLv == "1" {
  14822. //
  14823. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14824. //
  14825. // }
  14826. // if item.ChrgitmLv == "2" {
  14827. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14828. //
  14829. // }
  14830. // if item.ChrgitmLv == "3" {
  14831. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14832. // }
  14833. // }
  14834. //
  14835. // if item.MedChrgitmType == "12" { //中成费
  14836. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14837. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14838. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14839. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14840. // if item.ChrgitmLv == "1" {
  14841. //
  14842. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14843. //
  14844. // }
  14845. // if item.ChrgitmLv == "2" {
  14846. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14847. //
  14848. // }
  14849. // if item.ChrgitmLv == "3" {
  14850. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14851. // }
  14852. // }
  14853. //
  14854. // if item.MedChrgitmType == "13" { //中成费
  14855. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14856. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14857. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14858. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14859. // if item.ChrgitmLv == "1" {
  14860. //
  14861. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14862. //
  14863. // }
  14864. // if item.ChrgitmLv == "2" {
  14865. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14866. //
  14867. // }
  14868. // if item.ChrgitmLv == "3" {
  14869. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14870. // }
  14871. // }
  14872. //
  14873. // if item.MedChrgitmType == "14" { //其他费
  14874. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14875. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14876. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14877. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14878. // if item.ChrgitmLv == "1" {
  14879. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14880. //
  14881. // }
  14882. // if item.ChrgitmLv == "2" {
  14883. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14884. //
  14885. // }
  14886. // if item.ChrgitmLv == "3" {
  14887. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14888. // }
  14889. // }
  14890. //
  14891. // }
  14892. //
  14893. // var iteminfoStructs []service.IteminfoStruct
  14894. //
  14895. // if bedCostTotal != 0 {
  14896. // iteminfo.MedChrgitm = "01"
  14897. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14898. // iteminfo.Amt = bedCostTotal
  14899. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14900. // iteminfo.ClabAmt = bed_clab_amt
  14901. // iteminfo.OthAmt = bed_other_amt
  14902. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14903. // }
  14904. //
  14905. // if examineCostTotal != 0 {
  14906. // iteminfo.MedChrgitm = "02"
  14907. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14908. // iteminfo.Amt = examineCostTotal
  14909. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14910. // iteminfo.ClabAmt = examine_clab_amt
  14911. // iteminfo.OthAmt = examine_other_amt
  14912. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14913. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14914. // }
  14915. //
  14916. // if checkCostTotal != 0 {
  14917. // iteminfo.MedChrgitm = "03"
  14918. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14919. // iteminfo.Amt = checkCostTotal
  14920. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14921. // iteminfo.ClabAmt = check_clab_amt
  14922. // iteminfo.OthAmt = check_other_amt
  14923. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14924. //
  14925. // }
  14926. //
  14927. // if laboratoryCostTotal != 0 {
  14928. // iteminfo.MedChrgitm = "04"
  14929. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14930. // iteminfo.Amt = laboratoryCostTotal
  14931. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14932. // iteminfo.ClabAmt = laboratory_clab_amt
  14933. // iteminfo.OthAmt = laboratory_other_amt
  14934. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14935. //
  14936. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14937. //
  14938. // }
  14939. //
  14940. // if treatCostTotal != 0 {
  14941. // iteminfo.MedChrgitm = "05"
  14942. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14943. // iteminfo.Amt = treatCostTotal
  14944. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14945. // iteminfo.ClabAmt = treat_clab_amt
  14946. // iteminfo.OthAmt = treat_other_amt
  14947. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14948. // //(struct4101.IteminfoStruct, iteminfo)
  14949. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14950. // }
  14951. //
  14952. // if operationCostTotal != 0 {
  14953. // iteminfo.MedChrgitm = "06"
  14954. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14955. // iteminfo.Amt = operationCostTotal
  14956. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14957. // iteminfo.ClabAmt = operation_clab_amt
  14958. // iteminfo.OthAmt = operation_other_amt
  14959. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14960. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14961. // }
  14962. //
  14963. // if nursingCostTotal != 0 {
  14964. // iteminfo.MedChrgitm = "07"
  14965. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14966. // iteminfo.Amt = nursingCostTotal
  14967. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14968. // iteminfo.ClabAmt = nursing_clab_amt
  14969. // iteminfo.OthAmt = nursing_other_amt
  14970. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14971. // }
  14972. //
  14973. // if materialCostTotal != 0 {
  14974. // iteminfo.MedChrgitm = "08"
  14975. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14976. // iteminfo.Amt = materialCostTotal
  14977. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14978. // iteminfo.ClabAmt = material_clab_amt
  14979. // iteminfo.OthAmt = material_other_amt
  14980. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14981. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14982. // }
  14983. //
  14984. // if westernMedicineCostTotal != 0 {
  14985. // iteminfo.MedChrgitm = "09"
  14986. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14987. // iteminfo.Amt = westernMedicineCostTotal
  14988. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14989. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14990. // iteminfo.OthAmt = westernMedicine_other_amt
  14991. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14992. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14993. //
  14994. // }
  14995. //
  14996. // if chineseMedicineCostTotal != 0 {
  14997. // iteminfo.MedChrgitm = "10"
  14998. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14999. // iteminfo.Amt = chineseMedicineCostTotal
  15000. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  15001. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  15002. // iteminfo.OthAmt = chinese_medicine_other_amt
  15003. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15004. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15005. //
  15006. // }
  15007. //
  15008. // if chineseTraditionalMedicineCostTotal != 0 {
  15009. // iteminfo.MedChrgitm = "11"
  15010. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15011. // iteminfo.Amt = westernMedicineCostTotal
  15012. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15013. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15014. // iteminfo.OthAmt = westernMedicine_other_amt
  15015. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15016. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15017. //
  15018. // }
  15019. //
  15020. // if commonlyTreatmentCostTotal != 0 {
  15021. // iteminfo.MedChrgitm = "12"
  15022. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  15023. // iteminfo.Amt = commonlyTreatmentCostTotal
  15024. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  15025. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  15026. // iteminfo.OthAmt = commonly_treatment_other_amt
  15027. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15028. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15029. //
  15030. // }
  15031. //
  15032. // if registerCostTotal != 0 {
  15033. // iteminfo.MedChrgitm = "13"
  15034. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  15035. // iteminfo.Amt = registerCostTotal
  15036. // iteminfo.ClaaSumfee = register_claa_sunmfee
  15037. // iteminfo.ClabAmt = register_clab_amt
  15038. // iteminfo.OthAmt = register_other_amt
  15039. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15040. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15041. //
  15042. // }
  15043. //
  15044. // if otherCostTotal != 0 {
  15045. // iteminfo.MedChrgitm = "14"
  15046. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15047. // iteminfo.Amt = otherCostTotal
  15048. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15049. // iteminfo.ClabAmt = other_clab_amt
  15050. // iteminfo.OthAmt = other_other_amt
  15051. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15052. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15053. //
  15054. // }
  15055. // struct4101.IteminfoStruct = iteminfoStructs
  15056. // time_arr := strings.Split(order.SetlTime, " ")
  15057. // struct4101.AdmTime = time_arr[0]
  15058. // struct4101.AdmEndTime = time_arr[0]
  15059. //
  15060. // struct4101.DoctorName = doctor.UserName
  15061. // struct4101.DoctorCode = doctor.DoctorNumber
  15062. //
  15063. // struct4101.Ntly = "中国"
  15064. // struct4101.AdmCaty = "A03.06"
  15065. // var res ResultSeventeen
  15066. // if miConfig.MdtrtareaAdmvs == "421300" {
  15067. // data := make(map[string]interface{})
  15068. // data["struct4101"] = struct4101
  15069. // data["secret_key"] = miConfig.SecretKey
  15070. // data["org_name"] = miConfig.OrgName
  15071. // data["opera"] = curRoles.UserName
  15072. // data["code"] = miConfig.Code
  15073. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15074. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15075. //
  15076. // client := &http.Client{}
  15077. // bytesData, _ := json.Marshal(data)
  15078. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15079. // resp, _ := client.Do(req)
  15080. // defer resp.Body.Close()
  15081. // body, ioErr := ioutil.ReadAll(resp.Body)
  15082. // if ioErr != nil {
  15083. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15085. // return
  15086. // }
  15087. // var respJSON map[string]interface{}
  15088. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15089. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15091. // return
  15092. // }
  15093. //
  15094. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15095. // userJSONBytes, _ := json.Marshal(respJSON)
  15096. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15097. // utils.ErrorLog("解析失败:%v", err)
  15098. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15099. // adminUser := c.GetAdminUserInfo()
  15100. // errlog := &models.HisOrderError{
  15101. // UserOrgId: adminUser.CurrentOrgId,
  15102. // Ctime: time.Now().Unix(),
  15103. // Mtime: time.Now().Unix(),
  15104. // ErrMsg: res.ErrMsg + "解析失败",
  15105. // Status: 1,
  15106. // PatientId: order_id,
  15107. // Stage: 10088,
  15108. // }
  15109. // service.CreateErrMsgLog(errlog)
  15110. // continue
  15111. // }
  15112. //
  15113. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  15114. // data := make(map[string]interface{})
  15115. // data["struct4101"] = struct4101
  15116. // data["secret_key"] = miConfig.SecretKey
  15117. // data["org_name"] = miConfig.OrgName
  15118. // data["opera"] = curRoles.UserName
  15119. // data["code"] = miConfig.Code
  15120. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15121. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15122. //
  15123. // client := &http.Client{}
  15124. // bytesData, _ := json.Marshal(data)
  15125. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15126. // resp, _ := client.Do(req)
  15127. // defer resp.Body.Close()
  15128. // body, ioErr := ioutil.ReadAll(resp.Body)
  15129. // if ioErr != nil {
  15130. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15132. // return
  15133. // }
  15134. // var respJSON map[string]interface{}
  15135. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15136. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15138. // return
  15139. // }
  15140. //
  15141. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15142. // userJSONBytes, _ := json.Marshal(respJSON)
  15143. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15144. // utils.ErrorLog("解析失败:%v", err)
  15145. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15146. // adminUser := c.GetAdminUserInfo()
  15147. // errlog := &models.HisOrderError{
  15148. // UserOrgId: adminUser.CurrentOrgId,
  15149. // Ctime: time.Now().Unix(),
  15150. // Mtime: time.Now().Unix(),
  15151. // ErrMsg: res.ErrMsg + "解析失败",
  15152. // Status: 1,
  15153. // PatientId: order_id,
  15154. // Stage: 10088,
  15155. // }
  15156. // service.CreateErrMsgLog(errlog)
  15157. // continue
  15158. // }
  15159. //
  15160. // } else {
  15161. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  15162. // fmt.Println(result)
  15163. //
  15164. // var dat map[string]interface{}
  15165. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15166. // fmt.Println(dat)
  15167. // } else {
  15168. // fmt.Println(err)
  15169. // }
  15170. // userJSONBytes, _ := json.Marshal(dat)
  15171. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15172. // utils.ErrorLog("解析失败:%v", err)
  15173. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15174. // adminUser := c.GetAdminUserInfo()
  15175. // errlog := &models.HisOrderError{
  15176. // UserOrgId: adminUser.CurrentOrgId,
  15177. // Ctime: time.Now().Unix(),
  15178. // Mtime: time.Now().Unix(),
  15179. // ErrMsg: res.ErrMsg + "解析失败",
  15180. // Status: 1,
  15181. // PatientId: order_id,
  15182. // Stage: 10106,
  15183. // }
  15184. // service.CreateErrMsgLog(errlog)
  15185. // continue
  15186. // }
  15187. // }
  15188. //
  15189. // if res.Infcode != 0 {
  15190. // adminUser := c.GetAdminUserInfo()
  15191. // errlog := &models.HisOrderError{
  15192. // UserOrgId: adminUser.CurrentOrgId,
  15193. // Ctime: time.Now().Unix(),
  15194. // Mtime: time.Now().Unix(),
  15195. // ErrMsg: res.ErrMsg,
  15196. // Status: 1,
  15197. // PatientId: order_id,
  15198. // Stage: 10106,
  15199. // }
  15200. // service.CreateErrMsgLog(errlog)
  15201. // continue
  15202. // } else {
  15203. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15204. // Number: res.Output.SetlListId,
  15205. // Status: 1,
  15206. // Ctime: time.Now().Unix(),
  15207. // Mtime: time.Now().Unix(),
  15208. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15209. // IsUpload: 1,
  15210. // OrderId: order_id,
  15211. // }
  15212. // service.CreateUploadRecord(hisFundSettleListResult)
  15213. // continue
  15214. // }
  15215. // }
  15216. //}
  15217. func (c *HisApiController) GetOrgInfo() {
  15218. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15219. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15220. }
  15221. func (c *HisApiController) GetHisPatientInfo() {
  15222. medical_insurance_card := c.GetString("medical_insurance_card")
  15223. id_card_type, _ := c.GetInt64("id_card_type")
  15224. id_card := c.GetString("id_card")
  15225. adminInfo := c.GetAdminUserInfo()
  15226. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15227. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15228. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15229. IdCardNo := ""
  15230. if id_card_type == 1 {
  15231. IdCardNo = medical_insurance_card
  15232. } else if id_card_type == 2 {
  15233. IdCardNo = id_card
  15234. }
  15235. if config.IsOpen == 1 {
  15236. 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
  15237. resp, requestErr := http.Get(api)
  15238. if requestErr != nil {
  15239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15240. return
  15241. }
  15242. defer resp.Body.Close()
  15243. body, ioErr := ioutil.ReadAll(resp.Body)
  15244. if ioErr != nil {
  15245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15247. return
  15248. }
  15249. var respJSON map[string]interface{}
  15250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15253. return
  15254. }
  15255. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15256. userJSONBytes, _ := json.Marshal(userJSON)
  15257. var res ResultTwo
  15258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15259. utils.ErrorLog("解析失败:%v", err)
  15260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15261. return
  15262. }
  15263. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15264. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15265. infoStr := string(Iinfos)
  15266. idetinfoStr := string(Idetinfos)
  15267. if res.Infcode == 0 {
  15268. his := models.VMHisPatient{
  15269. Status: 1,
  15270. Ctime: time.Now().Unix(),
  15271. Mtime: time.Now().Unix(),
  15272. PsnNo: res.Output.Baseinfo.PsnNo,
  15273. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15274. Certno: res.Output.Baseinfo.Certno,
  15275. PsnName: res.Output.Baseinfo.PsnName,
  15276. Gend: res.Output.Baseinfo.Gend,
  15277. Naty: res.Output.Baseinfo.Naty,
  15278. Iinfo: infoStr,
  15279. Idetinfo: idetinfoStr,
  15280. UserOrgId: adminInfo.CurrentOrgId,
  15281. IsReturn: 1,
  15282. IdCardType: id_card_type,
  15283. }
  15284. c.ServeSuccessJSON(map[string]interface{}{
  15285. "info": his,
  15286. })
  15287. } else {
  15288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15289. return
  15290. }
  15291. }
  15292. }
  15293. //func GetBasBaseInfo() (jsonStr string, err error) {
  15294. //
  15295. // handle := syscall.NewLazyDLL("SSCard.dll")
  15296. // add := handle.NewProc("ReadCardBas")
  15297. // str := make([]byte, 1024)
  15298. // str1 := make([]byte, 1024)
  15299. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15300. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15301. //
  15302. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15303. //
  15304. // fmt.Println("> Add(4,5)的结果为:", ret)
  15305. // handle.Release()
  15306. //
  15307. // return "", nil
  15308. //
  15309. //}
  15310. //func GetQRBaseInfo() (jsonStr string, err error) {
  15311. // handle := syscall.LoadDLL("SSCard.dll")
  15312. // ReadCardBas := handle.FindProc("GetQRBase")
  15313. //
  15314. // str := make([]byte, 256)
  15315. // str1 := make([]byte, 256)
  15316. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15317. //
  15318. // fmt.Println(string(str))
  15319. // fmt.Println(r)
  15320. // return string(str), nil
  15321. //}
  15322. //func CardInit() int {
  15323. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15324. // add := DllTestDef.MustFindProc("Init")
  15325. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15326. // if err != nil {
  15327. // fmt.Println("SSCard的运算结果为:", ret)
  15328. // }
  15329. // result := int(ret)
  15330. // return result
  15331. //}
  15332. //func CardInit() int {
  15333. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15334. // if err != nil {
  15335. // fmt.Println("SSCard的运算结果为:", ret)
  15336. // }
  15337. // fmt.Println(err)
  15338. // result := int(ret)
  15339. // return result
  15340. //}
  15341. func IntPtr(n int) uintptr {
  15342. return uintptr(n)
  15343. }
  15344. func StrPtr(s string) uintptr {
  15345. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15346. }
  15347. type Result2001 struct {
  15348. Cainfo interface{} `json:"cainfo"`
  15349. ErrMsg string `json:"err_msg"`
  15350. InfRefmsgid string `json:"inf_refmsgid"`
  15351. Infcode int64 `json:"infcode"`
  15352. Output struct {
  15353. Trtinfo struct {
  15354. PsnNo string `json:"psn_no"`
  15355. TrtChkType string `json:"trt_chk_type"`
  15356. FundPayType string `json:"fund_pay_type"`
  15357. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15358. Begndate string `json:"begndate"`
  15359. Enddate string `json:"enddate"`
  15360. TrtChkRslt string `json:"trt_chk_rslt"`
  15361. } `json:"trtinfo"`
  15362. } `json:"output"`
  15363. RefmsgTime string `json:"refmsg_time"`
  15364. RespondTime string `json:"respond_time"`
  15365. Signtype interface{} `json:"signtype"`
  15366. WarnMsg interface{} `json:"warn_msg"`
  15367. }
  15368. type Result2001Org10265 struct {
  15369. Cainfo interface{} `json:"cainfo"`
  15370. ErrMsg string `json:"err_msg"`
  15371. InfRefmsgid string `json:"inf_refmsgid"`
  15372. Infcode string `json:"infcode"`
  15373. Output struct {
  15374. Trtinfo struct {
  15375. PsnNo string `json:"psn_no"`
  15376. TrtChkType string `json:"trt_chk_type"`
  15377. FundPayType string `json:"fund_pay_type"`
  15378. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15379. Begndate string `json:"begndate"`
  15380. Enddate string `json:"enddate"`
  15381. TrtChkRslt string `json:"trt_chk_rslt"`
  15382. } `json:"trtinfo"`
  15383. } `json:"output"`
  15384. RefmsgTime string `json:"refmsg_time"`
  15385. RespondTime string `json:"respond_time"`
  15386. Signtype interface{} `json:"signtype"`
  15387. WarnMsg interface{} `json:"warn_msg"`
  15388. }
  15389. type ResultTwo struct {
  15390. ErrMsg string `json:"err_msg"`
  15391. InfRefmsgid string `json:"inf_refmsgid"`
  15392. Infcode int64 `json:"infcode"`
  15393. Output struct {
  15394. Baseinfo struct {
  15395. //Brdy string `json:"brdy"`
  15396. Certno string `json:"certno"`
  15397. Gend string `json:"gend"`
  15398. Naty string `json:"naty"`
  15399. PsnCertType string `json:"psn_cert_type"`
  15400. PsnName string `json:"psn_name"`
  15401. PsnNo string `json:"psn_no"`
  15402. } `json:"baseinfo"`
  15403. Idetinfo []interface{} `json:"idetinfo"`
  15404. Iinfo []struct {
  15405. Balc float64 `json:"balc"`
  15406. CvlservFlag string `json:"cvlserv_flag"`
  15407. EmpName string `json:"emp_name"`
  15408. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15409. Insutype string `json:"insutype"`
  15410. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15411. //PausInsuDate string `json:"paus_insu_date"`
  15412. //PsnInsuDate string `json:"psn_insu_date"`
  15413. PsnInsuStas string `json:"psn_insu_stas"`
  15414. PsnType string `json:"psn_type"`
  15415. } `json:"insuinfo"`
  15416. } `json:"output"`
  15417. RefmsgTime string `json:"refmsg_time"`
  15418. RespondTime string `json:"respond_time"`
  15419. Signtype interface{} `json:"signtype"`
  15420. WarnInfo interface{} `json:"warn_info"`
  15421. }
  15422. type ResultTwo10265 struct {
  15423. ErrMsg string `json:"err_msg"`
  15424. InfRefmsgid string `json:"inf_refmsgid"`
  15425. Infcode string `json:"infcode"`
  15426. Output struct {
  15427. Baseinfo struct {
  15428. //Brdy string `json:"brdy"`
  15429. Certno string `json:"certno"`
  15430. Gend string `json:"gend"`
  15431. Naty string `json:"naty"`
  15432. PsnCertType string `json:"psn_cert_type"`
  15433. PsnName string `json:"psn_name"`
  15434. PsnNo string `json:"psn_no"`
  15435. } `json:"baseinfo"`
  15436. Idetinfo []interface{} `json:"idetinfo"`
  15437. Iinfo []struct {
  15438. Balc float64 `json:"balc"`
  15439. CvlservFlag string `json:"cvlserv_flag"`
  15440. EmpName string `json:"emp_name"`
  15441. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15442. Insutype string `json:"insutype"`
  15443. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15444. PsnInsuStas string `json:"psn_insu_stas"`
  15445. PsnType string `json:"psn_type"`
  15446. } `json:"insuinfo"`
  15447. } `json:"output"`
  15448. RefmsgTime string `json:"refmsg_time"`
  15449. RespondTime string `json:"respond_time"`
  15450. Signtype interface{} `json:"signtype"`
  15451. WarnInfo interface{} `json:"warn_info"`
  15452. }
  15453. type ResultThree struct {
  15454. Cainfo interface{} `json:"cainfo"`
  15455. ErrMsg string `json:"err_msg"`
  15456. InfRefmsgid string `json:"inf_refmsgid"`
  15457. Infcode int64 `json:"infcode"`
  15458. Output struct {
  15459. Data struct {
  15460. IptOtpNo string `json:"ipt_otp_no"`
  15461. MdtrtID string `json:"mdtrt_id"`
  15462. PsnNo string `json:"psn_no"`
  15463. } `json:"data"`
  15464. } `json:"output"`
  15465. RefmsgTime string `json:"refmsg_time"`
  15466. RespondTime string `json:"respond_time"`
  15467. Signtype interface{} `json:"signtype"`
  15468. WarnMsg interface{} `json:"warn_msg"`
  15469. }
  15470. type ResultThree10265 struct {
  15471. Cainfo interface{} `json:"cainfo"`
  15472. ErrMsg string `json:"err_msg"`
  15473. InfRefmsgid string `json:"inf_refmsgid"`
  15474. Infcode string `json:"infcode"`
  15475. Output struct {
  15476. Data struct {
  15477. IptOtpNo string `json:"ipt_otp_no"`
  15478. MdtrtID string `json:"mdtrt_id"`
  15479. PsnNo string `json:"psn_no"`
  15480. } `json:"data"`
  15481. } `json:"output"`
  15482. RefmsgTime string `json:"refmsg_time"`
  15483. RespondTime string `json:"respond_time"`
  15484. Signtype interface{} `json:"signtype"`
  15485. WarnMsg interface{} `json:"warn_msg"`
  15486. }
  15487. type ResultFour struct {
  15488. Cainfo string `json:"cainfo"`
  15489. ErrMsg string `json:"err_msg"`
  15490. InfRefmsgid string `json:"inf_refmsgid"`
  15491. Infcode int64 `json:"infcode"`
  15492. Output struct {
  15493. Result []struct {
  15494. BasMednFlag string `json:"bas_medn_flag"`
  15495. ChldMedcFlag string `json:"chld_medc_flag"`
  15496. ChrgitmLv string `json:"chrgitm_lv"`
  15497. Cnt float64 `json:"cnt"`
  15498. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15499. DrtReimFlag string `json:"drt_reim_flag"`
  15500. FeedetlSn string `json:"feedetl_sn"`
  15501. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15502. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15503. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15504. ListSpItemFlag string `json:"list_sp_item_flag"`
  15505. LmtUsedFlag string `json:"lmt_used_flag"`
  15506. MedChrgitmType string `json:"med_chrgitm_type"`
  15507. Memo string `json:"memo"`
  15508. OverlmtAmt float64 `json:"overlmt_amt"`
  15509. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15510. Pric float64 `json:"pric"`
  15511. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15512. SelfpayProp float64 `json:"selfpay_prop"`
  15513. } `json:"result"`
  15514. } `json:"output"`
  15515. RefmsgTime string `json:"refmsg_time"`
  15516. RespondTime string `json:"respond_time"`
  15517. Signtype string `json:"signtype"`
  15518. WarnMsg string `json:"warn_msg"`
  15519. }
  15520. type ResultFour10265 struct {
  15521. Cainfo string `json:"cainfo"`
  15522. ErrMsg string `json:"err_msg"`
  15523. InfRefmsgid string `json:"inf_refmsgid"`
  15524. Infcode string `json:"infcode"`
  15525. Output struct {
  15526. Result []struct {
  15527. BasMednFlag string `json:"bas_medn_flag"`
  15528. ChldMedcFlag string `json:"chld_medc_flag"`
  15529. ChrgitmLv string `json:"chrgitm_lv"`
  15530. Cnt float64 `json:"cnt"`
  15531. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15532. DrtReimFlag string `json:"drt_reim_flag"`
  15533. FeedetlSn string `json:"feedetl_sn"`
  15534. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15535. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15536. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15537. ListSpItemFlag string `json:"list_sp_item_flag"`
  15538. LmtUsedFlag string `json:"lmt_used_flag"`
  15539. MedChrgitmType string `json:"med_chrgitm_type"`
  15540. Memo string `json:"memo"`
  15541. OverlmtAmt float64 `json:"overlmt_amt"`
  15542. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15543. Pric float64 `json:"pric"`
  15544. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15545. SelfpayProp float64 `json:"selfpay_prop"`
  15546. } `json:"result"`
  15547. } `json:"output"`
  15548. RefmsgTime string `json:"refmsg_time"`
  15549. RespondTime string `json:"respond_time"`
  15550. Signtype string `json:"signtype"`
  15551. WarnMsg string `json:"warn_msg"`
  15552. }
  15553. type ResultMemo struct {
  15554. InsuAdmdvs string `json:"insuAdmdvs"`
  15555. }
  15556. // [{"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}]
  15557. type ResultIDInfo struct {
  15558. Begntime string `json:"begntime"`
  15559. Endtime string `json:"endtime"`
  15560. Memo string `json:"memo"`
  15561. }
  15562. type ResultFive struct {
  15563. Balc float64 `json:"balc"`
  15564. CvlservFlag string `json:"cvlserv_flag"`
  15565. EmpName string `json:"emp_name"`
  15566. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15567. Insutype string `json:"insutype"`
  15568. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15569. PausInsuDate string `json:"paus_insu_date"`
  15570. PsnInsuDate string `json:"psn_insu_date"`
  15571. PsnInsuStas string `json:"psn_insu_stas"`
  15572. PsnType string `json:"psn_type"`
  15573. }
  15574. type ResultSix struct {
  15575. Cainfo interface{} `json:"cainfo"`
  15576. ErrMsg string `json:"err_msg"`
  15577. InfRefmsgid string `json:"inf_refmsgid"`
  15578. Infcode int64 `json:"infcode"`
  15579. Output struct {
  15580. } `json:"output"`
  15581. RefmsgTime string `json:"refmsg_time"`
  15582. RespondTime string `json:"respond_time"`
  15583. Signtype interface{} `json:"signtype"`
  15584. WarnMsg interface{} `json:"warn_msg"`
  15585. }
  15586. type FJ3507Result struct {
  15587. Cainfo interface{} `json:"cainfo"`
  15588. ErrMsg string `json:"err_msg"`
  15589. InfRefmsgid string `json:"inf_refmsgid"`
  15590. Infcode int64 `json:"infcode"`
  15591. Output struct {
  15592. retRslt string `json:"retRslt"`
  15593. msgRslt string `json:"msgRslt"`
  15594. } `json:"output"`
  15595. RefmsgTime string `json:"refmsg_time"`
  15596. RespondTime string `json:"respond_time"`
  15597. Signtype interface{} `json:"signtype"`
  15598. WarnMsg interface{} `json:"warn_msg"`
  15599. }
  15600. type Result2406 struct {
  15601. Cainfo interface{} `json:"cainfo"`
  15602. ErrMsg string `json:"err_msg"`
  15603. InfRefmsgid string `json:"inf_refmsgid"`
  15604. Infcode int64 `json:"infcode"`
  15605. Output struct {
  15606. Result struct {
  15607. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15608. } `json:"result"`
  15609. } `json:"output"`
  15610. RefmsgTime string `json:"refmsg_time"`
  15611. RespondTime string `json:"respond_time"`
  15612. Signtype interface{} `json:"signtype"`
  15613. WarnMsg interface{} `json:"warn_msg"`
  15614. }
  15615. type GZResultSix struct {
  15616. Cainfo interface{} `json:"cainfo"`
  15617. ErrMsg string `json:"err_msg"`
  15618. InfRefmsgid string `json:"inf_refmsgid"`
  15619. Infcode int64 `json:"infcode"`
  15620. Output string `json:"output"`
  15621. RefmsgTime string `json:"refmsg_time"`
  15622. RespondTime string `json:"respond_time"`
  15623. Signtype interface{} `json:"signtype"`
  15624. WarnMsg interface{} `json:"warn_msg"`
  15625. }
  15626. type ResultSix10265 struct {
  15627. Cainfo interface{} `json:"cainfo"`
  15628. ErrMsg string `json:"err_msg"`
  15629. InfRefmsgid string `json:"inf_refmsgid"`
  15630. Infcode string `json:"infcode"`
  15631. Output struct {
  15632. } `json:"output"`
  15633. RefmsgTime string `json:"refmsg_time"`
  15634. RespondTime string `json:"respond_time"`
  15635. Signtype interface{} `json:"signtype"`
  15636. WarnMsg interface{} `json:"warn_msg"`
  15637. }
  15638. type ResultSeven struct {
  15639. Cainfo string `json:"cainfo"`
  15640. ErrMsg string `json:"err_msg"`
  15641. InfRefmsgid string `json:"inf_refmsgid"`
  15642. Infcode int64 `json:"infcode"`
  15643. Output struct {
  15644. Setlinfo struct {
  15645. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15646. AcctPay float64 `json:"acct_pay"`
  15647. ActPayDedc float64 `json:"act_pay_dedc"`
  15648. Age float64 `json:"age"`
  15649. Balc float64 `json:"balc"`
  15650. Certno string `json:"certno"`
  15651. ClrOptins string `json:"clr_optins"`
  15652. ClrType string `json:"clr_type"`
  15653. ClrWay string `json:"clr_way"`
  15654. CvlservFlag string `json:"cvlserv_flag"`
  15655. CvlservPay float64 `json:"cvlserv_pay"`
  15656. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15657. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15658. Gend string `json:"gend"`
  15659. HifesPay float64 `json:"hifes_pay"`
  15660. HifmiPay float64 `json:"hifmi_pay"`
  15661. HifpPay float64 `json:"hifp_pay"`
  15662. HospPartAmt float64 `json:"hosp_part_amt"`
  15663. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15664. Insutype string `json:"insutype"`
  15665. MafPay float64 `json:"maf_pay"`
  15666. MdtrtCertType string `json:"mdtrt_cert_type"`
  15667. HifobPay float64 `json:"hifob_pay"`
  15668. MdtrtID string `json:"mdtrt_id"`
  15669. MedType string `json:"med_type"`
  15670. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15671. MedinsSetlID string `json:"medins_setl_id"`
  15672. Naty string `json:"naty"`
  15673. OthPay float64 `json:"oth_pay"`
  15674. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15675. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15676. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15677. PsnCashPay float64 `json:"psn_cash_pay"`
  15678. PsnCertType string `json:"psn_cert_type"`
  15679. PsnName string `json:"psn_name"`
  15680. PsnNo string `json:"psn_no"`
  15681. PsnPartAmt float64 `json:"psn_part_amt"`
  15682. PsnType string `json:"psn_type"`
  15683. SetlID string `json:"setl_id"`
  15684. SetlTime string `json:"setl_time"`
  15685. } `json:"setlinfo"`
  15686. Setldetail interface{} `json:"setldetail"`
  15687. } `json:"output"`
  15688. RefmsgTime string `json:"refmsg_time"`
  15689. RespondTime string `json:"respond_time"`
  15690. Signtype interface{} `json:"signtype"`
  15691. WarnMsg interface{} `json:"warn_msg"`
  15692. }
  15693. type ResultSevenAH struct {
  15694. Cainfo string `json:"cainfo"`
  15695. ErrMsg string `json:"err_msg"`
  15696. InfRefmsgid string `json:"inf_refmsgid"`
  15697. Infcode int64 `json:"infcode"`
  15698. Output struct {
  15699. Setlinfo struct {
  15700. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15701. AcctPay float64 `json:"acct_pay"`
  15702. ActPayDedc float64 `json:"act_pay_dedc"`
  15703. Age float64 `json:"age"`
  15704. Balc float64 `json:"balc"`
  15705. Certno string `json:"certno"`
  15706. ClrOptins string `json:"clr_optins"`
  15707. ClrType string `json:"clr_type"`
  15708. ClrWay string `json:"clr_way"`
  15709. CvlservFlag string `json:"cvlserv_flag"`
  15710. CvlservPay float64 `json:"cvlserv_pay"`
  15711. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15712. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15713. Gend string `json:"gend"`
  15714. HifesPay float64 `json:"hifes_pay"`
  15715. HifmiPay float64 `json:"hifmi_pay"`
  15716. HifpPay float64 `json:"hifp_pay"`
  15717. HospPartAmt float64 `json:"hosp_part_amt"`
  15718. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15719. Insutype string `json:"insutype"`
  15720. MafPay float64 `json:"maf_pay"`
  15721. MdtrtCertType string `json:"mdtrt_cert_type"`
  15722. HifobPay float64 `json:"hifob_pay"`
  15723. MdtrtID string `json:"mdtrt_id"`
  15724. MedType string `json:"med_type"`
  15725. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15726. MedinsSetlID string `json:"medins_setl_id"`
  15727. Naty string `json:"naty"`
  15728. OthPay float64 `json:"oth_pay"`
  15729. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15730. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15731. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15732. PsnCashPay float64 `json:"psn_cash_pay"`
  15733. PsnCertType string `json:"psn_cert_type"`
  15734. PsnName string `json:"psn_name"`
  15735. PsnNo string `json:"psn_no"`
  15736. PsnPartAmt float64 `json:"psn_part_amt"`
  15737. PsnType string `json:"psn_type"`
  15738. SetlID string `json:"setl_id"`
  15739. SetlTime int64 `json:"setl_time"`
  15740. } `json:"setlinfo"`
  15741. Setldetail interface{} `json:"setldetail"`
  15742. } `json:"output"`
  15743. RefmsgTime string `json:"refmsg_time"`
  15744. RespondTime string `json:"respond_time"`
  15745. Signtype interface{} `json:"signtype"`
  15746. WarnMsg interface{} `json:"warn_msg"`
  15747. }
  15748. type ResultSeven10265 struct {
  15749. Cainfo string `json:"cainfo"`
  15750. ErrMsg string `json:"err_msg"`
  15751. InfRefmsgid string `json:"inf_refmsgid"`
  15752. Infcode string `json:"infcode"`
  15753. Output struct {
  15754. Setlinfo struct {
  15755. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15756. AcctPay float64 `json:"acct_pay"`
  15757. ActPayDedc float64 `json:"act_pay_dedc"`
  15758. Age float64 `json:"age"`
  15759. Balc float64 `json:"balc"`
  15760. Certno string `json:"certno"`
  15761. ClrOptins string `json:"clr_optins"`
  15762. ClrType string `json:"clr_type"`
  15763. ClrWay string `json:"clr_way"`
  15764. CvlservFlag string `json:"cvlserv_flag"`
  15765. CvlservPay float64 `json:"cvlserv_pay"`
  15766. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15767. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15768. Gend string `json:"gend"`
  15769. HifesPay float64 `json:"hifes_pay"`
  15770. HifmiPay float64 `json:"hifmi_pay"`
  15771. HifpPay float64 `json:"hifp_pay"`
  15772. HospPartAmt float64 `json:"hosp_part_amt"`
  15773. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15774. Insutype string `json:"insutype"`
  15775. MafPay float64 `json:"maf_pay"`
  15776. MdtrtCertType string `json:"mdtrt_cert_type"`
  15777. HifobPay float64 `json:"hifob_pay"`
  15778. MdtrtID string `json:"mdtrt_id"`
  15779. MedType string `json:"med_type"`
  15780. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15781. MedinsSetlID string `json:"medins_setl_id"`
  15782. Naty string `json:"naty"`
  15783. OthPay float64 `json:"oth_pay"`
  15784. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15785. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15786. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15787. PsnCashPay float64 `json:"psn_cash_pay"`
  15788. PsnCertType string `json:"psn_cert_type"`
  15789. PsnName string `json:"psn_name"`
  15790. PsnNo string `json:"psn_no"`
  15791. PsnPartAmt float64 `json:"psn_part_amt"`
  15792. PsnType string `json:"psn_type"`
  15793. SetlID string `json:"setl_id"`
  15794. SetlTime string `json:"setl_time"`
  15795. } `json:"setlinfo"`
  15796. Setldetail interface{} `json:"setldetail"`
  15797. } `json:"output"`
  15798. RefmsgTime string `json:"refmsg_time"`
  15799. RespondTime string `json:"respond_time"`
  15800. Signtype interface{} `json:"signtype"`
  15801. WarnMsg interface{} `json:"warn_msg"`
  15802. }
  15803. type ResultSeven10265Two struct {
  15804. Cainfo string `json:"cainfo"`
  15805. ErrMsg string `json:"err_msg"`
  15806. InfRefmsgid string `json:"inf_refmsgid"`
  15807. Infcode string `json:"infcode"`
  15808. Output struct {
  15809. Setlinfo struct {
  15810. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15811. AcctPay float64 `json:"acct_pay"`
  15812. ActPayDedc float64 `json:"act_pay_dedc"`
  15813. Age float64 `json:"age"`
  15814. Balc float64 `json:"balc"`
  15815. Certno string `json:"certno"`
  15816. ClrOptins string `json:"clr_optins"`
  15817. ClrType string `json:"clr_type"`
  15818. ClrWay string `json:"clr_way"`
  15819. CvlservFlag string `json:"cvlserv_flag"`
  15820. CvlservPay float64 `json:"cvlserv_pay"`
  15821. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15822. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15823. Gend string `json:"gend"`
  15824. HifesPay float64 `json:"hifes_pay"`
  15825. HifmiPay float64 `json:"hifmi_pay"`
  15826. HifpPay float64 `json:"hifp_pay"`
  15827. HospPartAmt string `json:"hosp_part_amt"`
  15828. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15829. Insutype string `json:"insutype"`
  15830. MafPay float64 `json:"maf_pay"`
  15831. MdtrtCertType string `json:"mdtrt_cert_type"`
  15832. HifobPay float64 `json:"hifob_pay"`
  15833. MdtrtID string `json:"mdtrt_id"`
  15834. MedType string `json:"med_type"`
  15835. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15836. MedinsSetlID string `json:"medins_setl_id"`
  15837. Naty string `json:"naty"`
  15838. OthPay float64 `json:"oth_pay"`
  15839. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15840. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15841. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15842. PsnCashPay float64 `json:"psn_cash_pay"`
  15843. PsnCertType string `json:"psn_cert_type"`
  15844. PsnName string `json:"psn_name"`
  15845. PsnNo string `json:"psn_no"`
  15846. PsnPartAmt float64 `json:"psn_part_amt"`
  15847. PsnType string `json:"psn_type"`
  15848. SetlID string `json:"setl_id"`
  15849. SetlTime string `json:"setl_time"`
  15850. } `json:"setlinfo"`
  15851. Setldetail interface{} `json:"setldetail"`
  15852. } `json:"output"`
  15853. RefmsgTime string `json:"refmsg_time"`
  15854. RespondTime string `json:"respond_time"`
  15855. Signtype interface{} `json:"signtype"`
  15856. WarnMsg interface{} `json:"warn_msg"`
  15857. }
  15858. type GZResultSeven10265Two struct {
  15859. Cainfo string `json:"cainfo"`
  15860. ErrMsg string `json:"err_msg"`
  15861. InfRefmsgid string `json:"inf_refmsgid"`
  15862. Infcode int64 `json:"infcode"`
  15863. Output struct {
  15864. Setlinfo struct {
  15865. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15866. AcctPay float64 `json:"acct_pay"`
  15867. ActPayDedc float64 `json:"act_pay_dedc"`
  15868. Age float64 `json:"age"`
  15869. Balc float64 `json:"balc"`
  15870. Certno string `json:"certno"`
  15871. ClrOptins string `json:"clr_optins"`
  15872. ClrType string `json:"clr_type"`
  15873. ClrWay string `json:"clr_way"`
  15874. CvlservFlag string `json:"cvlserv_flag"`
  15875. CvlservPay float64 `json:"cvlserv_pay"`
  15876. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15877. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15878. Gend string `json:"gend"`
  15879. HifesPay float64 `json:"hifes_pay"`
  15880. HifmiPay float64 `json:"hifmi_pay"`
  15881. HifpPay float64 `json:"hifp_pay"`
  15882. HospPartAmt float64 `json:"hosp_part_amt"`
  15883. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15884. Insutype string `json:"insutype"`
  15885. MafPay float64 `json:"maf_pay"`
  15886. MdtrtCertType string `json:"mdtrt_cert_type"`
  15887. HifobPay float64 `json:"hifob_pay"`
  15888. MdtrtID string `json:"mdtrt_id"`
  15889. MedType string `json:"med_type"`
  15890. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15891. MedinsSetlID string `json:"medins_setl_id"`
  15892. Naty string `json:"naty"`
  15893. OthPay float64 `json:"oth_pay"`
  15894. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15895. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15896. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15897. PsnCashPay float64 `json:"psn_cash_pay"`
  15898. PsnCertType string `json:"psn_cert_type"`
  15899. PsnName string `json:"psn_name"`
  15900. PsnNo string `json:"psn_no"`
  15901. PsnPartAmt float64 `json:"psn_part_amt"`
  15902. PsnType string `json:"psn_type"`
  15903. SetlID string `json:"setl_id"`
  15904. SetlTime string `json:"setl_time"`
  15905. } `json:"setlinfo"`
  15906. Setldetail interface{} `json:"setldetail"`
  15907. } `json:"output"`
  15908. RefmsgTime string `json:"refmsg_time"`
  15909. RespondTime string `json:"respond_time"`
  15910. Signtype interface{} `json:"signtype"`
  15911. WarnMsg interface{} `json:"warn_msg"`
  15912. }
  15913. type ResultEight struct {
  15914. Cainfo string `json:"cainfo"`
  15915. ErrMsg string `json:"err_msg"`
  15916. InfRefmsgid string `json:"inf_refmsgid"`
  15917. Infcode int64 `json:"infcode"`
  15918. Output struct {
  15919. Stmtinfo struct {
  15920. SetlOptins string `json:"setl_optins"`
  15921. StmtRslt string `json:"stmt_rslt"`
  15922. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15923. } `json:"stmtinfo"`
  15924. } `json:"output"`
  15925. RefmsgTime string `json:"refmsg_time"`
  15926. RespondTime string `json:"respond_time"`
  15927. Signtype interface{} `json:"signtype"`
  15928. WarnMsg interface{} `json:"warn_msg"`
  15929. }
  15930. type ResultEightFor10188 struct {
  15931. Cainfo string `json:"cainfo"`
  15932. ErrMsg string `json:"err_msg"`
  15933. InfRefmsgid string `json:"inf_refmsgid"`
  15934. Infcode string `json:"infcode"`
  15935. Output struct {
  15936. Stmtinfo struct {
  15937. SetlOptins string `json:"setl_optins"`
  15938. StmtRslt string `json:"stmt_rslt"`
  15939. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15940. } `json:"stmtinfo"`
  15941. } `json:"output"`
  15942. RefmsgTime string `json:"refmsg_time"`
  15943. RespondTime string `json:"respond_time"`
  15944. Signtype interface{} `json:"signtype"`
  15945. WarnMsg interface{} `json:"warn_msg"`
  15946. }
  15947. type ResultNine struct {
  15948. Cainfo string `json:"cainfo"`
  15949. ErrMsg string `json:"err_msg"`
  15950. InfRefmsgid string `json:"inf_refmsgid"`
  15951. Infcode int64 `json:"infcode"`
  15952. Output struct {
  15953. FileQuryNo string `json:"file_qury_no"`
  15954. } `json:"output"`
  15955. RefmsgTime string `json:"refmsg_time"`
  15956. RespondTime string `json:"respond_time"`
  15957. Signtype interface{} `json:"signtype"`
  15958. WarnMsg interface{} `json:"warn_msg"`
  15959. }
  15960. type ResultTen struct {
  15961. Cainfo string `json:"cainfo"`
  15962. ErrMsg string `json:"err_msg"`
  15963. InfRefmsgid string `json:"inf_refmsgid"`
  15964. Infcode int64 `json:"infcode"`
  15965. Output struct {
  15966. Fileinfo struct {
  15967. DldEndtime string `json:"dld_endtime"`
  15968. FileQuryNo string `json:"file_qury_no"`
  15969. Filename string `json:"filename"`
  15970. } `json:"fileinfo"`
  15971. } `json:"output"`
  15972. RefmsgTime string `json:"refmsg_time"`
  15973. RespondTime string `json:"respond_time"`
  15974. Signtype interface{} `json:"signtype"`
  15975. WarnMsg interface{} `json:"warn_msg"`
  15976. }
  15977. type Result5262 struct {
  15978. ErrMsg string `json:"err_msg"`
  15979. InfRefmsgid string `json:"inf_refmsgid"`
  15980. Infcode int64 `json:"infcode"`
  15981. Output struct {
  15982. PageInfo struct {
  15983. Size int `json:"size"`
  15984. RecordCounts int `json:"record_counts"`
  15985. } `json:"page_info"`
  15986. Idetinfo []interface{} `json:"idetinfo"`
  15987. Result []struct {
  15988. SetlID string `json:"setl_id"`
  15989. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15990. MdtrtID string `json:"mdtrt_id"`
  15991. InitSetlID string `json:"init_setl_id,omitempty"`
  15992. PsnNo string `json:"psn_no"`
  15993. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15994. PsnName string `json:"psn_name"`
  15995. PsnCertType string `json:"psn_cert_type"`
  15996. Certno string `json:"certno"`
  15997. Gend string `json:"gend,omitempty"`
  15998. Naty string `json:"naty,omitempty"`
  15999. Brdy string `json:"brdy,omitempty"`
  16000. Age float64 `json:"age,omitempty"`
  16001. Insutype string `json:"insutype,omitempty"`
  16002. PsnType string `json:"psn_type"`
  16003. CvlservFlag string `json:"cvlserv_flag"`
  16004. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16005. SpPsnType string `json:"sp_psn_type,omitempty"`
  16006. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16007. ClctGrde string `json:"clct_grde,omitempty"`
  16008. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16009. NwbFlag string `json:"nwb_flag,omitempty"`
  16010. InsuAdmdvs string `json:"insu_admdvs"`
  16011. EmpNo string `json:"emp_no,omitempty"`
  16012. EmpName string `json:"emp_name,omitempty"`
  16013. EmpType string `json:"emp_type,omitempty"`
  16014. EconType string `json:"econ_type,omitempty"`
  16015. AfilIndu string `json:"afil_indu,omitempty"`
  16016. AfilRlts string `json:"afil_rlts,omitempty"`
  16017. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16018. PayLoc string `json:"pay_loc,omitempty"`
  16019. FixmedinsCode string `json:"fixmedins_code"`
  16020. FixmedinsName string `json:"fixmedins_name"`
  16021. HospLv string `json:"hosp_lv,omitempty"`
  16022. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16023. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16024. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16025. Begndate string `json:"begndate"`
  16026. Enddate string `json:"enddate"`
  16027. SetlTime string `json:"setl_time"`
  16028. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16029. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16030. MedType string `json:"med_type"`
  16031. SetlType string `json:"setl_type,omitempty"`
  16032. ClrType string `json:"clr_type,omitempty"`
  16033. ClrWay string `json:"clr_way,omitempty"`
  16034. PsnSetlway string `json:"psn_setlway,omitempty"`
  16035. ClrOptins string `json:"clr_optins,omitempty"`
  16036. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16037. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16038. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16039. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16040. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16041. DedcStd float64 `json:"dedc_std,omitempty"`
  16042. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16043. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16044. HifpPay float64 `json:"hifp_pay,omitempty"`
  16045. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16046. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16047. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16048. HifesPay float64 `json:"hifes_pay,omitempty"`
  16049. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16050. HifobPay float64 `json:"hifob_pay,omitempty"`
  16051. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16052. MafPay float64 `json:"maf_pay,omitempty"`
  16053. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16054. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16055. PsnPay float64 `json:"psn_pay,omitempty"`
  16056. AcctPay float64 `json:"acct_pay,omitempty"`
  16057. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16058. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16059. Balc float64 `json:"balc,omitempty"`
  16060. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16061. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16062. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16063. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16064. Year string `json:"year,omitempty"`
  16065. DiseNo string `json:"dise_no,omitempty"`
  16066. DiseName string `json:"dise_name,omitempty"`
  16067. Invono string `json:"invono,omitempty"`
  16068. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16069. ValiFlag string `json:"vali_flag,omitempty"`
  16070. Memo string `json:"memo,omitempty"`
  16071. Rid string `json:"rid"`
  16072. UpdtTime string `json:"updt_time,omitempty"`
  16073. CrterID string `json:"crter_id,omitempty"`
  16074. CrterName string `json:"crter_name,omitempty"`
  16075. CrteTime string `json:"crte_time,omitempty"`
  16076. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  16077. OpterID string `json:"opter_id,omitempty"`
  16078. OpterName string `json:"opter_name,omitempty"`
  16079. OptTime string `json:"opt_time,omitempty"`
  16080. OptinsNo string `json:"optins_no,omitempty"`
  16081. PoolareaNo string `json:"poolarea_no,omitempty"`
  16082. } `json:"result"`
  16083. } `json:"output"`
  16084. RefmsgTime string `json:"refmsg_time"`
  16085. RespondTime string `json:"respond_time"`
  16086. Signtype interface{} `json:"signtype"`
  16087. WarnInfo interface{} `json:"warn_info"`
  16088. }
  16089. type Result5267 struct {
  16090. ErrMsg string `json:"err_msg"`
  16091. InfRefmsgid string `json:"inf_refmsgid"`
  16092. Infcode int64 `json:"infcode"`
  16093. Output struct {
  16094. PageInfo struct {
  16095. Size int `json:"size"`
  16096. RecordCounts int `json:"record_counts"`
  16097. } `json:"pageinfo"`
  16098. Result []struct {
  16099. SetlID string `json:"setl_id"`
  16100. ClrOptins string `json:"clr_optins"`
  16101. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16102. MdtrtID string `json:"mdtrt_id"`
  16103. InitSetlID string `json:"init_setl_id,omitempty"`
  16104. PsnNo string `json:"psn_no"`
  16105. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16106. PsnName string `json:"psn_name"`
  16107. PsnCertType string `json:"psn_cert_type"`
  16108. Certno string `json:"certno"`
  16109. Gend string `json:"gend,omitempty"`
  16110. Naty string `json:"naty,omitempty"`
  16111. Brdy string `json:"brdy,omitempty"`
  16112. Age float64 `json:"age,omitempty"`
  16113. Insutype string `json:"insutype,omitempty"`
  16114. PsnType string `json:"psn_type"`
  16115. CvlservFlag string `json:"cvlserv_flag"`
  16116. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16117. SpPsnType string `json:"sp_psn_type,omitempty"`
  16118. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16119. ClctGrde string `json:"clct_grde,omitempty"`
  16120. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16121. NwbFlag string `json:"nwb_flag,omitempty"`
  16122. InsuAdmdvs string `json:"insu_admdvs"`
  16123. EmpNo string `json:"emp_no,omitempty"`
  16124. EmpName string `json:"emp_name,omitempty"`
  16125. EmpType string `json:"emp_type,omitempty"`
  16126. EconType string `json:"econ_type,omitempty"`
  16127. AfilIndu string `json:"afil_indu,omitempty"`
  16128. AfilRlts string `json:"afil_rlts,omitempty"`
  16129. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16130. PayLoc string `json:"pay_loc,omitempty"`
  16131. FixmedinsCode string `json:"fixmedins_code"`
  16132. FixmedinsName string `json:"fixmedins_name"`
  16133. HospLv string `json:"hosp_lv,omitempty"`
  16134. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16135. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16136. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16137. Begndate string `json:"begndate,omitempty"`
  16138. Enddate string `json:"enddate,omitempty"`
  16139. SetlTime string `json:"setl_time,omitempty"`
  16140. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16141. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16142. MedType string `json:"med_type"`
  16143. SetlType string `json:"setl_type,omitempty"`
  16144. ClrType string `json:"clr_type,omitempty"`
  16145. ClrWay string `json:"clr_way,omitempty"`
  16146. PsnSetlway string `json:"psn_setlway,omitempty"`
  16147. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16148. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16149. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16150. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16151. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16152. DedcStd float64 `json:"dedc_std,omitempty"`
  16153. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16154. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16155. HifpPay float64 `json:"hifp_pay,omitempty"`
  16156. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16157. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16158. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16159. HifesPay float64 `json:"hifes_pay,omitempty"`
  16160. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16161. HifobPay float64 `json:"hifob_pay,omitempty"`
  16162. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16163. MafPay float64 `json:"maf_pay,omitempty"`
  16164. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16165. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16166. PsnPay float64 `json:"psn_pay,omitempty"`
  16167. AcctPay float64 `json:"acct_pay,omitempty"`
  16168. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16169. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16170. Balc float64 `json:"balc,omitempty"`
  16171. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16172. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16173. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16174. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16175. Year string `json:"year,omitempty"`
  16176. DiseNo string `json:"dise_no,omitempty"`
  16177. DiseName string `json:"dise_name,omitempty"`
  16178. Invono string `json:"invono,omitempty"`
  16179. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16180. Memo string `json:"memo,omitempty"`
  16181. UpdtTime string `json:"updt_time,omitempty"`
  16182. OpterID string `json:"opter_id,omitempty"`
  16183. OpterName string `json:"opter_name,omitempty"`
  16184. OptTime string `json:"opt_time,omitempty"`
  16185. OptinsNo string `json:"optins_no,omitempty"`
  16186. PoolareaNo string `json:"poolarea_no,omitempty"`
  16187. } `json:"result"`
  16188. } `json:"output"`
  16189. RefmsgTime string `json:"refmsg_time"`
  16190. RespondTime string `json:"respond_time"`
  16191. Signtype interface{} `json:"signtype"`
  16192. WarnInfo interface{} `json:"warn_info"`
  16193. }
  16194. // type Autogenerated struct {
  16195. // Output struct {
  16196. // Setlinfo struct {
  16197. // SetlTime string `json:"setl_time"`
  16198. // CvlservPay float64 `json:"cvlserv_pay"`
  16199. // Year string `json:"year"`
  16200. // MedType string `json:"med_type"`
  16201. // PsnPay float64 `json:"psn_pay"`
  16202. // OpterID string `json:"opter_id"`
  16203. // Begndate string `json:"begndate"`
  16204. // FlxempeFlag string `json:"flxempe_flag"`
  16205. // HifmiPay float64 `json:"hifmi_pay"`
  16206. // PsnNo string `json:"psn_no"`
  16207. // ActPayDedc float64 `json:"act_pay_dedc"`
  16208. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16209. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16210. // ClrWay string `json:"clr_way"`
  16211. // OthPay float64 `json:"oth_pay"`
  16212. // Gend string `json:"gend"`
  16213. // MdtrtID string `json:"mdtrt_id"`
  16214. // AcctPay float64 `json:"acct_pay"`
  16215. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16216. // Insutype string `json:"insutype"`
  16217. // Invono interface{} `json:"invono"`
  16218. // Enddate string `json:"enddate"`
  16219. // CashPayamt float64 `json:"cash_payamt"`
  16220. // PsnType string `json:"psn_type"`
  16221. // FixmedinsName string `json:"fixmedins_name"`
  16222. // HifpPay float64 `json:"hifp_pay"`
  16223. // NewFlag interface{} `json:"new_flag"`
  16224. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16225. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16226. // PayLoc string `json:"pay_loc"`
  16227. // ClrType string `json:"clr_type"`
  16228. // RefdSetlFlag string `json:"refd_setl_flag"`
  16229. // CvlservFlag string `json:"cvlserv_flag"`
  16230. // EmpName string `json:"emp_name"`
  16231. // Brdy string `json:"brdy"`
  16232. // Naty string `json:"naty"`
  16233. // Certno string `json:"certno"`
  16234. // DiseCode string `json:"dise_code"`
  16235. // FixmedinsCode string `json:"fixmedins_code"`
  16236. // DedcHospLv string `json:"dedc_hosp_lv"`
  16237. // OpterName string `json:"opter_name"`
  16238. // Balc float64 `json:"balc"`
  16239. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16240. // PsnCertType string `json:"psn_cert_type"`
  16241. // HifobPay float64 `json:"hifob_pay"`
  16242. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16243. // HifesPay float64 `json:"hifes_pay"`
  16244. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16245. // OptTime string `json:"opt_time"`
  16246. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16247. // SetlID string `json:"setl_id"`
  16248. // MafPay float64 `json:"maf_pay"`
  16249. // PsnName string `json:"psn_name"`
  16250. // InsuOptins interface{} `json:"insu_optins"`
  16251. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16252. // ClrOptins string `json:"clr_optins"`
  16253. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16254. // DiseName string `json:"dise_name"`
  16255. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16256. // Age float64 `json:"age"`
  16257. // DtrtCertType string `json:"dtrt_cert_type"`
  16258. // HospLv string `json:"hosp_lv"`
  16259. // } `json:"setlinfo"`
  16260. // Setldetail []struct {
  16261. // FundPayType string `json:"fund_pay_type"`
  16262. // FundPayamt float64 `json:"fund_payamt"`
  16263. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16264. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16265. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16266. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16267. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16268. // } `json:"setldetail"`
  16269. // } `json:"output"`
  16270. // Infcode int `json:"infcode"`
  16271. // WarnMsg interface{} `json:"warn_msg"`
  16272. // Cainfo interface{} `json:"cainfo"`
  16273. // ErrMsg interface{} `json:"err_msg"`
  16274. // RefmsgTime string `json:"refmsg_time"`
  16275. // Signtype interface{} `json:"signtype"`
  16276. // RespondTime string `json:"respond_time"`
  16277. // InfRefmsgid string `json:"inf_refmsgid"`
  16278. // }
  16279. type Result002 struct {
  16280. Cainfo interface{} `json:"cainfo"`
  16281. ErrMsg string `json:"err_msg"`
  16282. InfRefmsgid string `json:"inf_refmsgid"`
  16283. Infcode int64 `json:"infcode"`
  16284. Output struct {
  16285. RxFile string `json:"rx_file"`
  16286. SignDigest string `json:"sign_digest"`
  16287. SignCertSn string `json:"sign_cert_sn"`
  16288. SignCertDn string `json:"sign_cert_dn"`
  16289. } `json:"output"`
  16290. RefmsgTime string `json:"refmsg_time"`
  16291. RespondTime string `json:"respond_time"`
  16292. Signtype interface{} `json:"signtype"`
  16293. WarnMsg interface{} `json:"warn_msg"`
  16294. }
  16295. type Result003 struct {
  16296. Cainfo interface{} `json:"cainfo"`
  16297. ErrMsg string `json:"err_msg"`
  16298. InfRefmsgid string `json:"inf_refmsgid"`
  16299. Infcode int64 `json:"infcode"`
  16300. Output struct {
  16301. HiRxno string `json:"hi_rxno"`
  16302. RxStasCodg string `json:"rx_stas_codg"`
  16303. RxStasName string `json:"rx_stas_name"`
  16304. } `json:"output"`
  16305. RefmsgTime string `json:"refmsg_time"`
  16306. RespondTime string `json:"respond_time"`
  16307. Signtype interface{} `json:"signtype"`
  16308. WarnMsg interface{} `json:"warn_msg"`
  16309. }
  16310. type ResultEleven struct {
  16311. Cainfo string `json:"cainfo"`
  16312. ErrMsg string `json:"err_msg"`
  16313. InfRefmsgid string `json:"inf_refmsgid"`
  16314. Infcode int64 `json:"infcode"`
  16315. Output struct {
  16316. Setlinfo struct {
  16317. SetlTime string `json:"setl_time"`
  16318. CvlservPay float64 `json:"cvlserv_pay"`
  16319. Year string `json:"year"`
  16320. MedType string `json:"med_type"`
  16321. PsnPay float64 `json:"psn_pay"`
  16322. OpterID string `json:"opter_id"`
  16323. Begndate string `json:"begndate"`
  16324. FlxempeFlag string `json:"flxempe_flag"`
  16325. HifmiPay float64 `json:"hifmi_pay"`
  16326. PsnNo string `json:"psn_no"`
  16327. ActPayDedc float64 `json:"act_pay_dedc"`
  16328. MedinsSetlID interface{} `json:"medins_setl_id"`
  16329. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16330. ClrWay string `json:"clr_way"`
  16331. OthPay float64 `json:"oth_pay"`
  16332. Gend string `json:"gend"`
  16333. MdtrtID string `json:"mdtrt_id"`
  16334. AcctPay float64 `json:"acct_pay"`
  16335. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16336. Insutype string `json:"insutype"`
  16337. Invono interface{} `json:"invono"`
  16338. Enddate string `json:"enddate"`
  16339. CashPayamt float64 `json:"cash_payamt"`
  16340. PsnType string `json:"psn_type"`
  16341. FixmedinsName string `json:"fixmedins_name"`
  16342. HifpPay float64 `json:"hifp_pay"`
  16343. NewFlag interface{} `json:"new_flag"`
  16344. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16345. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16346. PayLoc string `json:"pay_loc"`
  16347. ClrType string `json:"clr_type"`
  16348. RefdSetlFlag string `json:"refd_setl_flag"`
  16349. CvlservFlag string `json:"cvlserv_flag"`
  16350. EmpName string `json:"emp_name"`
  16351. Brdy string `json:"brdy"`
  16352. Naty string `json:"naty"`
  16353. Certno string `json:"certno"`
  16354. DiseCode string `json:"dise_code"`
  16355. FixmedinsCode string `json:"fixmedins_code"`
  16356. DedcHospLv string `json:"dedc_hosp_lv"`
  16357. OpterName string `json:"opter_name"`
  16358. Balc float64 `json:"balc"`
  16359. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16360. PsnCertType string `json:"psn_cert_type"`
  16361. HifobPay float64 `json:"hifob_pay"`
  16362. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16363. HifesPay float64 `json:"hifes_pay"`
  16364. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16365. OptTime string `json:"opt_time"`
  16366. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16367. SetlID string `json:"setl_id"`
  16368. MafPay float64 `json:"maf_pay"`
  16369. PsnName string `json:"psn_name"`
  16370. InsuOptins interface{} `json:"insu_optins"`
  16371. PrefFundPay interface{} `json:"pref_fund_pay"`
  16372. ClrOptins string `json:"clr_optins"`
  16373. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16374. DiseName string `json:"dise_name"`
  16375. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16376. Age float64 `json:"age"`
  16377. DtrtCertType string `json:"dtrt_cert_type"`
  16378. HospLv string `json:"hosp_lv"`
  16379. PsnCashPay float64 `json:"psn_cash_pay"`
  16380. } `json:"setlinfo"`
  16381. } `json:"output"`
  16382. RefmsgTime string `json:"refmsg_time"`
  16383. RespondTime string `json:"respond_time"`
  16384. Signtype interface{} `json:"signtype"`
  16385. WarnMsg interface{} `json:"warn_msg"`
  16386. }
  16387. type ResultElevenah struct {
  16388. Cainfo string `json:"cainfo"`
  16389. ErrMsg string `json:"err_msg"`
  16390. InfRefmsgid string `json:"inf_refmsgid"`
  16391. Infcode int64 `json:"infcode"`
  16392. Output struct {
  16393. Setlinfo struct {
  16394. SetlTime int64 `json:"setl_time"`
  16395. CvlservPay float64 `json:"cvlserv_pay"`
  16396. Year string `json:"year"`
  16397. MedType string `json:"med_type"`
  16398. PsnPay float64 `json:"psn_pay"`
  16399. OpterID string `json:"opter_id"`
  16400. Begndate int64 `json:"begndate"`
  16401. FlxempeFlag string `json:"flxempe_flag"`
  16402. HifmiPay float64 `json:"hifmi_pay"`
  16403. PsnNo string `json:"psn_no"`
  16404. ActPayDedc float64 `json:"act_pay_dedc"`
  16405. MedinsSetlID interface{} `json:"medins_setl_id"`
  16406. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16407. ClrWay string `json:"clr_way"`
  16408. OthPay float64 `json:"oth_pay"`
  16409. Gend string `json:"gend"`
  16410. MdtrtID string `json:"mdtrt_id"`
  16411. AcctPay float64 `json:"acct_pay"`
  16412. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16413. Insutype string `json:"insutype"`
  16414. Invono interface{} `json:"invono"`
  16415. Enddate int64 `json:"enddate"`
  16416. CashPayamt float64 `json:"cash_payamt"`
  16417. PsnType string `json:"psn_type"`
  16418. FixmedinsName string `json:"fixmedins_name"`
  16419. HifpPay float64 `json:"hifp_pay"`
  16420. NewFlag interface{} `json:"new_flag"`
  16421. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16422. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16423. PayLoc string `json:"pay_loc"`
  16424. ClrType string `json:"clr_type"`
  16425. RefdSetlFlag string `json:"refd_setl_flag"`
  16426. CvlservFlag string `json:"cvlserv_flag"`
  16427. EmpName string `json:"emp_name"`
  16428. Brdy int64 `json:"brdy"`
  16429. Naty string `json:"naty"`
  16430. Certno string `json:"certno"`
  16431. DiseCode string `json:"dise_code"`
  16432. FixmedinsCode string `json:"fixmedins_code"`
  16433. DedcHospLv string `json:"dedc_hosp_lv"`
  16434. OpterName string `json:"opter_name"`
  16435. Balc float64 `json:"balc"`
  16436. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16437. PsnCertType string `json:"psn_cert_type"`
  16438. HifobPay float64 `json:"hifob_pay"`
  16439. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16440. HifesPay float64 `json:"hifes_pay"`
  16441. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16442. OptTime int64 `json:"opt_time"`
  16443. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16444. SetlID string `json:"setl_id"`
  16445. MafPay float64 `json:"maf_pay"`
  16446. PsnName string `json:"psn_name"`
  16447. InsuOptins interface{} `json:"insu_optins"`
  16448. PrefFundPay interface{} `json:"pref_fund_pay"`
  16449. ClrOptins string `json:"clr_optins"`
  16450. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16451. DiseName string `json:"dise_name"`
  16452. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16453. Age float64 `json:"age"`
  16454. DtrtCertType string `json:"dtrt_cert_type"`
  16455. HospLv string `json:"hosp_lv"`
  16456. PsnCashPay float64 `json:"psn_cash_pay"`
  16457. } `json:"setlinfo"`
  16458. } `json:"output"`
  16459. RefmsgTime string `json:"refmsg_time"`
  16460. RespondTime string `json:"respond_time"`
  16461. Signtype interface{} `json:"signtype"`
  16462. WarnMsg interface{} `json:"warn_msg"`
  16463. }
  16464. type ResultEleven10265 struct {
  16465. Cainfo string `json:"cainfo"`
  16466. ErrMsg string `json:"err_msg"`
  16467. InfRefmsgid string `json:"inf_refmsgid"`
  16468. Infcode string `json:"infcode"`
  16469. Output struct {
  16470. Setlinfo struct {
  16471. SetlTime string `json:"setl_time"`
  16472. CvlservPay float64 `json:"cvlserv_pay"`
  16473. Year string `json:"year"`
  16474. MedType string `json:"med_type"`
  16475. PsnPay float64 `json:"psn_pay"`
  16476. OpterID string `json:"opter_id"`
  16477. Begndate string `json:"begndate"`
  16478. FlxempeFlag string `json:"flxempe_flag"`
  16479. HifmiPay float64 `json:"hifmi_pay"`
  16480. PsnNo string `json:"psn_no"`
  16481. ActPayDedc float64 `json:"act_pay_dedc"`
  16482. MedinsSetlID interface{} `json:"medins_setl_id"`
  16483. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16484. ClrWay string `json:"clr_way"`
  16485. OthPay float64 `json:"oth_pay"`
  16486. Gend string `json:"gend"`
  16487. MdtrtID string `json:"mdtrt_id"`
  16488. AcctPay float64 `json:"acct_pay"`
  16489. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16490. Insutype string `json:"insutype"`
  16491. Invono interface{} `json:"invono"`
  16492. Enddate string `json:"enddate"`
  16493. CashPayamt float64 `json:"cash_payamt"`
  16494. PsnType string `json:"psn_type"`
  16495. FixmedinsName string `json:"fixmedins_name"`
  16496. HifpPay float64 `json:"hifp_pay"`
  16497. NewFlag interface{} `json:"new_flag"`
  16498. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16499. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16500. PayLoc string `json:"pay_loc"`
  16501. ClrType string `json:"clr_type"`
  16502. RefdSetlFlag string `json:"refd_setl_flag"`
  16503. CvlservFlag string `json:"cvlserv_flag"`
  16504. EmpName string `json:"emp_name"`
  16505. Brdy string `json:"brdy"`
  16506. Naty string `json:"naty"`
  16507. Certno string `json:"certno"`
  16508. DiseCode string `json:"dise_code"`
  16509. FixmedinsCode string `json:"fixmedins_code"`
  16510. DedcHospLv string `json:"dedc_hosp_lv"`
  16511. OpterName string `json:"opter_name"`
  16512. Balc float64 `json:"balc"`
  16513. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16514. PsnCertType string `json:"psn_cert_type"`
  16515. HifobPay float64 `json:"hifob_pay"`
  16516. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16517. HifesPay float64 `json:"hifes_pay"`
  16518. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16519. OptTime string `json:"opt_time"`
  16520. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16521. SetlID string `json:"setl_id"`
  16522. MafPay float64 `json:"maf_pay"`
  16523. PsnName string `json:"psn_name"`
  16524. InsuOptins interface{} `json:"insu_optins"`
  16525. PrefFundPay interface{} `json:"pref_fund_pay"`
  16526. ClrOptins string `json:"clr_optins"`
  16527. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16528. DiseName string `json:"dise_name"`
  16529. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16530. Age float64 `json:"age"`
  16531. DtrtCertType string `json:"dtrt_cert_type"`
  16532. HospLv string `json:"hosp_lv"`
  16533. PsnCashPay float64 `json:"psn_cash_pay"`
  16534. } `json:"setlinfo"`
  16535. } `json:"output"`
  16536. RefmsgTime string `json:"refmsg_time"`
  16537. RespondTime string `json:"respond_time"`
  16538. Signtype interface{} `json:"signtype"`
  16539. WarnMsg interface{} `json:"warn_msg"`
  16540. }
  16541. type ResultTwelve struct {
  16542. Cainfo string `json:"cainfo"`
  16543. ErrMsg string `json:"err_msg"`
  16544. InfRefmsgid string `json:"inf_refmsgid"`
  16545. Infcode int64 `json:"infcode"`
  16546. Output struct {
  16547. MdtrtId string `json:"mdtrt_id"`
  16548. ChrgBchno string `json:"chrg_bchno"`
  16549. PsnNo string `json:"psn_no"`
  16550. } `json:"output"`
  16551. RefmsgTime string `json:"refmsg_time"`
  16552. RespondTime string `json:"respond_time"`
  16553. Signtype interface{} `json:"signtype"`
  16554. WarnMsg interface{} `json:"warn_msg"`
  16555. }
  16556. type ResultThirteen struct {
  16557. ErrMsg string `json:"err_msg"`
  16558. InfRefmsgid string `json:"inf_refmsgid"`
  16559. Infcode int64 `json:"infcode"`
  16560. Output struct {
  16561. Result struct {
  16562. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16563. } `json:"result"`
  16564. } `json:"output"`
  16565. RefmsgTime string `json:"refmsg_time"`
  16566. RespondTime string `json:"respond_time"`
  16567. Signtype interface{} `json:"signtype"`
  16568. WarnInfo interface{} `json:"warn_info"`
  16569. }
  16570. type ResultThirteen10265 struct {
  16571. ErrMsg string `json:"err_msg"`
  16572. InfRefmsgid string `json:"inf_refmsgid"`
  16573. Infcode string `json:"infcode"`
  16574. Output struct {
  16575. Result struct {
  16576. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16577. } `json:"result"`
  16578. } `json:"output"`
  16579. RefmsgTime string `json:"refmsg_time"`
  16580. RespondTime string `json:"respond_time"`
  16581. Signtype interface{} `json:"signtype"`
  16582. WarnInfo interface{} `json:"warn_info"`
  16583. }
  16584. type ResultFourteen struct {
  16585. ErrMsg string `json:"err_msg"`
  16586. InfRefmsgid string `json:"inf_refmsgid"`
  16587. Infcode int64 `json:"infcode"`
  16588. Output struct {
  16589. } `json:"output"`
  16590. RefmsgTime string `json:"refmsg_time"`
  16591. RespondTime string `json:"respond_time"`
  16592. Signtype interface{} `json:"signtype"`
  16593. WarnInfo interface{} `json:"warn_info"`
  16594. }
  16595. type ResultCFYLJG001 struct {
  16596. ErrMsg string `json:"err_msg"`
  16597. InfRefmsgid string `json:"inf_refmsgid"`
  16598. Infcode int64 `json:"infcode"`
  16599. Output struct {
  16600. RxTraceCode string `json:"rx_trace_code"`
  16601. HiRxno string `json:"hi_rxno"`
  16602. } `json:"output"`
  16603. RefmsgTime string `json:"refmsg_time"`
  16604. RespondTime string `json:"respond_time"`
  16605. Signtype interface{} `json:"signtype"`
  16606. WarnInfo interface{} `json:"warn_info"`
  16607. }
  16608. type ResultCFYLJG007 struct {
  16609. ErrMsg string `json:"err_msg"`
  16610. InfRefmsgid string `json:"inf_refmsgid"`
  16611. Infcode int64 `json:"infcode"`
  16612. Output struct {
  16613. HiRxno string `json:"hi_rxno"`
  16614. RxStasName string `json:"rx_stas_name"`
  16615. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16616. Seltdelts []interface{} `json:"seltdelts"`
  16617. RxUsedStasName string `json:"rx_used_stas_name"`
  16618. RxStasCodg string `json:"rx_stas_codg"`
  16619. } `json:"output"`
  16620. RefmsgTime string `json:"refmsg_time"`
  16621. RespondTime string `json:"respond_time"`
  16622. Signtype interface{} `json:"signtype"`
  16623. WarnInfo interface{} `json:"warn_info"`
  16624. }
  16625. type ResultCFYLJG002 struct {
  16626. ErrMsg string `json:"err_msg"`
  16627. InfRefmsgid string `json:"inf_refmsgid"`
  16628. Infcode int64 `json:"infcode"`
  16629. Output struct {
  16630. RxFile string `json:"rx_file"`
  16631. SignDigest string `json:"sign_digest"`
  16632. SignCertSn string `json:"sign_cert_sn"`
  16633. SignCertDn string `json:"sign_cert_dn"`
  16634. } `json:"output"`
  16635. RefmsgTime string `json:"refmsg_time"`
  16636. RespondTime string `json:"respond_time"`
  16637. Signtype interface{} `json:"signtype"`
  16638. WarnInfo interface{} `json:"warn_info"`
  16639. }
  16640. type ResultCFYLJG003 struct {
  16641. ErrMsg string `json:"err_msg"`
  16642. InfRefmsgid string `json:"inf_refmsgid"`
  16643. Infcode int64 `json:"infcode"`
  16644. Output struct {
  16645. HiRxno string `json:"hi_rxno"`
  16646. RxStasCodg string `json:"rx_stas_codg"`
  16647. RxStasName string `json:"rx_stas_name"`
  16648. } `json:"output"`
  16649. RefmsgTime string `json:"refmsg_time"`
  16650. RespondTime string `json:"respond_time"`
  16651. Signtype interface{} `json:"signtype"`
  16652. WarnInfo interface{} `json:"warn_info"`
  16653. }
  16654. type ResultCFYLJG004 struct {
  16655. ErrMsg string `json:"err_msg"`
  16656. InfRefmsgid string `json:"inf_refmsgid"`
  16657. Infcode int64 `json:"infcode"`
  16658. Output struct {
  16659. HiRxno string `json:"hi_rxno"`
  16660. RxStasCodg string `json:"rx_stas_codg"`
  16661. RxStasName string `json:"rx_stas_name"`
  16662. } `json:"output"`
  16663. RefmsgTime string `json:"refmsg_time"`
  16664. RespondTime string `json:"respond_time"`
  16665. Signtype interface{} `json:"signtype"`
  16666. WarnInfo interface{} `json:"warn_info"`
  16667. }
  16668. type ResultCFYLJG008 struct {
  16669. ErrMsg string `json:"err_msg"`
  16670. InfRefmsgid string `json:"inf_refmsgid"`
  16671. Infcode int64 `json:"infcode"`
  16672. Output struct {
  16673. PoolareaNo string `json:"poolareaNo"`
  16674. AdmdvsName string `json:"admdvsName"`
  16675. Count string `json:"count"`
  16676. } `json:"output"`
  16677. RefmsgTime string `json:"refmsg_time"`
  16678. RespondTime string `json:"respond_time"`
  16679. Signtype interface{} `json:"signtype"`
  16680. WarnInfo interface{} `json:"warn_info"`
  16681. }
  16682. type ResultCFYLJG005 struct {
  16683. ErrMsg string `json:"err_msg"`
  16684. InfRefmsgid string `json:"inf_refmsgid"`
  16685. Infcode int64 `json:"infcode"`
  16686. Output struct {
  16687. HiRxNo string `json:"hi_rxno"`
  16688. FixMedinsCode string `json:"fixmedins_code"`
  16689. FixMedinsName string `json:"fixmedins_name"`
  16690. RxStasCodg string `json:"rx_stas_codg"`
  16691. RxStasName string `json:"rx_stas_name"`
  16692. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16693. RxUserdStasName string `json:"rx_userd_stas_name"`
  16694. PrscTime string `json:"prsc_time"`
  16695. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16696. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16697. RxUsedWayName string `json:"rx_used_way_name"`
  16698. RxFrquCodg string `json:"rx_frqu_codg"`
  16699. RxFrquName string `json:"rx_frqu_name"`
  16700. RxDosunt string `json:"rx_dosunt"`
  16701. RxDoscnt float64 `json:"rx_doscnt"`
  16702. RxDrordDscr string `json:"rx_drord_dscr"`
  16703. ValiDays int64 `json:"vali_days"`
  16704. ValiEndTime string `json:"vali_end_time"`
  16705. ReptFlag string `json:"rept_flag"`
  16706. MaxReptCnt int64 `json:"max_rept_cnt"`
  16707. ReptdCnt int64 `json:"reptd_cnt"`
  16708. MinInrvDays int64 `json:"min_inrv_days"`
  16709. RxTypeCode string `json:"rx_type_code"`
  16710. RxTypeName string `json:"rx_type_name"`
  16711. LongRxFlag string `json:"long_rx_flag"`
  16712. RxDetlList []struct {
  16713. MedListCodg string `json:"med_list_codg"`
  16714. MedinsListCodg string `json:"medins_list_codg"`
  16715. HospPrepFlag string `json:"hosp_prep_flag"`
  16716. RxItemTypeCode string `json:"rx_item_type_code"`
  16717. RxItemTypeName string `json:"rx_item_type_name"`
  16718. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16719. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16720. TcmHerbFoote string `json:"tcmherb_foote"`
  16721. MednTypeCode string `json:"medn_type_code"`
  16722. MednTypeName string `json:"medn_type_name"`
  16723. MainMedcFlag string `json:"main_medc_flag"`
  16724. UrgtFlag string `json:"urgt_flag"`
  16725. BasMednFlag string `json:"bas_medn_flag"`
  16726. ImpDrugFlag string `json:"imp_drug_flag"`
  16727. ProdBarc string `json:"prod_barc"`
  16728. DrugProdname string `json:"drug_prodname"`
  16729. GennameCodg string `json:"genname_codg"`
  16730. DrugGenname string `json:"drug_genname"`
  16731. DrugDosform string `json:"drug_dosform"`
  16732. DrugSpec string `json:"drug_spec"`
  16733. PrdrName string `json:"prdr_name"`
  16734. MedcWayCodg string `json:"medc_way_codg"`
  16735. MedcWayDscr string `json:"medc_way_dscr"`
  16736. MedcBegntime string `json:"medc_begntime"`
  16737. MedcEndtime string `json:"medc_endtime"`
  16738. MedcDays float64 `json:"medc_days"`
  16739. DrugPric float64 `json:"drug_pric"`
  16740. DrugSumamt float64 `json:"drug_sumamt"`
  16741. DrugCnt float64 `json:"drug_cnt"`
  16742. DrugDosunt string `json:"drug_dosunt"`
  16743. SinDoscnt float64 `json:"sin_doscnt"`
  16744. SinDosunt string `json:"sin_dosunt"`
  16745. UsedFrquCodg string `json:"used_frqu_codg"`
  16746. UsedFrquName string `json:"used_frqu_name"`
  16747. DrugTotlcnt string `json:"drug_totlcnt"`
  16748. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16749. DiseCodg string `json:"dise_codg"`
  16750. HospApprFlag string `json:"hosp_appr_flag"`
  16751. } `json:"rx_detl_list"`
  16752. RxOtpinfo struct {
  16753. MedType string `json:"med_type"`
  16754. IptOtpNo string `json:"ipt_otp_no"`
  16755. OtpIptFlag string `json:"otp_ipt_flag"`
  16756. PatnName string `json:"patn_name"`
  16757. PatnAge float64 `json:"patn_age"`
  16758. PatnHgt float64 `json:"patn_hgt"`
  16759. PatnWt float64 `json:"patn_wt"`
  16760. Gend string `json:"gend"`
  16761. GesoVal float64 `json:"geso_val"`
  16762. NwbFlag string `json:"nwb_flag"`
  16763. NwbAge string `json:"nwb_age"`
  16764. SuckPrdFlag string `json:"suck_prd_flag"`
  16765. AlgsHis string `json:"algs_his"`
  16766. Insutype string `json:"insutype"`
  16767. PrscDeptName string `json:"prsc_dept_name"`
  16768. PrscDrName string `json:"prsc_dr_name"`
  16769. PharName string `json:"phar_name"`
  16770. PharChkTime string `json:"phar_chk_time"`
  16771. MdtrtTime string `json:"mdtrt_time"`
  16772. DiseCodg string `json:"dise_codg"`
  16773. DiseName string `json:"dise_name"`
  16774. SpDiseFlag string `json:"sp_dise_flag"`
  16775. MaindiagCode string `json:"maindiag_code"`
  16776. MaindiagName string `json:"maindiag_name"`
  16777. DiseCondDscr string `json:"dise_cond_dscr"`
  16778. FstdiagFlag string `json:"fstdiag_flag"`
  16779. } `json:"rx_otpinfo"`
  16780. RxDiseList []struct {
  16781. DiagType string `json:"diag_type"`
  16782. MaindiagFlag string `json:"maindiag_flag"`
  16783. DiagSrtNo string `json:"diag_srt_no"`
  16784. DiagCode string `json:"diag_code"`
  16785. DiagName string `json:"diag_name"`
  16786. DiagDept string `json:"diag_dept"`
  16787. DiagDrNo string `json:"diag_dr_no"`
  16788. DiagDrName string `json:"diag_dr_name"`
  16789. DiagTime string `json:"diag_time"`
  16790. TcmDiseCode string `json:"tcm_dise_code"`
  16791. TcmDiseName string `json:"tcm_dise_name"`
  16792. TcmSympCode string `json:"tcmsymp_code"`
  16793. TcmSymp string `json:"tcmsymp"`
  16794. } `json:"rx_dise_list"`
  16795. } `json:"output"`
  16796. RefmsgTime string `json:"refmsg_time"`
  16797. RespondTime string `json:"respond_time"`
  16798. Signtype interface{} `json:"signtype"`
  16799. WarnInfo interface{} `json:"warn_info"`
  16800. }
  16801. type ResultCFYLJG006 struct {
  16802. ErrMsg string `json:"err_msg"`
  16803. InfRefmsgid string `json:"inf_refmsgid"`
  16804. Infcode int64 `json:"infcode"`
  16805. Output struct {
  16806. HiRxNo string `json:"hi_rxno"`
  16807. PharCode string `json:"phar_code"`
  16808. PharName string `json:"phar_name"`
  16809. RxChkOpnn string `json:"rx_chk_opnn"`
  16810. RxChkTime string `json:"rx_chk_time"`
  16811. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16812. RxChkStasName string `json:"rx_chk_stas_name"`
  16813. RxStasCodg string `json:"rx_stas_codg"`
  16814. RxStasName string `json:"rx_stas_name"`
  16815. } `json:"output"`
  16816. RefmsgTime string `json:"refmsg_time"`
  16817. RespondTime string `json:"respond_time"`
  16818. Signtype interface{} `json:"signtype"`
  16819. WarnInfo interface{} `json:"warn_info"`
  16820. }
  16821. type ResultFourteen10265 struct {
  16822. ErrMsg string `json:"err_msg"`
  16823. InfRefmsgid string `json:"inf_refmsgid"`
  16824. Infcode string `json:"infcode"`
  16825. Output struct {
  16826. } `json:"output"`
  16827. RefmsgTime string `json:"refmsg_time"`
  16828. RespondTime string `json:"respond_time"`
  16829. Signtype interface{} `json:"signtype"`
  16830. WarnInfo interface{} `json:"warn_info"`
  16831. }
  16832. type ResultSixteen struct {
  16833. Cainfo string `json:"cainfo"`
  16834. ErrMsg string `json:"err_msg"`
  16835. InfRefmsgid string `json:"inf_refmsgid"`
  16836. Infcode int64 `json:"infcode"`
  16837. Output struct {
  16838. Setlinfo struct {
  16839. MdtrtID string `json:"mdtrt_id"`
  16840. SetlID string `json:"setl_id"`
  16841. ClrOptins string `json:"clr_optins"`
  16842. SetlTime string `json:"setl_time"`
  16843. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16844. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16845. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16846. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16847. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16848. ActPayDedc float64 `json:"act_pay_dedc"`
  16849. HifpPay float64 `json:"hifp_pay"`
  16850. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16851. Lfpay float64 `json:"selfpay"`
  16852. CvlservPay float64 `json:"cvlserv_pay"`
  16853. HifesPay float64 `json:"hifes_pay"`
  16854. HifmiPay float64 `json:"hifmi_pay"`
  16855. HifobPay float64 `json:"hifob_pay"`
  16856. MafPay float64 `json:"maf_pay"`
  16857. OthPay float64 `json:"oth_pay"`
  16858. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16859. PsnPartAmt float64 `json:"psn_part_amt"`
  16860. AcctPay float64 `json:"acct_pay"`
  16861. Balc float64 `json:"balc"`
  16862. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16863. HospPartAmt float64 `json:"hosp_part_amt"`
  16864. MedinsSetlID string `json:"medins_setl_id"`
  16865. PdnCashPay string `json:"pdn_cash_pay"`
  16866. } `json:"setlinfo"`
  16867. } `json:"output"`
  16868. RefmsgTime string `json:"refmsg_time"`
  16869. RespondTime string `json:"respond_time"`
  16870. Signtype interface{} `json:"signtype"`
  16871. WarnMsg interface{} `json:"warn_msg"`
  16872. }
  16873. type ResultSixteen10265 struct {
  16874. Cainfo string `json:"cainfo"`
  16875. ErrMsg string `json:"err_msg"`
  16876. InfRefmsgid string `json:"inf_refmsgid"`
  16877. Infcode string `json:"infcode"`
  16878. Output struct {
  16879. Setlinfo struct {
  16880. MdtrtID string `json:"mdtrt_id"`
  16881. SetlID string `json:"setl_id"`
  16882. ClrOptins string `json:"clr_optins"`
  16883. SetlTime string `json:"setl_time"`
  16884. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16885. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16886. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16887. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16888. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16889. ActPayDedc float64 `json:"act_pay_dedc"`
  16890. HifpPay float64 `json:"hifp_pay"`
  16891. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16892. Lfpay float64 `json:"selfpay"`
  16893. CvlservPay float64 `json:"cvlserv_pay"`
  16894. HifesPay float64 `json:"hifes_pay"`
  16895. HifmiPay float64 `json:"hifmi_pay"`
  16896. HifobPay float64 `json:"hifob_pay"`
  16897. MafPay float64 `json:"maf_pay"`
  16898. OthPay float64 `json:"oth_pay"`
  16899. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16900. PsnPartAmt float64 `json:"psn_part_amt"`
  16901. AcctPay float64 `json:"acct_pay"`
  16902. Balc float64 `json:"balc"`
  16903. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16904. HospPartAmt float64 `json:"hosp_part_amt"`
  16905. MedinsSetlID string `json:"medins_setl_id"`
  16906. PdnCashPay string `json:"pdn_cash_pay"`
  16907. } `json:"setlinfo"`
  16908. } `json:"output"`
  16909. RefmsgTime string `json:"refmsg_time"`
  16910. RespondTime string `json:"respond_time"`
  16911. Signtype interface{} `json:"signtype"`
  16912. WarnMsg interface{} `json:"warn_msg"`
  16913. }
  16914. type ResultSixteen10265Two struct {
  16915. Cainfo string `json:"cainfo"`
  16916. ErrMsg string `json:"err_msg"`
  16917. InfRefmsgid string `json:"inf_refmsgid"`
  16918. Infcode string `json:"infcode"`
  16919. Output struct {
  16920. Setlinfo interface{} `json:"setlinfo"`
  16921. } `json:"output"`
  16922. RefmsgTime string `json:"refmsg_time"`
  16923. RespondTime string `json:"respond_time"`
  16924. Signtype interface{} `json:"signtype"`
  16925. WarnMsg interface{} `json:"warn_msg"`
  16926. }
  16927. type ResultgzSixteen10265Two struct {
  16928. Cainfo string `json:"cainfo"`
  16929. ErrMsg string `json:"err_msg"`
  16930. InfRefmsgid string `json:"inf_refmsgid"`
  16931. Infcode int64 `json:"infcode"`
  16932. Output struct {
  16933. Setlinfo interface{} `json:"setlinfo"`
  16934. } `json:"output"`
  16935. RefmsgTime string `json:"refmsg_time"`
  16936. RespondTime string `json:"respond_time"`
  16937. Signtype interface{} `json:"signtype"`
  16938. WarnMsg interface{} `json:"warn_msg"`
  16939. }
  16940. type ResultSeventeen struct {
  16941. ErrMsg string `json:"err_msg"`
  16942. InfRefmsgid string `json:"inf_refmsgid"`
  16943. Infcode int64 `json:"infcode"`
  16944. Output struct {
  16945. SetlListId string `json:"setl_list_id"`
  16946. } `json:"output"`
  16947. RefmsgTime string `json:"refmsg_time"`
  16948. RespondTime string `json:"respond_time"`
  16949. Signtype string `json:"signtype"`
  16950. WarnInfo string `json:"warn_info"`
  16951. }
  16952. type ResultSeventeenOther struct {
  16953. ErrMsg string `json:"err_msg"`
  16954. InfRefmsgid string `json:"inf_refmsgid"`
  16955. Infcode string `json:"infcode"`
  16956. Output struct {
  16957. SetlListId string `json:"setl_list_id"`
  16958. } `json:"output"`
  16959. RefmsgTime string `json:"refmsg_time"`
  16960. RespondTime string `json:"respond_time"`
  16961. Signtype string `json:"signtype"`
  16962. WarnInfo string `json:"warn_info"`
  16963. }
  16964. type Result90991 struct {
  16965. ErrMsg string `json:"err_msg"`
  16966. InfRefmsgid string `json:"inf_refmsgid"`
  16967. Infcode int64 `json:"infcode"`
  16968. Output struct {
  16969. Result struct {
  16970. PsnNo string `json:"psn_no"`
  16971. CardStat string `json:"card_stat"`
  16972. Certno string `json:"certno"`
  16973. PsnName string `json:"psn_name"`
  16974. CheckStat string `json:"check_stat"`
  16975. SscnoCheckStat string `json:"sscno_check_stat"`
  16976. } `json:"result"`
  16977. } `json:"output"`
  16978. RefmsgTime string `json:"refmsg_time"`
  16979. RespondTime string `json:"respond_time"`
  16980. Signtype interface{} `json:"signtype"`
  16981. WarnInfo interface{} `json:"warn_info"`
  16982. }
  16983. type Result90100 struct {
  16984. ErrMsg string `json:"err_msg"`
  16985. InfRefmsgid string `json:"inf_refmsgid"`
  16986. Infcode int64 `json:"infcode"`
  16987. Output struct {
  16988. PoolareaNo string `json:"poolarea_no"`
  16989. PoolareaNoName string `json:"poolarea_no_name"`
  16990. Insutype string `json:"insutype"`
  16991. InsutypeName string `json:"insutype_name"`
  16992. ClctType string `json:"clct_type"`
  16993. ClctTypeName string `json:"clct_type_name"`
  16994. ClctFlag string `json:"clct_flag"`
  16995. ClctFlagName string `json:"clct_flag_name"`
  16996. AccrymBegn string `json:"accrym_begn"`
  16997. AccrymEnd string `json:"accrym_end"`
  16998. ClctTime string `json:"clct_time"`
  16999. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  17000. } `json:"output"`
  17001. RefmsgTime string `json:"refmsg_time"`
  17002. RespondTime string `json:"respond_time"`
  17003. Signtype interface{} `json:"signtype"`
  17004. WarnInfo interface{} `json:"warn_info"`
  17005. }
  17006. type Custom struct {
  17007. DetItemFeeSumamt string
  17008. Cut string
  17009. FeedetlSn string
  17010. Price string
  17011. MedListCodg string
  17012. Type int64
  17013. AdviceId int64
  17014. ProjectId int64
  17015. ItemId int64
  17016. }
  17017. type Result5301 struct {
  17018. ErrMsg string `json:"err_msg"`
  17019. InfRefmsgid string `json:"inf_refmsgid"`
  17020. Infcode int64 `json:"infcode"`
  17021. Output struct {
  17022. Result []struct {
  17023. OpspDiseCode string `json:"opsp_dise_code"`
  17024. OpspDiseName string `json:"opsp_dise_name"`
  17025. Begndate string `json:"begndate"`
  17026. Enddate string `json:"enddate"`
  17027. } `json:"feedetail"`
  17028. } `json:"output"`
  17029. RefmsgTime string `json:"refmsg_time"`
  17030. RespondTime string `json:"respond_time"`
  17031. Signtype interface{} `json:"signtype"`
  17032. WarnInfo interface{} `json:"warn_info"`
  17033. }
  17034. type Result5301For10265 struct {
  17035. ErrMsg string `json:"err_msg"`
  17036. InfRefmsgid string `json:"inf_refmsgid"`
  17037. Infcode string `json:"infcode"`
  17038. Output struct {
  17039. Result []struct {
  17040. OpspDiseCode string `json:"opsp_dise_code"`
  17041. OpspDiseName string `json:"opsp_dise_name"`
  17042. Begndate string `json:"begndate"`
  17043. Enddate string `json:"enddate"`
  17044. } `json:"feedetail"`
  17045. } `json:"output"`
  17046. RefmsgTime string `json:"refmsg_time"`
  17047. RespondTime string `json:"respond_time"`
  17048. Signtype interface{} `json:"signtype"`
  17049. WarnInfo interface{} `json:"warn_info"`
  17050. }
  17051. //获取个人信息----挂号-----上传就诊信息
  17052. func (c *HisApiController) GetRegisterInfo() {
  17053. id, _ := c.GetInt64("id")
  17054. record_time := c.GetString("record_time")
  17055. settlementValue, _ := c.GetInt64("settlement_value")
  17056. medical_insurance_card := c.GetString("medical_insurance_card")
  17057. name := c.GetString("name")
  17058. id_card_type, _ := c.GetInt64("id_card_type")
  17059. certificates, _ := c.GetInt64("certificates")
  17060. medical_care, _ := c.GetInt64("medical_care")
  17061. birthday := c.GetString("birthday")
  17062. id_card := c.GetString("id_card")
  17063. register_type, _ := c.GetInt64("register")
  17064. doctor, _ := c.GetInt64("doctor")
  17065. department, _ := c.GetInt64("department")
  17066. gender, _ := c.GetInt64("sex")
  17067. registration_fee, _ := c.GetFloat("registration_fee")
  17068. medical_expenses, _ := c.GetFloat("medical_expenses")
  17069. social_type, _ := c.GetInt64("social_type")
  17070. admin_user_id, _ := c.GetInt64("admin_user_id")
  17071. insuplc_admdvs := c.GetString("insuplc_admdvs")
  17072. mdtrt_type := c.GetString("mdtrt_type")
  17073. if id_card_type == 5 {
  17074. id_card_type = 4
  17075. }
  17076. timeLayout := "2006-01-02"
  17077. loc, _ := time.LoadLocation("Local")
  17078. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  17079. birthUnix := birthdays.Unix()
  17080. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17081. if err != nil {
  17082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17083. return
  17084. }
  17085. recordDateTime := theTime.Unix()
  17086. adminInfo := c.GetAdminUserInfo()
  17087. var patient service.Patients
  17088. if id == 0 {
  17089. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  17090. } else {
  17091. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  17092. }
  17093. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17094. if patientPrescription.ID == 0 {
  17095. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17096. }
  17097. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17098. if patient.ID == 0 {
  17099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17100. return
  17101. }
  17102. if len(patient.IdCardNo) == 0 {
  17103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17104. return
  17105. }
  17106. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17107. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  17108. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  17109. //就诊结算未完成,不能进行二次挂号
  17110. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  17111. //if len(his) >= 1 {
  17112. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  17113. // if len(his) >= 1 && order.ID == 0 {
  17114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  17115. // return
  17116. // }
  17117. //}
  17118. //var register_log string
  17119. if config.IsOpen == 1 {
  17120. var res ResultTwo
  17121. var res10265 ResultTwo10265
  17122. var PsnNo string
  17123. var PsnCertType string
  17124. var Certno string
  17125. var PsnName string
  17126. var Gend string
  17127. var Naty string
  17128. var Brdy string
  17129. var Age float64
  17130. var infoStr string
  17131. var idetinfoStr string
  17132. var infocode int64
  17133. var verify_number string
  17134. fmt.Println(verify_number)
  17135. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  17136. psn_info, _ := service.GetPsnByPatientId(id)
  17137. PsnNo = psn_info.PsnNo
  17138. PsnCertType = psn_info.PsnCertType
  17139. Certno = psn_info.Certno
  17140. PsnName = psn_info.PsnName
  17141. Gend = psn_info.Gend
  17142. Naty = psn_info.Naty
  17143. Brdy = psn_info.Brdy
  17144. Age = psn_info.Age
  17145. infoStr = psn_info.Insuinfo
  17146. idetinfoStr = psn_info.Idetinfo
  17147. infocode = 0
  17148. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17149. psn_info, _ := service.GetPsnByPatientId(id)
  17150. PsnNo = psn_info.PsnNo
  17151. PsnCertType = psn_info.PsnCertType
  17152. Certno = psn_info.Certno
  17153. PsnName = psn_info.PsnName
  17154. Gend = psn_info.Gend
  17155. Naty = psn_info.Naty
  17156. Brdy = psn_info.Brdy
  17157. Age = psn_info.Age
  17158. infoStr = psn_info.Insuinfo
  17159. idetinfoStr = psn_info.Idetinfo
  17160. infocode = 0
  17161. verify_number = psn_info.VerifyNumber
  17162. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17163. if id_card_type == 2 {
  17164. //请求内网数据
  17165. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  17166. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17167. "&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
  17168. resp, requestErr := http.Get(api)
  17169. if requestErr != nil {
  17170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17171. return
  17172. }
  17173. body, ioErr := ioutil.ReadAll(resp.Body)
  17174. if ioErr != nil {
  17175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17177. return
  17178. }
  17179. var respJSON map[string]interface{}
  17180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17183. return
  17184. }
  17185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17186. result_byte, _ := json.Marshal(respJSON)
  17187. result := string(result_byte)
  17188. var dat map[string]interface{}
  17189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17190. fmt.Println(dat)
  17191. } else {
  17192. fmt.Println(err)
  17193. }
  17194. userJSONBytes, _ := json.Marshal(dat)
  17195. var res ResultTwo
  17196. var resTwo10265 ResultTwo10265
  17197. if miConfig.Code == "H15049901371" {
  17198. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17199. utils.ErrorLog("解析失败:%v", err)
  17200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17201. return
  17202. }
  17203. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17204. res.Infcode = Infcode
  17205. res.ErrMsg = resTwo10265.ErrMsg
  17206. res.Output = resTwo10265.Output
  17207. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17208. res.RespondTime = resTwo10265.RespondTime
  17209. res.WarnInfo = resTwo10265.WarnInfo
  17210. } else {
  17211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17212. utils.ErrorLog("解析失败:%v", err)
  17213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17214. return
  17215. }
  17216. }
  17217. //var insutypes []string
  17218. //var insutype string
  17219. //var is390 int = 0
  17220. //var is310 int = 0
  17221. //for _, item := range res.Output.Iinfo {
  17222. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17223. // insutypes = append(insutypes, item.Insutype)
  17224. // }
  17225. //}
  17226. //if len(insutypes) == 1 {
  17227. // insutype = insutypes[0]
  17228. //} else {
  17229. // for _, i := range insutypes {
  17230. // if i == "390" {
  17231. // is390 = 1
  17232. // }
  17233. //
  17234. // if i == "310" {
  17235. // is310 = 1
  17236. // }
  17237. // }
  17238. //}
  17239. //if is390 == 1 {
  17240. // insutype = "390"
  17241. //}
  17242. //if is310 == 1 {
  17243. // insutype = "310"
  17244. //}
  17245. //if len(insutypes) == 0 {
  17246. // insutype = "310"
  17247. //}
  17248. PsnNo = res.Output.Baseinfo.PsnNo
  17249. PsnCertType = res.Output.Baseinfo.PsnCertType
  17250. Certno = res.Output.Baseinfo.Certno
  17251. PsnName = res.Output.Baseinfo.PsnName
  17252. Gend = res.Output.Baseinfo.Gend
  17253. Naty = res.Output.Baseinfo.Naty
  17254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17256. infoStr = string(Iinfos)
  17257. idetinfoStr = string(Idetinfos)
  17258. infocode = res.Infcode
  17259. //infocode = 0
  17260. //verify_number = psn_info.VerifyNumber
  17261. } else {
  17262. psn_info, _ := service.GetPsnByPatientId(id)
  17263. PsnNo = psn_info.PsnNo
  17264. PsnCertType = psn_info.PsnCertType
  17265. Certno = psn_info.Certno
  17266. PsnName = psn_info.PsnName
  17267. Gend = psn_info.Gend
  17268. Naty = psn_info.Naty
  17269. Brdy = psn_info.Brdy
  17270. Age = psn_info.Age
  17271. infoStr = psn_info.Insuinfo
  17272. idetinfoStr = psn_info.Idetinfo
  17273. infocode = 0
  17274. verify_number = psn_info.VerifyNumber
  17275. }
  17276. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17277. if id_card_type == 1 {
  17278. psn_info, _ := service.GetPsnByPatientId(id)
  17279. PsnNo = psn_info.PsnNo
  17280. PsnCertType = psn_info.PsnCertType
  17281. Certno = psn_info.Certno
  17282. PsnName = psn_info.PsnName
  17283. Gend = psn_info.Gend
  17284. Naty = psn_info.Naty
  17285. Brdy = psn_info.Brdy
  17286. Age = psn_info.Age
  17287. infoStr = psn_info.Insuinfo
  17288. idetinfoStr = psn_info.Idetinfo
  17289. infocode = 0
  17290. verify_number = psn_info.VerifyNumber
  17291. } else if id_card_type == 2 {
  17292. 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)
  17293. fmt.Println(errMsgLog)
  17294. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17295. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17296. utils.ErrorLog("解析失败:%v", err)
  17297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17298. return
  17299. }
  17300. PsnNo = res.Output.Baseinfo.PsnNo
  17301. PsnCertType = res.Output.Baseinfo.PsnCertType
  17302. Certno = res.Output.Baseinfo.Certno
  17303. PsnName = res.Output.Baseinfo.PsnName
  17304. Gend = res.Output.Baseinfo.Gend
  17305. Naty = res.Output.Baseinfo.Naty
  17306. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17307. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17308. infoStr = string(Iinfos)
  17309. idetinfoStr = string(Idetinfos)
  17310. infocode = res.Infcode
  17311. }
  17312. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17313. if id_card_type == 1 {
  17314. psn_info, _ := service.GetPsnByPatientId(id)
  17315. PsnNo = psn_info.PsnNo
  17316. PsnCertType = psn_info.PsnCertType
  17317. Certno = psn_info.Certno
  17318. PsnName = psn_info.PsnName
  17319. Gend = psn_info.Gend
  17320. Naty = psn_info.Naty
  17321. Brdy = psn_info.Brdy
  17322. Age = psn_info.Age
  17323. infoStr = psn_info.Insuinfo
  17324. idetinfoStr = psn_info.Idetinfo
  17325. infocode = 0
  17326. verify_number = psn_info.VerifyNumber
  17327. } else if id_card_type == 2 {
  17328. 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, "")
  17329. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17330. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17331. utils.ErrorLog("解析失败:%v", err)
  17332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17333. return
  17334. }
  17335. PsnNo = res.Output.Baseinfo.PsnNo
  17336. PsnCertType = res.Output.Baseinfo.PsnCertType
  17337. Certno = res.Output.Baseinfo.Certno
  17338. PsnName = res.Output.Baseinfo.PsnName
  17339. Gend = res.Output.Baseinfo.Gend
  17340. Naty = res.Output.Baseinfo.Naty
  17341. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17342. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17343. infoStr = string(Iinfos)
  17344. idetinfoStr = string(Idetinfos)
  17345. infocode = res.Infcode
  17346. } else {
  17347. psn_info, _ := service.GetPsnByPatientId(id)
  17348. PsnNo = psn_info.PsnNo
  17349. PsnCertType = psn_info.PsnCertType
  17350. Certno = psn_info.Certno
  17351. PsnName = psn_info.PsnName
  17352. Gend = psn_info.Gend
  17353. Naty = psn_info.Naty
  17354. Brdy = psn_info.Brdy
  17355. Age = psn_info.Age
  17356. infoStr = psn_info.Insuinfo
  17357. idetinfoStr = psn_info.Idetinfo
  17358. infocode = 0
  17359. verify_number = psn_info.VerifyNumber
  17360. }
  17361. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17362. psn_info, _ := service.GetPsnByPatientId(id)
  17363. PsnNo = psn_info.PsnNo
  17364. PsnCertType = psn_info.PsnCertType
  17365. Certno = psn_info.Certno
  17366. PsnName = psn_info.PsnName
  17367. Gend = psn_info.Gend
  17368. Naty = psn_info.Naty
  17369. Brdy = psn_info.Brdy
  17370. Age = psn_info.Age
  17371. infoStr = psn_info.Insuinfo
  17372. idetinfoStr = psn_info.Idetinfo
  17373. infocode = 0
  17374. verify_number = psn_info.VerifyNumber
  17375. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17376. if id_card_type == 1 {
  17377. psn_info, _ := service.GetPsnByPatientId(id)
  17378. PsnNo = psn_info.PsnNo
  17379. PsnCertType = psn_info.PsnCertType
  17380. Certno = psn_info.Certno
  17381. PsnName = psn_info.PsnName
  17382. Gend = psn_info.Gend
  17383. Naty = psn_info.Naty
  17384. Brdy = psn_info.Brdy
  17385. Age = psn_info.Age
  17386. infoStr = psn_info.Insuinfo
  17387. idetinfoStr = psn_info.Idetinfo
  17388. infocode = 0
  17389. verify_number = psn_info.VerifyNumber
  17390. } else if id_card_type == 2 {
  17391. 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)
  17392. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17394. utils.ErrorLog("解析失败:%v", err)
  17395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17396. return
  17397. }
  17398. PsnNo = res.Output.Baseinfo.PsnNo
  17399. PsnCertType = res.Output.Baseinfo.PsnCertType
  17400. Certno = res.Output.Baseinfo.Certno
  17401. PsnName = res.Output.Baseinfo.PsnName
  17402. Gend = res.Output.Baseinfo.Gend
  17403. Naty = res.Output.Baseinfo.Naty
  17404. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17405. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17406. infoStr = string(Iinfos)
  17407. idetinfoStr = string(Idetinfos)
  17408. infocode = res.Infcode
  17409. } else if id_card_type == 4 {
  17410. psn_info, _ := service.GetPsnByPatientId(id)
  17411. PsnNo = psn_info.PsnNo
  17412. PsnCertType = psn_info.PsnCertType
  17413. Certno = psn_info.Certno
  17414. PsnName = psn_info.PsnName
  17415. Gend = psn_info.Gend
  17416. Naty = psn_info.Naty
  17417. Brdy = psn_info.Brdy
  17418. Age = psn_info.Age
  17419. infoStr = psn_info.Insuinfo
  17420. idetinfoStr = psn_info.Idetinfo
  17421. infocode = 0
  17422. verify_number = psn_info.VerifyNumber
  17423. }
  17424. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17425. var result string
  17426. var requestLog string
  17427. 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), "")
  17428. if id_card_type == 4 {
  17429. psn_info, _ := service.GetPsnByPatientId(id)
  17430. PsnNo = psn_info.PsnNo
  17431. PsnCertType = psn_info.PsnCertType
  17432. Certno = psn_info.Certno
  17433. PsnName = psn_info.PsnName
  17434. Gend = psn_info.Gend
  17435. Naty = psn_info.Naty
  17436. Brdy = psn_info.Brdy
  17437. Age = psn_info.Age
  17438. infoStr = psn_info.Insuinfo
  17439. idetinfoStr = psn_info.Idetinfo
  17440. infocode = 0
  17441. verify_number = psn_info.VerifyNumber
  17442. } else {
  17443. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17444. if miConfig.Code == "H15049901371" {
  17445. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17446. utils.ErrorLog("解析失败:%v", err)
  17447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17448. return
  17449. }
  17450. res.ErrMsg = res10265.ErrMsg
  17451. res.Output = res10265.Output
  17452. res.InfRefmsgid = res10265.InfRefmsgid
  17453. } else {
  17454. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17455. utils.ErrorLog("解析失败:%v", err)
  17456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17457. return
  17458. }
  17459. }
  17460. PsnNo = res.Output.Baseinfo.PsnNo
  17461. PsnCertType = res.Output.Baseinfo.PsnCertType
  17462. Certno = res.Output.Baseinfo.Certno
  17463. PsnName = res.Output.Baseinfo.PsnName
  17464. Gend = res.Output.Baseinfo.Gend
  17465. Naty = res.Output.Baseinfo.Naty
  17466. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17467. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17468. infoStr = string(Iinfos)
  17469. idetinfoStr = string(Idetinfos)
  17470. if miConfig.Code == "H15049901371" {
  17471. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17472. } else {
  17473. infocode = res.Infcode
  17474. }
  17475. }
  17476. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17477. psn_info, _ := service.GetPsnByPatientId(id)
  17478. PsnNo = psn_info.PsnNo
  17479. PsnCertType = psn_info.PsnCertType
  17480. Certno = psn_info.Certno
  17481. PsnName = psn_info.PsnName
  17482. Gend = psn_info.Gend
  17483. Naty = psn_info.Naty
  17484. Brdy = psn_info.Brdy
  17485. Age = psn_info.Age
  17486. infoStr = psn_info.Insuinfo
  17487. idetinfoStr = psn_info.Idetinfo
  17488. infocode = 0
  17489. verify_number = psn_info.VerifyNumber
  17490. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17491. psn_info, _ := service.GetPsnByPatientId(id)
  17492. PsnNo = psn_info.PsnNo
  17493. PsnCertType = psn_info.PsnCertType
  17494. Certno = psn_info.Certno
  17495. PsnName = psn_info.PsnName
  17496. Gend = psn_info.Gend
  17497. Naty = psn_info.Naty
  17498. Brdy = psn_info.Brdy
  17499. Age = psn_info.Age
  17500. infoStr = psn_info.Insuinfo
  17501. idetinfoStr = psn_info.Idetinfo
  17502. infocode = 0
  17503. verify_number = psn_info.VerifyNumber
  17504. } else {
  17505. var result string
  17506. var requestLog string
  17507. //if miConfig.UserOrgId == 10138 {
  17508. if id_card_type != 4 || id_card_type != 1 {
  17509. var insa string
  17510. if len(patient.InsuplcAdmdvs) > 0 {
  17511. insa = patient.InsuplcAdmdvs
  17512. } else {
  17513. insa = miConfig.InsuplcAdmdvs
  17514. }
  17515. //psn_info, _ := service.GetPsnByPatientId(id)
  17516. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17517. 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)
  17518. }
  17519. //}
  17520. //else {
  17521. // var insa string
  17522. // if len(patient.InsuplcAdmdvs) > 0 {
  17523. // insa = patient.InsuplcAdmdvs
  17524. // } else {
  17525. // insa = miConfig.InsuplcAdmdvs
  17526. // }
  17527. // 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)
  17528. //}
  17529. if id_card_type == 4 || id_card_type == 1 {
  17530. psn_info, _ := service.GetPsnByPatientId(id)
  17531. PsnNo = psn_info.PsnNo
  17532. PsnCertType = psn_info.PsnCertType
  17533. Certno = psn_info.Certno
  17534. PsnName = psn_info.PsnName
  17535. Gend = psn_info.Gend
  17536. Naty = psn_info.Naty
  17537. Brdy = psn_info.Brdy
  17538. Age = psn_info.Age
  17539. infoStr = psn_info.Insuinfo
  17540. idetinfoStr = psn_info.Idetinfo
  17541. infocode = 0
  17542. verify_number = psn_info.VerifyNumber
  17543. } else {
  17544. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17545. if miConfig.Code == "H15049901371" {
  17546. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17547. utils.ErrorLog("解析失败:%v", err)
  17548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17549. return
  17550. }
  17551. res.ErrMsg = res10265.ErrMsg
  17552. res.Output = res10265.Output
  17553. res.InfRefmsgid = res10265.InfRefmsgid
  17554. } else {
  17555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17556. utils.ErrorLog("解析失败:%v", err)
  17557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17558. return
  17559. }
  17560. }
  17561. PsnNo = res.Output.Baseinfo.PsnNo
  17562. PsnCertType = res.Output.Baseinfo.PsnCertType
  17563. Certno = res.Output.Baseinfo.Certno
  17564. PsnName = res.Output.Baseinfo.PsnName
  17565. Gend = res.Output.Baseinfo.Gend
  17566. Naty = res.Output.Baseinfo.Naty
  17567. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17568. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17569. infoStr = string(Iinfos)
  17570. idetinfoStr = string(Idetinfos)
  17571. if miConfig.Code == "H15049901371" {
  17572. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17573. } else {
  17574. infocode = res.Infcode
  17575. }
  17576. }
  17577. }
  17578. if infocode == 0 {
  17579. his := models.VMHisPatient{
  17580. Name: name,
  17581. Gender: gender,
  17582. Birthday: birthUnix,
  17583. MedicalTreatmentType: medical_care,
  17584. IdType: certificates,
  17585. IdCardNo: id_card,
  17586. BalanceAccountsType: settlementValue,
  17587. SocialType: social_type,
  17588. MedicalInsuranceNumber: medical_insurance_card,
  17589. RegisterType: register_type,
  17590. RegisterCost: registration_fee,
  17591. TreatmentCost: medical_expenses,
  17592. Status: 1,
  17593. Ctime: time.Now().Unix(),
  17594. Mtime: time.Now().Unix(),
  17595. PsnNo: PsnNo,
  17596. PsnCertType: PsnCertType,
  17597. Certno: Certno,
  17598. PsnName: PsnName,
  17599. Gend: Gend,
  17600. Naty: Naty,
  17601. Brdy: Brdy,
  17602. Age: Age,
  17603. Iinfo: infoStr,
  17604. Idetinfo: idetinfoStr,
  17605. PatientId: patient.ID,
  17606. RecordDate: theTime.Unix(),
  17607. UserOrgId: adminInfo.CurrentOrgId,
  17608. AdminUserId: admin_user_id,
  17609. IsReturn: 1,
  17610. IdCardType: id_card_type,
  17611. Doctor: doctor,
  17612. Departments: department,
  17613. MdtrtGrpType: mdtrt_type,
  17614. }
  17615. timestamp := time.Now().Unix()
  17616. tempTime := time.Unix(timestamp, 0)
  17617. timeFormat := tempTime.Format("20060102150405")
  17618. chrgBchno := rand.Intn(100000) + 10000
  17619. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17620. his.Number = ipt_otp_no
  17621. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17622. department, _ := service.GetDepartMentDetail(department)
  17623. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17624. IdCardNo := ""
  17625. if id_card_type == 1 {
  17626. // IdCardNo = medical_insurance_card
  17627. IdCardNo = patient.IdCardNo
  17628. } else {
  17629. IdCardNo = patient.IdCardNo
  17630. }
  17631. var rf []*ResultFive
  17632. json.Unmarshal([]byte(his.Iinfo), &rf)
  17633. var insutypes []*ResultFive
  17634. var insutype string
  17635. var insuplc_admdvs_temp string
  17636. var is390 int = 0
  17637. var is310 int = 0
  17638. for _, item := range rf {
  17639. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17640. insutypes = append(insutypes, item)
  17641. }
  17642. }
  17643. if len(insutypes) == 1 {
  17644. insutype = insutypes[0].Insutype
  17645. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17646. if insutype == "390" {
  17647. is390 = 1
  17648. }
  17649. if insutype == "310" {
  17650. is310 = 1
  17651. }
  17652. } else {
  17653. for _, i := range insutypes {
  17654. if i.Insutype == "390" {
  17655. is390 = 1
  17656. }
  17657. if i.Insutype == "310" {
  17658. is310 = 1
  17659. }
  17660. }
  17661. }
  17662. if is390 == 1 {
  17663. insutype = "390"
  17664. }
  17665. if is310 == 1 {
  17666. insutype = "310"
  17667. }
  17668. fmt.Println(social_type)
  17669. if social_type > 0 {
  17670. insutype = strconv.FormatInt(social_type, 10)
  17671. }
  17672. var infocode int64
  17673. var resThree ResultThree
  17674. var resThree10265 ResultThree10265
  17675. if len(insuplc_admdvs) == 0 {
  17676. psn_info, _ := service.GetPsnByPatientId(id)
  17677. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17678. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17679. //}
  17680. } else {
  17681. insuplc_admdvs_temp = insuplc_admdvs
  17682. }
  17683. if miConfig.MdtrtareaAdmvs == "421300" {
  17684. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17685. psn_info, _ := service.GetPsnByPatientId(id)
  17686. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17687. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17688. "&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
  17689. resp, requestErr := http.Get(api)
  17690. if requestErr != nil {
  17691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17692. return
  17693. }
  17694. body, ioErr := ioutil.ReadAll(resp.Body)
  17695. if ioErr != nil {
  17696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17698. return
  17699. }
  17700. var respJSON map[string]interface{}
  17701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17704. return
  17705. }
  17706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17707. result, _ := json.Marshal(respJSON)
  17708. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17709. utils.ErrorLog("解析失败:%v", err)
  17710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17711. return
  17712. }
  17713. infocode = resThree.Infcode
  17714. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17715. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17716. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17717. // insuplc_admdvs_temp =
  17718. //}
  17719. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17720. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17721. //}
  17722. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17723. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17724. "&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
  17725. resp, requestErr := http.Get(api)
  17726. if requestErr != nil {
  17727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17728. return
  17729. }
  17730. body, ioErr := ioutil.ReadAll(resp.Body)
  17731. if ioErr != nil {
  17732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17734. return
  17735. }
  17736. var respJSON map[string]interface{}
  17737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17740. return
  17741. }
  17742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17743. result, _ := json.Marshal(respJSON)
  17744. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17745. utils.ErrorLog("解析失败:%v", err)
  17746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17747. return
  17748. }
  17749. infocode = resThree.Infcode
  17750. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17751. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17752. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17753. // insuplc_admdvs_temp =
  17754. //}
  17755. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17756. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17757. //}
  17758. utils.ErrorLog("解析失败:%v", insutype)
  17759. utils.ErrorLog("解析失败:%v", PsnNo)
  17760. utils.ErrorLog("解析失败:%v", Certno)
  17761. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17762. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17763. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17764. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17765. utils.ErrorLog("解析失败:%v", PsnNo)
  17766. utils.ErrorLog("解析失败:%v", department.Number)
  17767. utils.ErrorLog("解析失败:%v", department.Name)
  17768. utils.ErrorLog("解析失败:%v", roles.UserName)
  17769. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17770. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17771. "&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
  17772. resp, requestErr := http.Get(api)
  17773. if requestErr != nil {
  17774. utils.ErrorLog("解析失败:%v", requestErr)
  17775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17776. return
  17777. }
  17778. body, ioErr := ioutil.ReadAll(resp.Body)
  17779. if ioErr != nil {
  17780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17782. return
  17783. }
  17784. var respJSON map[string]interface{}
  17785. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17788. return
  17789. }
  17790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17791. result, _ := json.Marshal(respJSON)
  17792. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17793. utils.ErrorLog("解析失败:%v", err)
  17794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17795. return
  17796. }
  17797. infocode = resThree.Infcode
  17798. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17799. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17800. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17801. // insuplc_admdvs_temp =
  17802. //}
  17803. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17804. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17805. //}
  17806. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17807. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17808. "&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
  17809. resp, requestErr := http.Get(api)
  17810. if requestErr != nil {
  17811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17812. return
  17813. }
  17814. body, ioErr := ioutil.ReadAll(resp.Body)
  17815. if ioErr != nil {
  17816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17818. return
  17819. }
  17820. var respJSON map[string]interface{}
  17821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17824. return
  17825. }
  17826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17827. result, _ := json.Marshal(respJSON)
  17828. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17829. utils.ErrorLog("解析失败:%v", err)
  17830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17831. return
  17832. }
  17833. infocode = resThree.Infcode
  17834. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17835. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17836. psn_info, _ := service.GetPsnByPatientId(id)
  17837. var verify_number string
  17838. if id_card_type == 4 {
  17839. verify_number = psn_info.VerifyNumber
  17840. } else if id_card_type == 1 {
  17841. bas := strings.Split(psn_info.CardInfo, "|")
  17842. cardNumber := bas[2]
  17843. verify_number = cardNumber
  17844. }
  17845. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17846. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17847. "&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
  17848. resp, requestErr := http.Get(api)
  17849. if requestErr != nil {
  17850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17851. return
  17852. }
  17853. body, ioErr := ioutil.ReadAll(resp.Body)
  17854. if ioErr != nil {
  17855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17857. return
  17858. }
  17859. var respJSON map[string]interface{}
  17860. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17863. return
  17864. }
  17865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17866. result, _ := json.Marshal(respJSON)
  17867. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17868. // utils.ErrorLog("解析失败:%v", err)
  17869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17870. // return
  17871. //}
  17872. //infocode = resThree.Infcode
  17873. //result, _ := json.Marshal(respJSON)
  17874. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17875. utils.ErrorLog("解析失败:%v", err)
  17876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17877. return
  17878. }
  17879. resThree.ErrMsg = resThree10265.ErrMsg
  17880. resThree.Output = resThree10265.Output
  17881. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17882. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17883. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17884. psn_info, _ := service.GetPsnByPatientId(id)
  17885. his.PsnNo = psn_info.PsnNo
  17886. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17887. var cert_no string
  17888. if id_card_type == 3 {
  17889. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17890. cert_no = IdCardNo
  17891. } else if id_card_type == 4 {
  17892. cert_no = IdCardNo
  17893. psn_info.VerifyNumber = psn_info.VerifyNumber
  17894. } else {
  17895. bas := strings.Split(psn_info.CardInfo, "|")
  17896. cert_no = bas[2]
  17897. }
  17898. var hisPrescription []*models.HisPrescription
  17899. for _, item := range rf {
  17900. if item.Insutype == insutype {
  17901. //insuplc_admdvs = item.InsuplcAdmdvs
  17902. his.InsuplcAdmdvs = insuplc_admdvs
  17903. }
  17904. }
  17905. his.Insutype = insutype
  17906. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17907. fmt.Println(res3101)
  17908. fmt.Println(res3101.Infcode)
  17909. if res3101.Infcode == "0" {
  17910. fmt.Println("33333333")
  17911. if len(res3101.Output.Result) > 0 {
  17912. fmt.Println("222222")
  17913. for _, item := range res3101.Output.Result {
  17914. if len(res3101.ErrMsg) == 0 {
  17915. res3101.ErrMsg = item.VolaCont
  17916. } else {
  17917. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17918. }
  17919. }
  17920. c.ServeSuccessJSON(map[string]interface{}{
  17921. "failed_code": -10,
  17922. "msg": res3101.ErrMsg,
  17923. })
  17924. return
  17925. } else {
  17926. fmt.Println("11111")
  17927. var api string
  17928. if miConfig.MdtrtareaAdmvs == "320921" {
  17929. ipt_otp_no = timeFormat
  17930. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17931. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17932. "&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
  17933. } else {
  17934. ipt_otp_no = timeFormat
  17935. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17936. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17937. "&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
  17938. }
  17939. resp, requestErr := http.Get(api)
  17940. if requestErr != nil {
  17941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17942. return
  17943. }
  17944. body, ioErr := ioutil.ReadAll(resp.Body)
  17945. if ioErr != nil {
  17946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17948. return
  17949. }
  17950. var respJSON map[string]interface{}
  17951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17954. return
  17955. }
  17956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17957. result, _ := json.Marshal(respJSON)
  17958. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17959. utils.ErrorLog("解析失败:%v", err)
  17960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17961. return
  17962. }
  17963. resThree.ErrMsg = resThree10265.ErrMsg
  17964. resThree.Output = resThree10265.Output
  17965. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17966. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17967. }
  17968. } else if res3101.Infcode != "0" {
  17969. c.ServeSuccessJSON(map[string]interface{}{
  17970. "failed_code": -10,
  17971. "msg": res3101.ErrMsg,
  17972. })
  17973. return
  17974. }
  17975. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17976. psn_info, _ := service.GetPsnByPatientId(id)
  17977. var cert_no string
  17978. if id_card_type == 1 {
  17979. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17980. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17981. } else if id_card_type == 4 {
  17982. cert_no = psn_info.VerifyNumber
  17983. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17984. } else {
  17985. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17986. cert_no = psn_info.VerifyNumber
  17987. }
  17988. 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)
  17989. saveLog(result, requestLog, "2201", "挂号")
  17990. if miConfig.Code == "H15049901371" {
  17991. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17992. utils.ErrorLog("解析失败:%v", err)
  17993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17994. return
  17995. }
  17996. resThree.ErrMsg = resThree10265.ErrMsg
  17997. resThree.Output = resThree10265.Output
  17998. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17999. } else {
  18000. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18001. utils.ErrorLog("解析失败:%v", err)
  18002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18003. return
  18004. }
  18005. }
  18006. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18007. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  18008. psn_info, _ := service.GetPsnByPatientId(id)
  18009. var result string
  18010. var requestLog string
  18011. if id_card_type == 1 {
  18012. bas := strings.Split(psn_info.CardInfo, "|")
  18013. basNumber := bas[2]
  18014. card_sn := bas[3]
  18015. 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)
  18016. saveLog(result, requestLog, "2201A", "挂号")
  18017. } else if id_card_type == 2 {
  18018. 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, "", "", "", "", "", "")
  18019. saveLog(result, requestLog, "2201A", "挂号")
  18020. } else {
  18021. 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, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  18022. saveLog(result, requestLog, "2201A", "挂号")
  18023. }
  18024. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18025. utils.ErrorLog("解析失败:%v", err)
  18026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18027. return
  18028. }
  18029. infocode = resThree.Infcode
  18030. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18031. psn_info, _ := service.GetPsnByPatientId(id)
  18032. his.PsnNo = psn_info.PsnNo
  18033. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18034. var cert_no string
  18035. if id_card_type == 1 {
  18036. bas := strings.Split(psn_info.CardInfo, "|")
  18037. cert_no = bas[2]
  18038. } else if id_card_type == 4 {
  18039. cert_no = IdCardNo
  18040. psn_info.VerifyNumber = psn_info.VerifyNumber
  18041. } else {
  18042. cert_no = IdCardNo
  18043. psn_info.VerifyNumber = cert_no
  18044. }
  18045. for _, item := range rf {
  18046. if item.Insutype == insutype {
  18047. his.InsuplcAdmdvs = insuplc_admdvs
  18048. }
  18049. }
  18050. his.Insutype = insutype
  18051. var api string
  18052. ipt_otp_no = timeFormat
  18053. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18054. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18055. "&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
  18056. resp, requestErr := http.Get(api)
  18057. if requestErr != nil {
  18058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18059. return
  18060. }
  18061. body, ioErr := ioutil.ReadAll(resp.Body)
  18062. if ioErr != nil {
  18063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18065. return
  18066. }
  18067. var respJSON map[string]interface{}
  18068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18071. return
  18072. }
  18073. status := respJSON["data"].(map[string]interface{})["status"].(string)
  18074. if status == "0" {
  18075. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  18076. c.ServeSuccessJSON(map[string]interface{}{
  18077. "failed_code": -10,
  18078. "msg": err_msg,
  18079. })
  18080. return
  18081. }
  18082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18083. result, _ := json.Marshal(respJSON)
  18084. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18085. utils.ErrorLog("解析失败:%v", err)
  18086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18087. return
  18088. }
  18089. infocode = resThree.Infcode
  18090. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18091. psn_info, _ := service.GetPsnByPatientId(id)
  18092. var result string
  18093. var requestLog string
  18094. if id_card_type == 1 {
  18095. bas := strings.Split(psn_info.CardInfo, "|")
  18096. basNumber := bas[2]
  18097. card_sn := bas[3]
  18098. 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)
  18099. saveLog(result, requestLog, "2201A", "挂号")
  18100. } else if id_card_type == 2 {
  18101. 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, "", "")
  18102. saveLog(result, requestLog, "2201A", "挂号")
  18103. } else {
  18104. 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, "", "")
  18105. saveLog(result, requestLog, "2201A", "挂号")
  18106. }
  18107. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18108. utils.ErrorLog("解析失败:%v", err)
  18109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18110. return
  18111. }
  18112. infocode = resThree.Infcode
  18113. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18114. psn_info, _ := service.GetPsnByPatientId(id)
  18115. 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)
  18116. saveLog(result, requestLog, "2201A", "挂号")
  18117. if miConfig.Code == "H15049901371" {
  18118. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18119. utils.ErrorLog("解析失败:%v", err)
  18120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18121. return
  18122. }
  18123. resThree.ErrMsg = resThree10265.ErrMsg
  18124. resThree.Output = resThree10265.Output
  18125. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18126. } else {
  18127. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18128. utils.ErrorLog("解析失败:%v", err)
  18129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18130. return
  18131. }
  18132. }
  18133. if miConfig.Code == "H15049901371" {
  18134. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18135. } else {
  18136. infocode = resThree.Infcode
  18137. }
  18138. } else {
  18139. psn_info, _ := service.GetPsnByPatientId(id)
  18140. if id_card_type == 4 || id_card_type == 1 {
  18141. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18142. }
  18143. var rf []*ResultFive
  18144. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  18145. var insutypes []*ResultFive
  18146. var insutype string
  18147. var is390 int = 0
  18148. var is310 int = 0
  18149. for _, item := range rf {
  18150. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18151. insutypes = append(insutypes, item)
  18152. }
  18153. }
  18154. if len(insutypes) == 1 {
  18155. insutype = insutypes[0].Insutype
  18156. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18157. } else {
  18158. for _, i := range insutypes {
  18159. if i.Insutype == "390" {
  18160. is390 = 1
  18161. }
  18162. if i.Insutype == "310" {
  18163. is310 = 1
  18164. }
  18165. }
  18166. }
  18167. if is390 == 1 {
  18168. insutype = "390"
  18169. }
  18170. if is310 == 1 {
  18171. insutype = "310"
  18172. }
  18173. fmt.Println(len(insutypes))
  18174. if len(insutypes) == 0 {
  18175. for index, item := range rf {
  18176. if index == 0 {
  18177. insutype = item.Insutype
  18178. insuplc_admdvs = item.InsuplcAdmdvs
  18179. }
  18180. }
  18181. fmt.Println(insutype)
  18182. fmt.Println(insuplc_admdvs)
  18183. }
  18184. if social_type > 0 {
  18185. insutype = strconv.FormatInt(social_type, 10)
  18186. }
  18187. fmt.Println("--------")
  18188. fmt.Println(psn_info)
  18189. fmt.Println(psn_info.PsnNo)
  18190. if miConfig.MdtrtareaAdmvs == "441202" {
  18191. var hisPrescription []*models.HisPrescription
  18192. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18193. if res3101.Infcode == 0 {
  18194. fmt.Println("33333333")
  18195. if len(res3101.Output.Result) > 0 {
  18196. fmt.Println("222222")
  18197. for _, item := range res3101.Output.Result {
  18198. if len(res3101.ErrMsg) == 0 {
  18199. res3101.ErrMsg = item.VolaCont
  18200. } else {
  18201. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18202. }
  18203. }
  18204. c.ServeSuccessJSON(map[string]interface{}{
  18205. "failed_code": -10,
  18206. "msg": res3101.ErrMsg,
  18207. })
  18208. return
  18209. } else {
  18210. hour := time.Now().Format("15")
  18211. min := time.Now().Format("04")
  18212. sec := time.Now().Format("05")
  18213. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18214. fmt.Println(record_time_two)
  18215. 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)
  18216. saveLog(result, requestLog, "2201A", "挂号")
  18217. if miConfig.Code == "H15049901371" {
  18218. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18219. utils.ErrorLog("解析失败:%v", err)
  18220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18221. return
  18222. }
  18223. resThree.ErrMsg = resThree10265.ErrMsg
  18224. resThree.Output = resThree10265.Output
  18225. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18226. } else {
  18227. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18228. utils.ErrorLog("解析失败:%v", err)
  18229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18230. return
  18231. }
  18232. }
  18233. if miConfig.Code == "H15049901371" {
  18234. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18235. } else {
  18236. infocode = resThree.Infcode
  18237. }
  18238. }
  18239. } else if res3101.Infcode != 0 {
  18240. c.ServeSuccessJSON(map[string]interface{}{
  18241. "failed_code": -10,
  18242. "msg": res3101.ErrMsg,
  18243. })
  18244. return
  18245. }
  18246. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18247. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18248. psn_info, _ := service.GetPsnByPatientId(id)
  18249. var verify_number string
  18250. if id_card_type == 4 {
  18251. verify_number = psn_info.VerifyNumber
  18252. } else if id_card_type == 1 {
  18253. bas := strings.Split(psn_info.CardInfo, "|")
  18254. cardNumber := bas[2]
  18255. verify_number = cardNumber
  18256. } else {
  18257. verify_number = psn_info.Certno
  18258. }
  18259. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18260. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18261. "&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
  18262. resp, requestErr := http.Get(api)
  18263. if requestErr != nil {
  18264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18265. return
  18266. }
  18267. body, ioErr := ioutil.ReadAll(resp.Body)
  18268. if ioErr != nil {
  18269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18271. return
  18272. }
  18273. var respJSON map[string]interface{}
  18274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18277. return
  18278. }
  18279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18280. result, _ := json.Marshal(respJSON)
  18281. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18282. utils.ErrorLog("解析失败:%v", err)
  18283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18284. return
  18285. }
  18286. infocode = resThree.Infcode
  18287. } else {
  18288. hour := time.Now().Format("15")
  18289. min := time.Now().Format("04")
  18290. sec := time.Now().Format("05")
  18291. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18292. if id_card_type == 1 {
  18293. for _, item := range rf {
  18294. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18295. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18296. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18297. } else if strconv.FormatInt(social_type, 10) == "390" {
  18298. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18299. } else {
  18300. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18301. }
  18302. }
  18303. }
  18304. }
  18305. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18306. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18307. }
  18308. if id_card_type == 1 {
  18309. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18310. bas := strings.Split(psn_info.CardInfo, "|")
  18311. basNumber := bas[1]
  18312. IdCardNo = basNumber
  18313. }
  18314. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18315. IdCardNo = psn_info.VerifyNumber
  18316. }
  18317. 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)
  18318. saveLog(result, requestLog, "2201A", "挂号")
  18319. if miConfig.Code == "H15049901371" {
  18320. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18321. utils.ErrorLog("解析失败:%v", err)
  18322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18323. return
  18324. }
  18325. resThree.ErrMsg = resThree10265.ErrMsg
  18326. resThree.Output = resThree10265.Output
  18327. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18328. } else {
  18329. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18330. utils.ErrorLog("解析失败:%v", err)
  18331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18332. return
  18333. }
  18334. }
  18335. if miConfig.Code == "H15049901371" {
  18336. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18337. } else {
  18338. infocode = resThree.Infcode
  18339. }
  18340. }
  18341. }
  18342. if infocode != 0 {
  18343. adminUser := c.GetAdminUserInfo()
  18344. errlog := &models.HisOrderError{
  18345. UserOrgId: adminUser.CurrentOrgId,
  18346. Ctime: time.Now().Unix(),
  18347. Mtime: time.Now().Unix(),
  18348. ErrMsg: resThree.ErrMsg,
  18349. Status: 1,
  18350. PatientId: id,
  18351. RecordTime: recordDateTime,
  18352. Stage: 2,
  18353. }
  18354. service.CreateErrMsgLog(errlog)
  18355. c.ServeSuccessJSON(map[string]interface{}{
  18356. "failed_code": -10,
  18357. "msg": resThree.ErrMsg,
  18358. })
  18359. return
  18360. }
  18361. his.Number = resThree.Output.Data.MdtrtID
  18362. his.PsnNo = resThree.Output.Data.PsnNo
  18363. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18364. his.IdCardNo = patient.IdCardNo
  18365. his.PhoneNumber = patient.Phone
  18366. his.UserOrgId = adminInfo.CurrentOrgId
  18367. his.Insutype = insutype
  18368. his.Ctime = time.Now().Unix()
  18369. his.Mtime = time.Now().Unix()
  18370. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18371. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18372. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18373. }
  18374. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18375. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18376. }
  18377. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18378. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18379. }
  18380. his.Status = 1
  18381. his.MdtrtGrpType = mdtrt_type
  18382. service.UpdateHisPatientStatus(&his)
  18383. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18384. c.ServeSuccessJSON(map[string]interface{}{
  18385. "his_info": his,
  18386. })
  18387. } else {
  18388. adminUser := c.GetAdminUserInfo()
  18389. errlog := &models.HisOrderError{
  18390. UserOrgId: adminUser.CurrentOrgId,
  18391. Ctime: time.Now().Unix(),
  18392. Mtime: time.Now().Unix(),
  18393. ErrMsg: res.ErrMsg,
  18394. Status: 1,
  18395. PatientId: id,
  18396. RecordTime: recordDateTime,
  18397. Stage: 1,
  18398. }
  18399. service.CreateErrMsgLog(errlog)
  18400. c.ServeSuccessJSON(map[string]interface{}{
  18401. "failed_code": -10,
  18402. "msg": res.ErrMsg,
  18403. })
  18404. return
  18405. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18406. }
  18407. }
  18408. }
  18409. func (c *HisApiController) GetUploadInfo() {
  18410. id, _ := c.GetInt64("id")
  18411. record_time := c.GetString("record_time")
  18412. his_patient_id, _ := c.GetInt64("his_patient_id")
  18413. order_id, _ := c.GetInt64("order_id")
  18414. pay_way, _ := c.GetInt64("pay_way")
  18415. pay_ways := c.GetString("pay_ways")
  18416. oth_desc := c.GetString("oth_desc")
  18417. pay_price, _ := c.GetFloat("pay_price")
  18418. pay_card_no := c.GetString("pay_card_no")
  18419. discount_price, _ := c.GetFloat("discount_price")
  18420. preferential_price, _ := c.GetFloat("preferential_price")
  18421. reality_price, _ := c.GetFloat("reality_price")
  18422. found_price, _ := c.GetFloat("found_price")
  18423. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18424. private_price, _ := c.GetFloat("private_price")
  18425. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18426. admin_user_id, _ := c.GetInt64("admin_user_id")
  18427. fapiao_code := c.GetString("fapiao_code")
  18428. fapiao_number := c.GetString("fapiao_number")
  18429. diagnosis_id := c.GetString("diagnosis")
  18430. sick_type, _ := c.GetInt64("sick_type")
  18431. reg_type, _ := c.GetInt64("p_type")
  18432. begin_time := c.GetString("begin_time")
  18433. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18434. cash_pay := c.GetString("cash_pay")
  18435. band_card_pay := c.GetString("band_card_pay")
  18436. wechat_pay := c.GetString("wechat_pay")
  18437. ali_pay := c.GetString("ali_pay")
  18438. jifen_pay := c.GetString("jifen_pay")
  18439. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18440. fmt.Println(acct_used_flag)
  18441. id_str := c.GetString("ids")
  18442. ids_arr := strings.Split(id_str, ",")
  18443. timeLayout := "2006-01-02"
  18444. loc, _ := time.LoadLocation("Local")
  18445. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18446. if err != nil {
  18447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18448. return
  18449. }
  18450. recordDateTime := theTime.Unix()
  18451. adminUser := c.GetAdminUserInfo()
  18452. var tempOrder models.HisOrder
  18453. tempOrder, _ = service.GetHisOrderByID(order_id)
  18454. var prescriptions []*models.HisPrescription
  18455. var start_time int64
  18456. var end_time int64
  18457. //押金模块
  18458. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18459. tmp_decimal := c.GetString("tmp_decimal")
  18460. var decimal float64 //本次使用的押金
  18461. var errmsg error
  18462. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18463. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18464. return
  18465. }
  18466. if len(tmp_decimal) > 0 {
  18467. if tmp_decimal[0] == 45 {
  18468. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18469. return
  18470. }
  18471. }
  18472. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18473. fmt.Println(errs)
  18474. decimal = tt
  18475. //if adminUser.CurrentOrgId == 10106{
  18476. // if len(fapiao_code) == 0{
  18477. // fapiao_code = "144072080589"
  18478. // }
  18479. // if len(fapiao_number) == 0{
  18480. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18481. // if order.ID == 0{
  18482. // fapiao_number = "00001520"
  18483. // }else{
  18484. // //fapiao_code = "00001520"
  18485. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18486. // var zero string
  18487. // if fpNumber >= 1000{
  18488. // zero = "0000" + strconv.Itoa(fpNumber)
  18489. // }else if fpNumber >= 10000{
  18490. // zero = "000" + strconv.Itoa(fpNumber)
  18491. // } else if fpNumber >= 100000{
  18492. // zero = "00" + strconv.Itoa(fpNumber)
  18493. // } else if fpNumber >= 1000000{
  18494. // zero = "0" + strconv.Itoa(fpNumber)
  18495. // }else {
  18496. // zero = strconv.Itoa(fpNumber)
  18497. // }
  18498. // fapiao_number = zero
  18499. // }
  18500. // }
  18501. //}
  18502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18503. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18504. var patientPrescription models.HisPrescriptionInfo
  18505. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18506. if patientPrescription.ID == 0 {
  18507. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18508. }
  18509. //if patientPrescription.Do
  18510. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18511. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18512. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18513. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18514. var config []*models.HisXtDiagnoseConfig
  18515. for _, item := range diagnosis_ids {
  18516. id, _ := strconv.ParseInt(item, 10, 64)
  18517. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18518. config = append(config, &diagnosisConfig)
  18519. }
  18520. sickConfig, _ := service.FindSickById(sick_type)
  18521. //if tempOrder.ID == 0 {
  18522. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18523. //}
  18524. if tempOrder.ID == 0 {
  18525. var result string
  18526. var requestLog string
  18527. var res2 ResultSix
  18528. var res3 GZResultSix
  18529. var ressix10265 ResultSix10265
  18530. if miConfig.MdtrtareaAdmvs == "421300" {
  18531. data := make(map[string]interface{})
  18532. client := &http.Client{}
  18533. data["psn_no"] = his.PsnNo
  18534. data["mdtrt_id"] = his.Number
  18535. data["opter"] = roles.UserName
  18536. data["org_name"] = miConfig.OrgName
  18537. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18538. data["doctor_id"] = doctor_info.DoctorNumber
  18539. data["doctor_name"] = doctor_info.UserName
  18540. data["department"] = department.Name
  18541. data["fixmedins_code"] = miConfig.Code
  18542. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18543. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18544. data["secret_key"] = miConfig.SecretKey
  18545. data["sick_code"] = sickConfig.CountryCode
  18546. data["sick_name"] = sickConfig.ClassName
  18547. data["dept"] = strconv.FormatInt(department.ID, 10)
  18548. data["config"] = config
  18549. data["begin_time"] = begin_time
  18550. bytesData, _ := json.Marshal(data)
  18551. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18552. resp, _ := client.Do(req)
  18553. defer resp.Body.Close()
  18554. body, ioErr := ioutil.ReadAll(resp.Body)
  18555. if ioErr != nil {
  18556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18558. return
  18559. }
  18560. var respJSON map[string]interface{}
  18561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18564. return
  18565. }
  18566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18567. userJSONBytes, _ := json.Marshal(respJSON)
  18568. fmt.Println("log")
  18569. fmt.Println(string(userJSONBytes))
  18570. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18571. utils.ErrorLog("解析失败:%v", err)
  18572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18573. return
  18574. }
  18575. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18576. data := make(map[string]interface{})
  18577. client := &http.Client{}
  18578. data["psn_no"] = his.PsnNo
  18579. data["mdtrt_id"] = his.Number
  18580. data["opter"] = roles.UserName
  18581. data["org_name"] = miConfig.OrgName
  18582. if reg_type == 11 && his.Insutype == "390" {
  18583. data["med_type"] = "110104"
  18584. } else {
  18585. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18586. }
  18587. data["doctor_id"] = doctor_info.DoctorNumber
  18588. data["doctor_name"] = doctor_info.UserName
  18589. data["department"] = department.Name
  18590. data["fixmedins_code"] = miConfig.Code
  18591. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18592. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18593. data["secret_key"] = miConfig.SecretKey
  18594. data["sick_code"] = sickConfig.CountryCode
  18595. data["sick_name"] = sickConfig.ClassName
  18596. data["dept"] = strconv.FormatInt(department.ID, 10)
  18597. data["config"] = config
  18598. data["begin_time"] = begin_time
  18599. bytesData, _ := json.Marshal(data)
  18600. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18601. resp, _ := client.Do(req)
  18602. defer resp.Body.Close()
  18603. body, ioErr := ioutil.ReadAll(resp.Body)
  18604. if ioErr != nil {
  18605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18607. return
  18608. }
  18609. var respJSON map[string]interface{}
  18610. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18613. return
  18614. }
  18615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18616. userJSONBytes, _ := json.Marshal(respJSON)
  18617. fmt.Println("log")
  18618. fmt.Println(string(userJSONBytes))
  18619. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18620. utils.ErrorLog("解析失败:%v", err)
  18621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18622. return
  18623. }
  18624. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18625. data := make(map[string]interface{})
  18626. client := &http.Client{}
  18627. data["psn_no"] = his.PsnNo
  18628. data["mdtrt_id"] = his.Number
  18629. data["opter"] = roles.UserName
  18630. data["org_name"] = miConfig.OrgName
  18631. if reg_type == 11 && his.Insutype == "390" {
  18632. data["med_type"] = "110104"
  18633. } else {
  18634. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18635. }
  18636. data["doctor_id"] = doctor_info.DoctorNumber
  18637. data["doctor_name"] = doctor_info.UserName
  18638. data["department"] = department.Name
  18639. data["fixmedins_code"] = miConfig.Code
  18640. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18641. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18642. data["secret_key"] = miConfig.SecretKey
  18643. data["sick_code"] = sickConfig.CountryCode
  18644. data["sick_name"] = sickConfig.ClassName
  18645. data["dept"] = strconv.FormatInt(department.ID, 10)
  18646. data["config"] = config
  18647. data["begin_time"] = begin_time
  18648. bytesData, _ := json.Marshal(data)
  18649. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18650. resp, _ := client.Do(req)
  18651. defer resp.Body.Close()
  18652. body, ioErr := ioutil.ReadAll(resp.Body)
  18653. if ioErr != nil {
  18654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18656. return
  18657. }
  18658. var respJSON map[string]interface{}
  18659. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18662. return
  18663. }
  18664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18665. userJSONBytes, _ := json.Marshal(respJSON)
  18666. fmt.Println("log")
  18667. fmt.Println(string(userJSONBytes))
  18668. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18669. utils.ErrorLog("解析失败:%v", err)
  18670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18671. return
  18672. }
  18673. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18674. data := make(map[string]interface{})
  18675. client := &http.Client{}
  18676. data["psn_no"] = his.PsnNo
  18677. data["mdtrt_id"] = his.Number
  18678. data["opter"] = roles.UserName
  18679. data["org_name"] = miConfig.OrgName
  18680. if reg_type == 11 && his.Insutype == "390" {
  18681. data["med_type"] = "110104"
  18682. } else {
  18683. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18684. }
  18685. data["doctor_id"] = doctor_info.DoctorNumber
  18686. data["doctor_name"] = doctor_info.UserName
  18687. data["department"] = department.Name
  18688. data["fixmedins_code"] = miConfig.Code
  18689. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18690. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18691. data["secret_key"] = miConfig.SecretKey
  18692. data["sick_code"] = sickConfig.CountryCode
  18693. data["sick_name"] = sickConfig.ClassName
  18694. data["dept"] = strconv.FormatInt(department.ID, 10)
  18695. data["config"] = config
  18696. data["begin_time"] = begin_time
  18697. bytesData, _ := json.Marshal(data)
  18698. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18699. resp, _ := client.Do(req)
  18700. defer resp.Body.Close()
  18701. body, ioErr := ioutil.ReadAll(resp.Body)
  18702. if ioErr != nil {
  18703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18705. return
  18706. }
  18707. var respJSON map[string]interface{}
  18708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18711. return
  18712. }
  18713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18714. userJSONBytes, _ := json.Marshal(respJSON)
  18715. fmt.Println("log")
  18716. fmt.Println(string(userJSONBytes))
  18717. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18718. utils.ErrorLog("解析失败:%v", err)
  18719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18720. return
  18721. }
  18722. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18723. data := make(map[string]interface{})
  18724. client := &http.Client{}
  18725. data["psn_no"] = his.PsnNo
  18726. data["mdtrt_id"] = his.Number
  18727. data["doctor"] = roles.UserName
  18728. data["department"] = department.Name
  18729. data["org_name"] = miConfig.OrgName
  18730. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18731. data["doctor_id"] = doctor_info.DoctorNumber
  18732. data["new_doctor_name"] = doctor_info.UserName
  18733. data["fixmedins_code"] = miConfig.Code
  18734. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18735. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18736. data["secret_key"] = miConfig.SecretKey
  18737. data["sick_code"] = sickConfig.CountryCode
  18738. data["sick_name"] = sickConfig.ClassName
  18739. data["url"] = miConfig.Url
  18740. data["ak"] = miConfig.AccessKey
  18741. data["begin_time"] = begin_time
  18742. data["cainfo"] = miConfig.Cainfo
  18743. data["dept"] = strconv.FormatInt(department.ID, 10)
  18744. data["config"] = config
  18745. bytesData, _ := json.Marshal(data)
  18746. var req *http.Request
  18747. if miConfig.MdtrtareaAdmvs == "320921" {
  18748. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18749. //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 +
  18750. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18751. } else {
  18752. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18753. }
  18754. resp, _ := client.Do(req)
  18755. defer resp.Body.Close()
  18756. body, ioErr := ioutil.ReadAll(resp.Body)
  18757. if ioErr != nil {
  18758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18760. return
  18761. }
  18762. var respJSON map[string]interface{}
  18763. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18766. return
  18767. }
  18768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18769. userJSONBytes, _ := json.Marshal(respJSON)
  18770. fmt.Println("log")
  18771. fmt.Println(string(userJSONBytes))
  18772. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18773. utils.ErrorLog("解析失败:%v", err)
  18774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18775. return
  18776. }
  18777. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18778. res2.Output = ressix10265.Output
  18779. res2.ErrMsg = ressix10265.ErrMsg
  18780. res2.Cainfo = ressix10265.Cainfo
  18781. res2.WarnMsg = ressix10265.WarnMsg
  18782. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18783. res2.Infcode = infocode
  18784. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18785. data := make(map[string]interface{})
  18786. client := &http.Client{}
  18787. data["psn_no"] = his.PsnNo
  18788. data["mdtrt_id"] = his.Number
  18789. data["doctor"] = roles.UserName
  18790. data["department"] = department.Name
  18791. data["org_name"] = miConfig.OrgName
  18792. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18793. data["doctor_id"] = doctor_info.DoctorNumber
  18794. data["new_doctor_name"] = doctor_info.UserName
  18795. data["fixmedins_code"] = miConfig.Code
  18796. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18797. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18798. data["secret_key"] = miConfig.SecretKey
  18799. data["sick_code"] = sickConfig.CountryCode
  18800. data["sick_name"] = sickConfig.ClassName
  18801. data["url"] = miConfig.Url
  18802. data["ak"] = miConfig.AccessKey
  18803. data["begin_time"] = begin_time
  18804. data["cainfo"] = miConfig.Cainfo
  18805. data["dept"] = strconv.FormatInt(department.ID, 10)
  18806. data["config"] = config
  18807. bytesData, _ := json.Marshal(data)
  18808. var req *http.Request
  18809. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18810. resp, _ := client.Do(req)
  18811. defer resp.Body.Close()
  18812. body, ioErr := ioutil.ReadAll(resp.Body)
  18813. if ioErr != nil {
  18814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18816. return
  18817. }
  18818. var respJSON map[string]interface{}
  18819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18822. return
  18823. }
  18824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18825. userJSONBytes, _ := json.Marshal(respJSON)
  18826. fmt.Println("log")
  18827. fmt.Println(string(userJSONBytes))
  18828. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18829. utils.ErrorLog("解析失败:%v", err)
  18830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18831. return
  18832. }
  18833. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18834. res2.Output = ressix10265.Output
  18835. res2.ErrMsg = ressix10265.ErrMsg
  18836. res2.Cainfo = ressix10265.Cainfo
  18837. res2.WarnMsg = ressix10265.WarnMsg
  18838. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18839. res2.Infcode = infocode
  18840. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18841. 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)
  18842. saveLog(result, requestLog, "2203", "上传就诊信息")
  18843. var respJSON2 map[string]interface{}
  18844. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18847. return
  18848. }
  18849. userJSONBytes2, _ := json.Marshal(respJSON2)
  18850. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18851. utils.ErrorLog("解析失败:%v", err)
  18852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18853. return
  18854. }
  18855. 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)
  18856. fmt.Println(result2)
  18857. fmt.Println(src_request)
  18858. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18859. data := make(map[string]interface{})
  18860. client := &http.Client{}
  18861. data["psn_no"] = his.PsnNo
  18862. data["mdtrt_id"] = his.Number
  18863. data["doctor"] = roles.UserName
  18864. data["department"] = department.Name
  18865. data["org_name"] = miConfig.OrgName
  18866. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18867. data["doctor_id"] = doctor_info.DoctorNumber
  18868. data["new_doctor_name"] = doctor_info.UserName
  18869. data["fixmedins_code"] = miConfig.Code
  18870. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18871. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18872. data["secret_key"] = miConfig.SecretKey
  18873. data["sick_code"] = sickConfig.CountryCode
  18874. data["sick_name"] = sickConfig.ClassName
  18875. data["url"] = miConfig.Url
  18876. data["ak"] = miConfig.AccessKey
  18877. data["begin_time"] = begin_time
  18878. data["cainfo"] = miConfig.Cainfo
  18879. data["dept"] = strconv.FormatInt(department.ID, 10)
  18880. data["config"] = config
  18881. bytesData, _ := json.Marshal(data)
  18882. var req *http.Request
  18883. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18884. resp, _ := client.Do(req)
  18885. defer resp.Body.Close()
  18886. body, ioErr := ioutil.ReadAll(resp.Body)
  18887. if ioErr != nil {
  18888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18890. return
  18891. }
  18892. var respJSON map[string]interface{}
  18893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18896. return
  18897. }
  18898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18899. userJSONBytes, _ := json.Marshal(respJSON)
  18900. fmt.Println("log")
  18901. fmt.Println(string(userJSONBytes))
  18902. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18903. utils.ErrorLog("解析失败:%v", err)
  18904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18905. return
  18906. }
  18907. } else {
  18908. if miConfig.MdtrtareaAdmvs == "440781" { //
  18909. 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)
  18910. } else {
  18911. if miConfig.Code == "H15049901371" {
  18912. //赤峰地区国家医保医疗类别
  18913. //职工透析:医疗类别选特殊情况门诊990502
  18914. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18915. var med_type string
  18916. if his.Insutype == "390" {
  18917. if reg_type == 14 {
  18918. med_type = "9933"
  18919. } else if reg_type == 11 {
  18920. med_type = "11"
  18921. }
  18922. } else if his.Insutype == "310" {
  18923. if reg_type == 14 {
  18924. med_type = "990502"
  18925. } else if reg_type == 11 {
  18926. med_type = "11"
  18927. }
  18928. }
  18929. 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)
  18930. } else {
  18931. 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)
  18932. }
  18933. }
  18934. saveLog(result, requestLog, "2203", "上传就诊信息")
  18935. var respJSON2 map[string]interface{}
  18936. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18939. return
  18940. }
  18941. userJSONBytes2, _ := json.Marshal(respJSON2)
  18942. if miConfig.Code == "H15049901371" {
  18943. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18944. utils.ErrorLog("解析失败:%v", err)
  18945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18946. return
  18947. }
  18948. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18949. res2.Output = ressix10265.Output
  18950. res2.ErrMsg = ressix10265.ErrMsg
  18951. res2.Cainfo = ressix10265.Cainfo
  18952. res2.WarnMsg = ressix10265.WarnMsg
  18953. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18954. res2.Infcode = infocode
  18955. } else {
  18956. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18957. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18958. utils.ErrorLog("解析失败:%v", err)
  18959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18960. return
  18961. }
  18962. res2.Infcode = res3.Infcode
  18963. } else {
  18964. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18965. utils.ErrorLog("解析失败:%v", err)
  18966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18967. return
  18968. }
  18969. }
  18970. }
  18971. }
  18972. if res2.Infcode != 0 {
  18973. adminUser := c.GetAdminUserInfo()
  18974. errlog := &models.HisOrderError{
  18975. UserOrgId: adminUser.CurrentOrgId,
  18976. Ctime: time.Now().Unix(),
  18977. Mtime: time.Now().Unix(),
  18978. ErrMsg: res2.ErrMsg,
  18979. Status: 1,
  18980. PatientId: id,
  18981. RecordTime: recordDateTime,
  18982. Stage: 3,
  18983. }
  18984. service.CreateErrMsgLog(errlog)
  18985. c.ServeSuccessJSON(map[string]interface{}{
  18986. "failed_code": -10,
  18987. "msg": res2.ErrMsg,
  18988. })
  18989. return
  18990. } else {
  18991. his.Diagnosis = diagnosis_id
  18992. his.SickType = sickConfig.ID
  18993. //var p_type int64
  18994. //if reg_type == 1111 || reg_type == 1112 {
  18995. // p_type = 11
  18996. //
  18997. //}
  18998. his.PType = fmt.Sprintf("%d", reg_type)
  18999. service.UpdateHisPatientThree(&his)
  19000. data := make(map[string]interface{})
  19001. if settle_accounts_type == 1 { //日结
  19002. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  19003. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  19004. } else {
  19005. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  19006. }
  19007. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  19008. data["pre"] = prescriptions
  19009. } else { //月结
  19010. start_time_str := c.GetString("start_time")
  19011. end_time_str := c.GetString("end_time")
  19012. timeLayout := "2006-01-02"
  19013. loc, _ := time.LoadLocation("Local")
  19014. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  19015. if err != nil {
  19016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19017. return
  19018. }
  19019. recordStartTime := theStartTime.Unix()
  19020. start_time = recordStartTime
  19021. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  19022. if err != nil {
  19023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19024. return
  19025. }
  19026. recordEndTime := theEndTime.Unix()
  19027. end_time = recordEndTime
  19028. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  19029. data["pre"] = prescriptions
  19030. }
  19031. timestamp := time.Now().Unix()
  19032. tempTime := time.Unix(timestamp, 0)
  19033. timeFormat := tempTime.Format("20060102150405")
  19034. chrgBchno := rand.Intn(100000) + 10000
  19035. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  19036. strconv.FormatInt(his.PatientId, 10)
  19037. client := &http.Client{}
  19038. data["psn_no"] = his.PsnNo
  19039. data["mdtrt_id"] = his.Number
  19040. data["chrg_bchno"] = chrg_bchno
  19041. data["org_name"] = miConfig.OrgName
  19042. data["doctor"] = doctor_info.UserName
  19043. data["doctor_id"] = doctor_info.DoctorNumber
  19044. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  19045. data["fixmedins_code"] = miConfig.Code
  19046. data["dept_code"] = department.Number
  19047. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19048. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19049. data["secret_key"] = miConfig.SecretKey
  19050. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  19051. data["url"] = miConfig.Url
  19052. data["ak"] = miConfig.AccessKey
  19053. data["new_doctor_name"] = patientPrescription.Doctor
  19054. data["diag_code"] = sickConfig.CountryCode
  19055. data["cainfo"] = miConfig.Cainfo
  19056. data["opter"] = roles.UserName
  19057. var ids []int64
  19058. for _, item := range prescriptions {
  19059. ids = append(ids, item.ID)
  19060. }
  19061. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19062. if config.IsOpen == 1 { //对接了医保,走医保流程
  19063. var res ResultFour
  19064. var resFour10265 ResultFour10265
  19065. if miConfig.MdtrtareaAdmvs == "421300" {
  19066. bytesData, _ := json.Marshal(data)
  19067. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19068. resp, _ := client.Do(req)
  19069. defer resp.Body.Close()
  19070. body, ioErr := ioutil.ReadAll(resp.Body)
  19071. if ioErr != nil {
  19072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19074. return
  19075. }
  19076. var respJSON map[string]interface{}
  19077. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19080. return
  19081. }
  19082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19083. userJSONBytes, _ := json.Marshal(respJSON)
  19084. fmt.Println("log")
  19085. fmt.Println(string(userJSONBytes))
  19086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19087. utils.ErrorLog("解析失败:%v", err)
  19088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19089. return
  19090. }
  19091. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19092. bytesData, _ := json.Marshal(data)
  19093. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19094. resp, _ := client.Do(req)
  19095. defer resp.Body.Close()
  19096. body, ioErr := ioutil.ReadAll(resp.Body)
  19097. if ioErr != nil {
  19098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19100. return
  19101. }
  19102. var respJSON map[string]interface{}
  19103. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19106. return
  19107. }
  19108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19109. userJSONBytes, _ := json.Marshal(respJSON)
  19110. fmt.Println("log")
  19111. fmt.Println(string(userJSONBytes))
  19112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19113. utils.ErrorLog("解析失败:%v", err)
  19114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19115. return
  19116. }
  19117. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19118. bytesData, _ := json.Marshal(data)
  19119. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19120. resp, _ := client.Do(req)
  19121. defer resp.Body.Close()
  19122. body, ioErr := ioutil.ReadAll(resp.Body)
  19123. if ioErr != nil {
  19124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19126. return
  19127. }
  19128. var respJSON map[string]interface{}
  19129. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19132. return
  19133. }
  19134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19135. userJSONBytes, _ := json.Marshal(respJSON)
  19136. fmt.Println("log")
  19137. fmt.Println(string(userJSONBytes))
  19138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19139. utils.ErrorLog("解析失败:%v", err)
  19140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19141. return
  19142. }
  19143. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19144. bytesData, _ := json.Marshal(data)
  19145. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19146. resp, _ := client.Do(req)
  19147. defer resp.Body.Close()
  19148. body, ioErr := ioutil.ReadAll(resp.Body)
  19149. if ioErr != nil {
  19150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19152. return
  19153. }
  19154. var respJSON map[string]interface{}
  19155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19158. return
  19159. }
  19160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19161. userJSONBytes, _ := json.Marshal(respJSON)
  19162. fmt.Println("log")
  19163. fmt.Println(string(userJSONBytes))
  19164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19165. utils.ErrorLog("解析失败:%v", err)
  19166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19167. return
  19168. }
  19169. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19170. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  19171. if result3101.Infcode == "0" {
  19172. if len(result3101.Output.Result) > 0 {
  19173. var errMsgs []string
  19174. for _, item := range result3101.Output.Result {
  19175. errMsgs = append(errMsgs, item.VolaCont)
  19176. }
  19177. c.ServeSuccessJSON(map[string]interface{}{
  19178. "failed_code": -10,
  19179. "msg": errMsgs,
  19180. })
  19181. return
  19182. }
  19183. }
  19184. bytesData, _ := json.Marshal(data)
  19185. var req *http.Request
  19186. if miConfig.MdtrtareaAdmvs == "320921" {
  19187. data["diag_code"] = sickConfig.CountryCode
  19188. fmt.Println(data)
  19189. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19190. } else {
  19191. data["diag_code"] = sickConfig.CountryCode
  19192. fmt.Println(data)
  19193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19194. }
  19195. resp, _ := client.Do(req)
  19196. defer resp.Body.Close()
  19197. body, ioErr := ioutil.ReadAll(resp.Body)
  19198. if ioErr != nil {
  19199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19201. return
  19202. }
  19203. var respJSON map[string]interface{}
  19204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19207. return
  19208. }
  19209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19210. userJSONBytes, _ := json.Marshal(respJSON)
  19211. fmt.Println("log")
  19212. fmt.Println(string(userJSONBytes))
  19213. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19214. utils.ErrorLog("解析失败:%v", err)
  19215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19216. return
  19217. }
  19218. res.InfRefmsgid = resFour10265.InfRefmsgid
  19219. res.Output = resFour10265.Output
  19220. res.ErrMsg = resFour10265.ErrMsg
  19221. res.Cainfo = resFour10265.Cainfo
  19222. res.WarnMsg = resFour10265.WarnMsg
  19223. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19224. res.Infcode = infocode
  19225. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19226. var pagesize int = 2
  19227. var start int = 1
  19228. var stop int
  19229. var pagecount int
  19230. var curpage int
  19231. var isSuccess bool = true
  19232. data["doctor_id"] = doctor_info.DoctorNumber
  19233. //总页数,向上取整,注意除之前要先转换类型为float64
  19234. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19235. for curpage = 1; curpage <= pagecount; curpage++ {
  19236. if curpage == 1 {
  19237. start = 1
  19238. } else {
  19239. start = (curpage-1)*pagesize + 1
  19240. }
  19241. stop = curpage * pagesize
  19242. if stop > len(prescriptions) {
  19243. stop = len(prescriptions)
  19244. }
  19245. //var requestLog string
  19246. data["pre"] = prescriptions[start-1 : stop]
  19247. fmt.Println(data["pre"])
  19248. bytesData, _ := json.Marshal(data)
  19249. var req *http.Request
  19250. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19251. resp, _ := client.Do(req)
  19252. defer resp.Body.Close()
  19253. body, ioErr := ioutil.ReadAll(resp.Body)
  19254. if ioErr != nil {
  19255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19257. return
  19258. }
  19259. var respJSON map[string]interface{}
  19260. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19263. return
  19264. }
  19265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19266. userJSONBytes, _ := json.Marshal(respJSON)
  19267. fmt.Println("log")
  19268. fmt.Println(string(userJSONBytes))
  19269. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19270. utils.ErrorLog("解析失败:%v", err)
  19271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19272. return
  19273. }
  19274. res.InfRefmsgid = resFour10265.InfRefmsgid
  19275. res.Output = resFour10265.Output
  19276. res.ErrMsg = resFour10265.ErrMsg
  19277. res.Cainfo = resFour10265.Cainfo
  19278. res.WarnMsg = resFour10265.WarnMsg
  19279. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19280. res.Infcode = infocode
  19281. if infocode == 0 {
  19282. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19283. } else {
  19284. isSuccess = false
  19285. errlog := &models.HisOrderError{
  19286. UserOrgId: adminUser.CurrentOrgId,
  19287. Ctime: time.Now().Unix(),
  19288. Mtime: time.Now().Unix(),
  19289. Number: chrg_bchno,
  19290. ErrMsg: "",
  19291. Status: 1,
  19292. PatientId: id,
  19293. RecordTime: recordDateTime,
  19294. Stage: 4,
  19295. }
  19296. service.CreateErrMsgLog(errlog)
  19297. c.ServeSuccessJSON(map[string]interface{}{
  19298. "failed_code": -10,
  19299. "msg": res.ErrMsg,
  19300. })
  19301. return
  19302. }
  19303. }
  19304. if isSuccess {
  19305. res.Infcode = 0
  19306. }
  19307. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19308. 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)
  19309. var dat map[string]interface{}
  19310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19311. fmt.Println(dat)
  19312. } else {
  19313. fmt.Println(err)
  19314. }
  19315. saveLog(result, request_log, "2204", "上传费用明细")
  19316. userJSONBytes, _ := json.Marshal(dat)
  19317. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19318. utils.ErrorLog("解析失败:%v", err)
  19319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19320. return
  19321. }
  19322. res.InfRefmsgid = resFour10265.InfRefmsgid
  19323. res.Output = resFour10265.Output
  19324. res.ErrMsg = resFour10265.ErrMsg
  19325. res.Cainfo = resFour10265.Cainfo
  19326. res.WarnMsg = resFour10265.WarnMsg
  19327. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19328. res.Infcode = infocode
  19329. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19330. bytesData, _ := json.Marshal(data)
  19331. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19332. resp, _ := client.Do(req)
  19333. defer resp.Body.Close()
  19334. body, ioErr := ioutil.ReadAll(resp.Body)
  19335. if ioErr != nil {
  19336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19338. return
  19339. }
  19340. var respJSON map[string]interface{}
  19341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19344. return
  19345. }
  19346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19347. userJSONBytes, _ := json.Marshal(respJSON)
  19348. fmt.Println("log")
  19349. fmt.Println(string(userJSONBytes))
  19350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19351. utils.ErrorLog("解析失败:%v", err)
  19352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19353. return
  19354. }
  19355. } else {
  19356. if miConfig.Code == "H15049901371" {
  19357. 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)
  19358. var dat map[string]interface{}
  19359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19360. fmt.Println(dat)
  19361. } else {
  19362. fmt.Println(err)
  19363. }
  19364. saveLog(result, request_log, "2204", "上传费用明细")
  19365. userJSONBytes, _ := json.Marshal(dat)
  19366. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19367. utils.ErrorLog("解析失败:%v", err)
  19368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19369. return
  19370. }
  19371. res.InfRefmsgid = resFour10265.InfRefmsgid
  19372. res.Output = resFour10265.Output
  19373. res.ErrMsg = resFour10265.ErrMsg
  19374. res.Cainfo = resFour10265.Cainfo
  19375. res.WarnMsg = resFour10265.WarnMsg
  19376. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19377. res.Infcode = infocode
  19378. } else {
  19379. 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)
  19380. var dat map[string]interface{}
  19381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19382. fmt.Println(dat)
  19383. } else {
  19384. fmt.Println(err)
  19385. }
  19386. saveLog(result, request_log, "2204", "上传费用明细")
  19387. userJSONBytes, _ := json.Marshal(dat)
  19388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19389. utils.ErrorLog("解析失败:%v", err)
  19390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19391. return
  19392. }
  19393. }
  19394. }
  19395. if res.Infcode == 0 {
  19396. order := &models.HisOrder{
  19397. UserOrgId: adminUser.CurrentOrgId,
  19398. HisPatientId: his.ID,
  19399. PatientId: his.PatientId,
  19400. SettleAccountsDate: recordDateTime,
  19401. MdtrtId: his.Number,
  19402. PsnNo: his.PsnNo,
  19403. MedType: strconv.FormatInt(reg_type, 10),
  19404. Ctime: time.Now().Unix(),
  19405. Mtime: time.Now().Unix(),
  19406. Status: 1,
  19407. Number: chrg_bchno,
  19408. Infcode: res.Infcode,
  19409. WarnMsg: res.WarnMsg,
  19410. Cainfo: res.Cainfo,
  19411. ErrMsg: res.ErrMsg,
  19412. RespondTime: res.RefmsgTime,
  19413. InfRefmsgid: res.InfRefmsgid,
  19414. OrderStatus: 1,
  19415. PayWay: pay_way,
  19416. PayWays: pay_ways,
  19417. OthDesc: oth_desc,
  19418. PayPrice: pay_price,
  19419. PayCardNo: pay_card_no,
  19420. DiscountPrice: discount_price,
  19421. PreferentialPrice: preferential_price,
  19422. RealityPrice: reality_price,
  19423. FoundPrice: found_price,
  19424. MedicalInsurancePrice: medical_insurance_price,
  19425. PrivatePrice: private_price,
  19426. IsMedicineInsurance: 1,
  19427. SettleType: settle_accounts_type,
  19428. SettleStartTime: start_time,
  19429. SettleEndTime: end_time,
  19430. Creator: roles.AdminUserId,
  19431. Modify: roles.AdminUserId,
  19432. FaPiaoNumber: fapiao_number,
  19433. FaPiaoCode: fapiao_code,
  19434. PType: 2,
  19435. Diagnosis: diagnosis_id,
  19436. CashPay: cash_pay,
  19437. WechatPay: wechat_pay,
  19438. AliPay: ali_pay,
  19439. JifenPay: jifen_pay,
  19440. BandCardPay: band_card_pay,
  19441. }
  19442. err = service.CreateOrder(order)
  19443. if err != nil {
  19444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19445. return
  19446. }
  19447. for _, item := range res.Output.Result {
  19448. temp := strings.Split(item.FeedetlSn, "-")
  19449. var advice_id int64 = 0
  19450. var project_id int64 = 0
  19451. var types int64 = 0
  19452. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19453. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19454. if temp[1] == "1" {
  19455. advice_id = id
  19456. project_id = 0
  19457. } else if temp[1] == "2" {
  19458. advice_id = 0
  19459. project_id = id
  19460. }
  19461. if item.MedChrgitmType == "9" {
  19462. item.MedChrgitmType = "09"
  19463. }
  19464. info := &models.HisOrderInfo{
  19465. OrderNumber: order.Number,
  19466. FeedetlSn: item.FeedetlSn,
  19467. UploadDate: time.Now().Unix(),
  19468. AdviceId: advice_id,
  19469. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19470. Cnt: item.Cnt,
  19471. Pric: float64(item.Pric),
  19472. PatientId: his.PatientId,
  19473. PricUplmtAmt: item.PricUplmtAmt,
  19474. SelfpayProp: item.SelfpayProp,
  19475. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19476. OverlmtAmt: item.OverlmtAmt,
  19477. PreselfpayAmt: item.PreselfpayAmt,
  19478. BasMednFlag: item.BasMednFlag,
  19479. MedChrgitmType: item.MedChrgitmType,
  19480. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19481. Status: 1,
  19482. Memo: item.Memo,
  19483. Mtime: time.Now().Unix(),
  19484. InscpScpAmt: item.InscpScpAmt,
  19485. DrtReimFlag: item.DrtReimFlag,
  19486. Ctime: time.Now().Unix(),
  19487. ListSpItemFlag: item.ListSpItemFlag,
  19488. ChldMedcFlag: item.ChldMedcFlag,
  19489. LmtUsedFlag: item.LmtUsedFlag,
  19490. ChrgitmLv: item.ChrgitmLv,
  19491. UserOrgId: adminUser.CurrentOrgId,
  19492. HisPatientId: his.ID,
  19493. OrderId: order.ID,
  19494. ProjectId: project_id,
  19495. Type: types,
  19496. }
  19497. service.CreateOrderInfo(info)
  19498. }
  19499. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19500. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19501. var total float64
  19502. for _, item := range prescriptions {
  19503. if item.Type == 1 { //药品
  19504. for _, subItem := range item.HisDoctorAdviceInfo {
  19505. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19506. total_one := price * subItem.PrescribingNumber
  19507. total = total + total_one
  19508. }
  19509. }
  19510. if item.Type == 2 { //项目
  19511. for _, subItem := range item.HisPrescriptionProject {
  19512. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19513. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19514. total_one := price * cnt
  19515. total = total + total_one
  19516. }
  19517. }
  19518. }
  19519. allTotal := fmt.Sprintf("%.2f", total)
  19520. //if adminUser.CurrentOrgId == 9919 {
  19521. //
  19522. // allTotal = fmt.Sprintf("%.2f", total)
  19523. //
  19524. //} else {
  19525. //
  19526. // allTotal = fmt.Sprintf("%.2f", total)
  19527. //
  19528. //}
  19529. if res.Infcode == 0 {
  19530. var rf []*ResultFive
  19531. json.Unmarshal([]byte(his.Iinfo), &rf)
  19532. chrg_bchno := chrg_bchno
  19533. cert_no := his.Certno
  19534. var insutypes []string
  19535. var insutype string
  19536. var is390 int = 0
  19537. var is310 int = 0
  19538. for _, item := range rf {
  19539. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19540. insutypes = append(insutypes, item.Insutype)
  19541. }
  19542. }
  19543. if len(insutypes) == 1 {
  19544. insutype = insutypes[0]
  19545. } else {
  19546. for _, i := range insutypes {
  19547. if i == "390" {
  19548. is390 = 1
  19549. }
  19550. if i == "310" {
  19551. is310 = 1
  19552. }
  19553. }
  19554. }
  19555. if is390 == 1 {
  19556. insutype = "390"
  19557. }
  19558. if is310 == 1 {
  19559. insutype = "310"
  19560. }
  19561. if len(insutypes) == 0 {
  19562. insutype = "310"
  19563. }
  19564. if len(insutypes) == 2 {
  19565. insutype = strconv.FormatInt(his.SocialType, 10)
  19566. }
  19567. insutype = strconv.FormatInt(his.SocialType, 10)
  19568. //insutype = "390"
  19569. if his.IdCardType == 1 {
  19570. // cert_no = his.MedicalInsuranceNumber
  19571. cert_no = his.Certno
  19572. } else {
  19573. cert_no = his.Certno
  19574. }
  19575. var res ResultSeven
  19576. var resSeven10265 ResultSeven10265
  19577. var gzresSeven10265Two GZResultSeven10265Two
  19578. var src_resquest string
  19579. var result2 string
  19580. if miConfig.MdtrtareaAdmvs == "421300" {
  19581. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19582. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19583. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19585. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19586. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19587. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19588. resp, requestErr := http.Get(api)
  19589. if requestErr != nil {
  19590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19591. return
  19592. }
  19593. body, ioErr := ioutil.ReadAll(resp.Body)
  19594. if ioErr != nil {
  19595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19597. return
  19598. }
  19599. var respJSON map[string]interface{}
  19600. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19603. return
  19604. }
  19605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19606. result, _ := json.Marshal(respJSON)
  19607. if miConfig.Code == "H15049901371" {
  19608. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19609. utils.ErrorLog("解析失败:%v", err)
  19610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19611. return
  19612. }
  19613. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19614. res.Output = resSeven10265.Output
  19615. res.ErrMsg = resSeven10265.ErrMsg
  19616. res.Cainfo = resSeven10265.Cainfo
  19617. res.WarnMsg = resSeven10265.WarnMsg
  19618. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19619. res.Infcode = infocode
  19620. } else {
  19621. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19622. utils.ErrorLog("解析失败:%v", err)
  19623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19624. return
  19625. }
  19626. }
  19627. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19628. if reg_type == 11 && his.Insutype == "390" {
  19629. reg_type = 110104
  19630. }
  19631. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19632. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19633. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19634. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19635. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19636. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19637. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19638. resp, requestErr := http.Get(api)
  19639. if requestErr != nil {
  19640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19641. return
  19642. }
  19643. body, ioErr := ioutil.ReadAll(resp.Body)
  19644. if ioErr != nil {
  19645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19647. return
  19648. }
  19649. var respJSON map[string]interface{}
  19650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19653. return
  19654. }
  19655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19656. result, _ := json.Marshal(respJSON)
  19657. if miConfig.Code == "H15049901371" {
  19658. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19659. utils.ErrorLog("解析失败:%v", err)
  19660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19661. return
  19662. }
  19663. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19664. res.Output = resSeven10265.Output
  19665. res.ErrMsg = resSeven10265.ErrMsg
  19666. res.Cainfo = resSeven10265.Cainfo
  19667. res.WarnMsg = resSeven10265.WarnMsg
  19668. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19669. res.Infcode = infocode
  19670. } else {
  19671. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19672. utils.ErrorLog("解析失败:%v", err)
  19673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19674. return
  19675. }
  19676. }
  19677. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19678. if reg_type == 11 && his.Insutype == "390" {
  19679. reg_type = 110104
  19680. }
  19681. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19682. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19683. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19684. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19685. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19686. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19687. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19688. resp, requestErr := http.Get(api)
  19689. if requestErr != nil {
  19690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19691. return
  19692. }
  19693. body, ioErr := ioutil.ReadAll(resp.Body)
  19694. if ioErr != nil {
  19695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19697. return
  19698. }
  19699. var respJSON map[string]interface{}
  19700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19703. return
  19704. }
  19705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19706. result, _ := json.Marshal(respJSON)
  19707. if miConfig.Code == "H15049901371" {
  19708. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19709. utils.ErrorLog("解析失败:%v", err)
  19710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19711. return
  19712. }
  19713. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19714. res.Output = resSeven10265.Output
  19715. res.ErrMsg = resSeven10265.ErrMsg
  19716. res.Cainfo = resSeven10265.Cainfo
  19717. res.WarnMsg = resSeven10265.WarnMsg
  19718. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19719. res.Infcode = infocode
  19720. } else {
  19721. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19722. utils.ErrorLog("解析失败:%v", err)
  19723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19724. return
  19725. }
  19726. }
  19727. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19728. if reg_type == 11 && his.Insutype == "390" {
  19729. reg_type = 110104
  19730. }
  19731. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19732. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19733. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19734. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19735. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19736. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19737. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19738. resp, requestErr := http.Get(api)
  19739. if requestErr != nil {
  19740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19741. return
  19742. }
  19743. body, ioErr := ioutil.ReadAll(resp.Body)
  19744. if ioErr != nil {
  19745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19747. return
  19748. }
  19749. var respJSON map[string]interface{}
  19750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19753. return
  19754. }
  19755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19756. result, _ := json.Marshal(respJSON)
  19757. if miConfig.Code == "H15049901371" {
  19758. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19759. utils.ErrorLog("解析失败:%v", err)
  19760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19761. return
  19762. }
  19763. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19764. res.Output = resSeven10265.Output
  19765. res.ErrMsg = resSeven10265.ErrMsg
  19766. res.Cainfo = resSeven10265.Cainfo
  19767. res.WarnMsg = resSeven10265.WarnMsg
  19768. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19769. res.Infcode = infocode
  19770. } else {
  19771. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19772. utils.ErrorLog("解析失败:%v", err)
  19773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19774. return
  19775. }
  19776. }
  19777. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19778. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19779. if result3101.Infcode == "0" {
  19780. if len(result3101.Output.Result) > 0 {
  19781. var errMsgs []string
  19782. for _, item := range result3101.Output.Result {
  19783. errMsgs = append(errMsgs, item.VolaCont)
  19784. }
  19785. c.ServeSuccessJSON(map[string]interface{}{
  19786. "failed_code": -10,
  19787. "msg": errMsgs,
  19788. })
  19789. return
  19790. } else {
  19791. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19792. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19793. bas := strings.Split(psn_info.CardInfo, "|")
  19794. if his.IdCardType == 1 {
  19795. cert_no = bas[2]
  19796. } else if his.IdCardType == 3 {
  19797. cert_no = his.Certno
  19798. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19799. } else if his.IdCardType == 4 {
  19800. cert_no = his.Certno
  19801. psn_info.VerifyNumber = psn_info.VerifyNumber
  19802. }
  19803. var api string
  19804. if miConfig.MdtrtareaAdmvs == "320921" {
  19805. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19806. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19807. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19808. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19809. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19810. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19811. "&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
  19812. } else {
  19813. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19814. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19815. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19817. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19818. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19819. "&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
  19820. }
  19821. resp, requestErr := http.Get(api)
  19822. if requestErr != nil {
  19823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19824. return
  19825. }
  19826. body, ioErr := ioutil.ReadAll(resp.Body)
  19827. if ioErr != nil {
  19828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19830. return
  19831. }
  19832. var respJSON map[string]interface{}
  19833. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19836. return
  19837. }
  19838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19839. result, _ := json.Marshal(respJSON)
  19840. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19841. utils.ErrorLog("解析失败:%v", err)
  19842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19843. return
  19844. }
  19845. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19846. res.Output = resSeven10265.Output
  19847. res.ErrMsg = resSeven10265.ErrMsg
  19848. res.Cainfo = resSeven10265.Cainfo
  19849. res.WarnMsg = resSeven10265.WarnMsg
  19850. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19851. res.Infcode = infocode
  19852. }
  19853. }
  19854. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19855. psn_info, _ := service.GetPsnByPatientId(id)
  19856. var verify_number string
  19857. if psn_info.IdCardType == 4 {
  19858. verify_number = psn_info.VerifyNumber
  19859. } else if psn_info.IdCardType == 1 {
  19860. bas := strings.Split(psn_info.CardInfo, "|")
  19861. cardNumber := bas[2]
  19862. verify_number = cardNumber
  19863. } else {
  19864. psn_info.IdCardType = 2
  19865. verify_number = psn_info.Certno
  19866. }
  19867. var api string
  19868. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19869. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19870. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19871. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19872. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19873. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19874. "&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
  19875. resp, requestErr := http.Get(api)
  19876. if requestErr != nil {
  19877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19878. return
  19879. }
  19880. body, ioErr := ioutil.ReadAll(resp.Body)
  19881. if ioErr != nil {
  19882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19884. return
  19885. }
  19886. var respJSON map[string]interface{}
  19887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19890. return
  19891. }
  19892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19893. result, _ := json.Marshal(respJSON)
  19894. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19895. utils.ErrorLog("解析失败:%v", err)
  19896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19897. return
  19898. }
  19899. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19900. res.Output = resSeven10265.Output
  19901. res.ErrMsg = resSeven10265.ErrMsg
  19902. res.Cainfo = resSeven10265.Cainfo
  19903. res.WarnMsg = resSeven10265.WarnMsg
  19904. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19905. res.Infcode = infocode
  19906. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19907. var cert_no string
  19908. if his.IdCardType == 4 {
  19909. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19910. cert_no = psn_info.VerifyNumber
  19911. 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)
  19912. } else if his.IdCardType == 1 {
  19913. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19914. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19915. 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)
  19916. }
  19917. //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)
  19918. var dat map[string]interface{}
  19919. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19920. fmt.Println(dat)
  19921. } else {
  19922. fmt.Println(err)
  19923. }
  19924. saveLog(result2, src_resquest, "2207", "结算")
  19925. userJSONBytes, _ := json.Marshal(dat)
  19926. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19927. utils.ErrorLog("解析失败:%v", err)
  19928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19929. return
  19930. }
  19931. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19932. res.Output = resSeven10265.Output
  19933. res.ErrMsg = resSeven10265.ErrMsg
  19934. res.Cainfo = resSeven10265.Cainfo
  19935. res.WarnMsg = resSeven10265.WarnMsg
  19936. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19937. res.Infcode = infocode
  19938. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19939. res2 := c.GetoleInfo()
  19940. if res2.Infcode == 0 {
  19941. var result string
  19942. var request_log string
  19943. var result_log string
  19944. if res2.Output.MdtrtCertType == "02" {
  19945. 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)
  19946. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19947. } else if res2.Output.MdtrtCertType == "01" {
  19948. 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)
  19949. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19950. } else {
  19951. 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)
  19952. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19953. }
  19954. var dat map[string]interface{}
  19955. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19956. fmt.Println(dat)
  19957. } else {
  19958. fmt.Println(err)
  19959. }
  19960. userJSONBytes, _ := json.Marshal(dat)
  19961. var res5 ResultTwo
  19962. //var resTwo10265 ResultTwo10265
  19963. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19964. utils.ErrorLog("解析失败:%v", err)
  19965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19966. return
  19967. }
  19968. if res5.Infcode == -1 {
  19969. c.ServeSuccessJSON(map[string]interface{}{
  19970. "failed_code": -10,
  19971. "msg": res5.ErrMsg,
  19972. })
  19973. return
  19974. }
  19975. var insutypes []string
  19976. var insutype string
  19977. var is390 int = 0
  19978. var is310 int = 0
  19979. for _, item := range res5.Output.Iinfo {
  19980. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19981. insutypes = append(insutypes, item.Insutype)
  19982. }
  19983. }
  19984. if len(insutypes) == 1 {
  19985. insutype = insutypes[0]
  19986. } else {
  19987. for _, i := range insutypes {
  19988. if i == "390" {
  19989. is390 = 1
  19990. }
  19991. if i == "310" {
  19992. is310 = 1
  19993. }
  19994. }
  19995. }
  19996. if is390 == 1 {
  19997. insutype = "390"
  19998. }
  19999. if is310 == 1 {
  20000. insutype = "310"
  20001. }
  20002. if len(insutypes) == 0 {
  20003. insutype = "310"
  20004. }
  20005. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20006. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20007. infoStr := string(Iinfos)
  20008. idetinfoStr := string(Idetinfos)
  20009. psn := &models.HisPsn{
  20010. PsnNo: res5.Output.Baseinfo.PsnNo,
  20011. PatientId: id,
  20012. Certno: res5.Output.Baseinfo.Certno,
  20013. Gend: res5.Output.Baseinfo.Gend,
  20014. Naty: res5.Output.Baseinfo.Naty,
  20015. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20016. PsnName: res5.Output.Baseinfo.PsnName,
  20017. Idetinfo: idetinfoStr,
  20018. Insuinfo: infoStr,
  20019. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20020. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20021. VerifyNumber: res2.Output.EcToken,
  20022. }
  20023. if res2.Output.MdtrtCertType == "01" {
  20024. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20025. psn.VerifyNumber = res2.Output.EcToken
  20026. } else if res2.Output.MdtrtCertType == "02" {
  20027. psn.VerifyNumber = res2.Output.CardNo
  20028. } else {
  20029. psn.VerifyNumber = res2.Output.MdtrtCertNo
  20030. }
  20031. service.CreateHisPsn(psn)
  20032. if res2.Output.MdtrtCertType == "01" {
  20033. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20034. token := res2.Output.EcToken
  20035. 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)
  20036. } else if res2.Output.MdtrtCertType == "02" {
  20037. 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)
  20038. } else {
  20039. 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)
  20040. }
  20041. var dat2 map[string]interface{}
  20042. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20043. fmt.Println(dat2)
  20044. } else {
  20045. fmt.Println(err)
  20046. }
  20047. userJSONBytes3, _ := json.Marshal(dat2)
  20048. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20049. utils.ErrorLog("解析失败:%v", err)
  20050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20051. return
  20052. }
  20053. saveLog(result2, src_resquest, "2207", "结算")
  20054. } else {
  20055. c.ServeSuccessJSON(map[string]interface{}{
  20056. "failed_code": -10,
  20057. "msg": res2.ErrMsg,
  20058. })
  20059. return
  20060. }
  20061. } else {
  20062. if miConfig.Code == "H15049901371" {
  20063. //赤峰地区国家医保医疗类别
  20064. //职工透析:医疗类别选特殊情况门诊990502
  20065. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20066. var med_type string
  20067. if his.Insutype == "390" {
  20068. if reg_type == 14 {
  20069. med_type = "9933"
  20070. } else if reg_type == 11 {
  20071. med_type = "11"
  20072. }
  20073. } else if his.Insutype == "310" {
  20074. if reg_type == 14 {
  20075. med_type = "990502"
  20076. } else if reg_type == 11 {
  20077. med_type = "11"
  20078. }
  20079. }
  20080. 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)
  20081. } else {
  20082. if his.IdCardType == 4 {
  20083. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20084. var token string
  20085. token = psn_info.VerifyNumber
  20086. 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)
  20087. } else {
  20088. if his.IdCardType == 1 {
  20089. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20090. bas := strings.Split(psn_info.CardInfo, "|")
  20091. basNumber := bas[2]
  20092. cert_no = basNumber
  20093. }
  20094. 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)
  20095. }
  20096. }
  20097. //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)
  20098. var dat map[string]interface{}
  20099. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20100. fmt.Println(dat)
  20101. } else {
  20102. fmt.Println(err)
  20103. }
  20104. saveLog(result2, src_resquest, "2207", "结算")
  20105. userJSONBytes, _ := json.Marshal(dat)
  20106. if miConfig.Code == "H15049901371" {
  20107. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20108. utils.ErrorLog("解析失败:%v", err)
  20109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20110. return
  20111. }
  20112. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20113. res.Output = resSeven10265.Output
  20114. res.ErrMsg = resSeven10265.ErrMsg
  20115. res.Cainfo = resSeven10265.Cainfo
  20116. res.WarnMsg = resSeven10265.WarnMsg
  20117. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20118. res.Infcode = infocode
  20119. } else {
  20120. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20121. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20122. utils.ErrorLog("解析失败:%v", err)
  20123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20124. return
  20125. }
  20126. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20127. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20128. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20129. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20130. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20131. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20132. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20133. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20134. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20135. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20136. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20137. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20138. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20139. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20140. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20141. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20142. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20143. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20144. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20145. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20146. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20147. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20148. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20149. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20150. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20151. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20152. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20153. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20154. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20155. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20156. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20157. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20158. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20159. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20160. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20161. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20162. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20163. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20164. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20165. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20166. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20167. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20168. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20169. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20170. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20171. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20172. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20173. res.Cainfo = gzresSeven10265Two.Cainfo
  20174. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20175. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20176. //res.Infcode = infocode
  20177. } else {
  20178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20179. utils.ErrorLog("解析失败:%v", err)
  20180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20181. return
  20182. }
  20183. }
  20184. }
  20185. }
  20186. if res.Infcode == -1 {
  20187. errlog := &models.HisOrderError{
  20188. UserOrgId: adminUser.CurrentOrgId,
  20189. Ctime: time.Now().Unix(),
  20190. Mtime: time.Now().Unix(),
  20191. Number: chrg_bchno,
  20192. ErrMsg: res.ErrMsg,
  20193. Status: 1,
  20194. PatientId: id,
  20195. RecordTime: recordDateTime,
  20196. Stage: 6,
  20197. }
  20198. service.CreateErrMsgLog(errlog)
  20199. c.ServeSuccessJSON(map[string]interface{}{
  20200. "failed_code": -10,
  20201. "msg": res.ErrMsg,
  20202. })
  20203. return
  20204. } else {
  20205. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20206. order.OrderStatus = 2
  20207. order.Status = 1
  20208. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20209. order.SetlId = res.Output.Setlinfo.SetlID
  20210. order.PsnNo = res.Output.Setlinfo.PsnNo
  20211. order.PsnName = res.Output.Setlinfo.PsnName
  20212. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20213. order.Certno = res.Output.Setlinfo.Certno
  20214. order.Gend = res.Output.Setlinfo.Gend
  20215. order.Naty = res.Output.Setlinfo.Naty
  20216. order.Age = res.Output.Setlinfo.Age
  20217. order.Insutype = res.Output.Setlinfo.Insutype
  20218. order.PsnType = res.Output.Setlinfo.PsnType
  20219. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20220. order.SetlTime = res.Output.Setlinfo.SetlTime
  20221. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20222. if res.Output.Setlinfo.MedType == "140101" {
  20223. order.MedType = "14"
  20224. } else {
  20225. if res.Output.Setlinfo.MedType == "110104" {
  20226. order.MedType = "11"
  20227. } else {
  20228. order.MedType = res.Output.Setlinfo.MedType
  20229. }
  20230. }
  20231. if reg_type == 1112 {
  20232. order.MedType = "1112"
  20233. }
  20234. if reg_type == 1111 {
  20235. order.MedType = "1111"
  20236. }
  20237. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20238. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20239. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20240. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20241. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20242. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20243. order.HifpPay = res.Output.Setlinfo.HifpPay
  20244. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20245. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20246. order.HifesPay = res.Output.Setlinfo.HifesPay
  20247. order.HifobPay = res.Output.Setlinfo.HifobPay
  20248. order.MafPay = res.Output.Setlinfo.MafPay
  20249. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20250. order.OthPay = res.Output.Setlinfo.OthPay
  20251. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20252. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20253. order.AcctPay = res.Output.Setlinfo.AcctPay
  20254. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20255. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20256. order.Balc = res.Output.Setlinfo.Balc
  20257. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20258. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20259. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20260. order.ClrType = res.Output.Setlinfo.ClrType
  20261. order.ClrWay = res.Output.Setlinfo.ClrWay
  20262. order.Creator = order.Creator
  20263. order.Modify = roles.AdminUserId
  20264. order.RequestLog = src_resquest
  20265. order.FaPiaoNumber = fapiao_number
  20266. order.FaPiaoCode = fapiao_code
  20267. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20268. //detailStr := string(setlDetail)
  20269. //order.SetlDetail = detailStr
  20270. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20271. err = service.UpDateOrder(order)
  20272. if err == nil {
  20273. //判断是否使用了押金
  20274. if dec_way == "true" {
  20275. tmpstring := strconv.FormatInt(order.ID, 10)
  20276. order.Decimal = decimal
  20277. service.UpDateOrder(order)
  20278. //扣押金
  20279. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20280. if errmsg != nil {
  20281. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20282. return
  20283. }
  20284. }
  20285. c.ServeSuccessJSON(map[string]interface{}{
  20286. "msg": "结算成功",
  20287. })
  20288. } else {
  20289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20290. return
  20291. }
  20292. }
  20293. } else {
  20294. adminUser := c.GetAdminUserInfo()
  20295. errlog := &models.HisOrderError{
  20296. UserOrgId: adminUser.CurrentOrgId,
  20297. Ctime: time.Now().Unix(),
  20298. Mtime: time.Now().Unix(),
  20299. ErrMsg: res.ErrMsg,
  20300. Status: 1,
  20301. PatientId: id,
  20302. RecordTime: recordDateTime,
  20303. Stage: 4,
  20304. }
  20305. service.CreateErrMsgLog(errlog)
  20306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20307. return
  20308. }
  20309. } else {
  20310. adminUser := c.GetAdminUserInfo()
  20311. errlog := &models.HisOrderError{
  20312. UserOrgId: adminUser.CurrentOrgId,
  20313. Ctime: time.Now().Unix(),
  20314. Mtime: time.Now().Unix(),
  20315. ErrMsg: res.ErrMsg,
  20316. Status: 1,
  20317. PatientId: id,
  20318. RecordTime: recordDateTime,
  20319. Stage: 4,
  20320. }
  20321. service.CreateErrMsgLog(errlog)
  20322. c.ServeSuccessJSON(map[string]interface{}{
  20323. "failed_code": -10,
  20324. "msg": res.ErrMsg,
  20325. })
  20326. return
  20327. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20328. //return
  20329. }
  20330. }
  20331. }
  20332. } else if tempOrder.ID > 0 {
  20333. if tempOrder.IsPre == 1 {
  20334. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20335. var rf []*ResultFive
  20336. json.Unmarshal([]byte(his.Iinfo), &rf)
  20337. chrg_bchno := tempOrder.Number
  20338. cert_no := his.Certno
  20339. var insutypes []string
  20340. var insutype string
  20341. var is390 int = 0
  20342. var is310 int = 0
  20343. for _, item := range rf {
  20344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20345. insutypes = append(insutypes, item.Insutype)
  20346. }
  20347. }
  20348. if len(insutypes) == 1 {
  20349. insutype = insutypes[0]
  20350. } else {
  20351. for _, i := range insutypes {
  20352. if i == "390" {
  20353. is390 = 1
  20354. }
  20355. if i == "310" {
  20356. is310 = 1
  20357. }
  20358. }
  20359. }
  20360. if is390 == 1 {
  20361. insutype = "390"
  20362. }
  20363. if is310 == 1 {
  20364. insutype = "310"
  20365. }
  20366. if len(insutypes) == 0 {
  20367. insutype = "310"
  20368. }
  20369. if len(insutypes) == 2 {
  20370. insutype = strconv.FormatInt(his.SocialType, 10)
  20371. }
  20372. //insutype = "390"
  20373. if his.IdCardType == 1 {
  20374. // cert_no = his.MedicalInsuranceNumber
  20375. cert_no = his.Certno
  20376. } else {
  20377. cert_no = his.Certno
  20378. }
  20379. var res ResultSeven
  20380. var ahres ResultSevenAH
  20381. var resSeven10265 ResultSeven10265
  20382. var gzresSeven10265Two GZResultSeven10265Two
  20383. var src_resquest string
  20384. var result2 string
  20385. if miConfig.MdtrtareaAdmvs == "450721" {
  20386. res2 := c.GetoleInfo()
  20387. if res2.Infcode == 0 {
  20388. var result string
  20389. var request_log string
  20390. var result_log string
  20391. if res2.Output.MdtrtCertType == "02" {
  20392. 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)
  20393. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20394. } else if res2.Output.MdtrtCertType == "01" {
  20395. 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)
  20396. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20397. } else {
  20398. 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)
  20399. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20400. }
  20401. var dat map[string]interface{}
  20402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20403. fmt.Println(dat)
  20404. } else {
  20405. fmt.Println(err)
  20406. }
  20407. userJSONBytes, _ := json.Marshal(dat)
  20408. var res5 ResultTwo
  20409. //var resTwo10265 ResultTwo10265
  20410. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20411. utils.ErrorLog("解析失败:%v", err)
  20412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20413. return
  20414. }
  20415. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20416. if res5.Infcode == -1 {
  20417. c.ServeSuccessJSON(map[string]interface{}{
  20418. "failed_code": -10,
  20419. "msg": res5.ErrMsg,
  20420. })
  20421. return
  20422. }
  20423. var insutypes []string
  20424. var insutype string
  20425. var is390 int = 0
  20426. var is310 int = 0
  20427. for _, item := range res5.Output.Iinfo {
  20428. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20429. insutypes = append(insutypes, item.Insutype)
  20430. }
  20431. }
  20432. if len(insutypes) == 1 {
  20433. insutype = insutypes[0]
  20434. } else {
  20435. for _, i := range insutypes {
  20436. if i == "390" {
  20437. is390 = 1
  20438. }
  20439. if i == "310" {
  20440. is310 = 1
  20441. }
  20442. }
  20443. }
  20444. if is390 == 1 {
  20445. insutype = "390"
  20446. }
  20447. if is310 == 1 {
  20448. insutype = "310"
  20449. }
  20450. if len(insutypes) == 0 {
  20451. insutype = "310"
  20452. }
  20453. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20454. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20455. infoStr := string(Iinfos)
  20456. idetinfoStr := string(Idetinfos)
  20457. psn := &models.HisPsn{
  20458. PsnNo: res5.Output.Baseinfo.PsnNo,
  20459. PatientId: id,
  20460. Certno: res5.Output.Baseinfo.Certno,
  20461. Gend: res5.Output.Baseinfo.Gend,
  20462. Naty: res5.Output.Baseinfo.Naty,
  20463. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20464. PsnName: res5.Output.Baseinfo.PsnName,
  20465. Idetinfo: idetinfoStr,
  20466. Insuinfo: infoStr,
  20467. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20468. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20469. VerifyNumber: res2.Output.EcToken,
  20470. }
  20471. service.CreateHisPsn(psn)
  20472. if res2.Output.MdtrtCertType == "01" {
  20473. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20474. token := res2.Output.EcToken
  20475. 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)
  20476. } else if res2.Output.MdtrtCertType == "02" {
  20477. 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)
  20478. } else {
  20479. 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)
  20480. }
  20481. var dat2 map[string]interface{}
  20482. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20483. fmt.Println(dat2)
  20484. } else {
  20485. fmt.Println(err)
  20486. }
  20487. userJSONBytes3, _ := json.Marshal(dat2)
  20488. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20489. utils.ErrorLog("解析失败:%v", err)
  20490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20491. return
  20492. }
  20493. saveLog(result2, src_resquest, "2207", "结算")
  20494. } else {
  20495. c.ServeSuccessJSON(map[string]interface{}{
  20496. "failed_code": -10,
  20497. "msg": res2.ErrMsg,
  20498. })
  20499. return
  20500. }
  20501. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20502. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20503. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20504. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20505. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20506. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20507. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20508. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20509. resp, requestErr := http.Get(api)
  20510. if requestErr != nil {
  20511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20512. return
  20513. }
  20514. body, ioErr := ioutil.ReadAll(resp.Body)
  20515. if ioErr != nil {
  20516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20518. return
  20519. }
  20520. var respJSON map[string]interface{}
  20521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20524. return
  20525. }
  20526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20527. result, _ := json.Marshal(respJSON)
  20528. fmt.Println("log")
  20529. fmt.Println(string(result))
  20530. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20531. utils.ErrorLog("解析失败:%v", err)
  20532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20533. return
  20534. }
  20535. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20536. if reg_type == 11 && his.Insutype == "390" {
  20537. reg_type = 110104
  20538. }
  20539. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20540. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20541. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20542. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20543. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20544. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20545. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20546. resp, requestErr := http.Get(api)
  20547. if requestErr != nil {
  20548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20549. return
  20550. }
  20551. body, ioErr := ioutil.ReadAll(resp.Body)
  20552. if ioErr != nil {
  20553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20555. return
  20556. }
  20557. var respJSON map[string]interface{}
  20558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20561. return
  20562. }
  20563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20564. result, _ := json.Marshal(respJSON)
  20565. fmt.Println("log")
  20566. fmt.Println(string(result))
  20567. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20568. utils.ErrorLog("解析失败:%v", err)
  20569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20570. return
  20571. }
  20572. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20573. if reg_type == 11 && his.Insutype == "390" {
  20574. reg_type = 110104
  20575. }
  20576. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20577. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20578. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20579. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20580. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20581. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20582. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20583. resp, requestErr := http.Get(api)
  20584. if requestErr != nil {
  20585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20586. return
  20587. }
  20588. body, ioErr := ioutil.ReadAll(resp.Body)
  20589. if ioErr != nil {
  20590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20592. return
  20593. }
  20594. var respJSON map[string]interface{}
  20595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20598. return
  20599. }
  20600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20601. result, _ := json.Marshal(respJSON)
  20602. fmt.Println("log")
  20603. fmt.Println(string(result))
  20604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20605. utils.ErrorLog("解析失败:%v", err)
  20606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20607. return
  20608. }
  20609. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20610. if reg_type == 11 && his.Insutype == "390" {
  20611. reg_type = 110104
  20612. }
  20613. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20614. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20615. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20616. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20617. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20618. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20619. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20620. resp, requestErr := http.Get(api)
  20621. if requestErr != nil {
  20622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20623. return
  20624. }
  20625. body, ioErr := ioutil.ReadAll(resp.Body)
  20626. if ioErr != nil {
  20627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20629. return
  20630. }
  20631. var respJSON map[string]interface{}
  20632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20635. return
  20636. }
  20637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20638. result, _ := json.Marshal(respJSON)
  20639. fmt.Println("log")
  20640. fmt.Println(string(result))
  20641. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20642. utils.ErrorLog("解析失败:%v", err)
  20643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20644. return
  20645. }
  20646. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20647. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20648. if result3101.Infcode == "0" {
  20649. if len(result3101.Output.Result) > 0 {
  20650. var errMsgs []string
  20651. for _, item := range result3101.Output.Result {
  20652. errMsgs = append(errMsgs, item.VolaCont)
  20653. }
  20654. c.ServeSuccessJSON(map[string]interface{}{
  20655. "failed_code": -10,
  20656. "msg": errMsgs,
  20657. })
  20658. return
  20659. } else {
  20660. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20661. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20662. bas := strings.Split(psn_info.CardInfo, "|")
  20663. if his.IdCardType == 1 {
  20664. cert_no = bas[2]
  20665. } else if his.IdCardType == 3 {
  20666. cert_no = his.Certno
  20667. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20668. } else if his.IdCardType == 4 {
  20669. cert_no = his.Certno
  20670. psn_info.VerifyNumber = psn_info.VerifyNumber
  20671. }
  20672. //江苏地区国家医保医疗类别
  20673. //职工透析:医疗类别选特殊情况门诊9933
  20674. //居民血透门慢: 医疗类别选门诊慢病1402
  20675. //var med_type string
  20676. //if his.Insutype == "310" {
  20677. // if reg_type == 14 {
  20678. // med_type = "9933"
  20679. // } else if reg_type == 11 {
  20680. // med_type = "11"
  20681. //
  20682. // }
  20683. //} else if his.Insutype == "390" {
  20684. // if reg_type == 14 {
  20685. // med_type = "1402"
  20686. // } else if reg_type == 11 {
  20687. // med_type = "11"
  20688. // }
  20689. //}
  20690. var api string
  20691. if miConfig.MdtrtareaAdmvs == "320921" {
  20692. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20693. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20694. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20695. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20696. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20697. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20698. "&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
  20699. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20700. } else {
  20701. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20702. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20703. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20704. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20706. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20707. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20708. "&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
  20709. }
  20710. resp, requestErr := http.Get(api)
  20711. if requestErr != nil {
  20712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20713. return
  20714. }
  20715. body, ioErr := ioutil.ReadAll(resp.Body)
  20716. if ioErr != nil {
  20717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20719. return
  20720. }
  20721. var respJSON map[string]interface{}
  20722. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20725. return
  20726. }
  20727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20728. result, _ := json.Marshal(respJSON)
  20729. fmt.Println("log")
  20730. fmt.Println(string(result))
  20731. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20732. utils.ErrorLog("解析失败:%v", err)
  20733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20734. return
  20735. }
  20736. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20737. res.Output = resSeven10265.Output
  20738. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20739. res.ErrMsg = resSeven10265.ErrMsg
  20740. res.Cainfo = resSeven10265.Cainfo
  20741. res.WarnMsg = resSeven10265.WarnMsg
  20742. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20743. res.Infcode = infocode
  20744. }
  20745. }
  20746. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20747. psn_info, _ := service.GetPsnByPatientId(id)
  20748. var verify_number string
  20749. if psn_info.IdCardType == 4 {
  20750. verify_number = psn_info.VerifyNumber
  20751. } else if psn_info.IdCardType == 1 {
  20752. bas := strings.Split(psn_info.CardInfo, "|")
  20753. cardNumber := bas[2]
  20754. verify_number = cardNumber
  20755. } else {
  20756. verify_number = psn_info.Certno
  20757. psn_info.IdCardType = 2
  20758. }
  20759. var api string
  20760. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20761. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20762. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20763. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20764. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20765. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20766. "&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
  20767. resp, requestErr := http.Get(api)
  20768. if requestErr != nil {
  20769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20770. return
  20771. }
  20772. body, ioErr := ioutil.ReadAll(resp.Body)
  20773. if ioErr != nil {
  20774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20776. return
  20777. }
  20778. var respJSON map[string]interface{}
  20779. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20782. return
  20783. }
  20784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20785. result, _ := json.Marshal(respJSON)
  20786. fmt.Println("log")
  20787. fmt.Println(string(result))
  20788. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20789. utils.ErrorLog("解析失败:%v", err)
  20790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20791. return
  20792. }
  20793. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20794. res.Output = resSeven10265.Output
  20795. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20796. res.ErrMsg = resSeven10265.ErrMsg
  20797. res.Cainfo = resSeven10265.Cainfo
  20798. res.WarnMsg = resSeven10265.WarnMsg
  20799. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20800. res.Infcode = infocode
  20801. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20802. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20803. var cert_no string
  20804. if his.IdCardType == 1 {
  20805. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20806. } else {
  20807. cert_no = psn_info.VerifyNumber
  20808. }
  20809. 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)
  20810. var dat map[string]interface{}
  20811. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20812. fmt.Println(dat)
  20813. } else {
  20814. fmt.Println(err)
  20815. }
  20816. saveLog(result2, src_resquest, "2207", "结算")
  20817. userJSONBytes, _ := json.Marshal(dat)
  20818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20819. utils.ErrorLog("解析失败:%v", err)
  20820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20821. return
  20822. }
  20823. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20824. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20825. var cert_no string
  20826. var card_sn string
  20827. if his.IdCardType == 1 {
  20828. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20829. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20830. bas := strings.Split(psn_info.CardInfo, "|")
  20831. card_sn = bas[3]
  20832. } else if his.IdCardType == 2 {
  20833. cert_no = his.IdCardNo
  20834. } else {
  20835. cert_no = psn_info.VerifyNumber
  20836. }
  20837. var rf []*ResultFive
  20838. json.Unmarshal([]byte(his.Iinfo), &rf)
  20839. var psn_type string
  20840. for _, item := range rf {
  20841. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20842. psn_type = item.PsnType
  20843. }
  20844. }
  20845. 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)
  20846. var dat map[string]interface{}
  20847. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20848. fmt.Println(dat)
  20849. } else {
  20850. fmt.Println(err)
  20851. }
  20852. saveLog(result2, src_resquest, "2207", "结算")
  20853. userJSONBytes, _ := json.Marshal(dat)
  20854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20855. utils.ErrorLog("解析失败:%v", err)
  20856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20857. return
  20858. }
  20859. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20860. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20861. if his.IdCardType == 1 {
  20862. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20863. bas := strings.Split(psn_info.CardInfo, "|")
  20864. cert_no = bas[2]
  20865. } else if his.IdCardType == 3 {
  20866. cert_no = his.Certno
  20867. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20868. } else if his.IdCardType == 4 {
  20869. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20870. cert_no = his.Certno
  20871. psn_info.VerifyNumber = psn_info.VerifyNumber
  20872. } else {
  20873. cert_no = his.Certno
  20874. psn_info.VerifyNumber = his.Certno
  20875. }
  20876. var api string
  20877. var med_type string
  20878. if his.Insutype == "390" {
  20879. if reg_type == 992102 {
  20880. med_type = "992102"
  20881. }
  20882. if reg_type == 140104 {
  20883. med_type = "140104"
  20884. }
  20885. if reg_type == 14 {
  20886. med_type = "14"
  20887. }
  20888. } else if his.Insutype == "310" {
  20889. if reg_type == 992102 {
  20890. med_type = "992102"
  20891. }
  20892. if reg_type == 14 {
  20893. med_type = "14"
  20894. }
  20895. }
  20896. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20897. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20898. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20899. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20900. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20901. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20902. "&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
  20903. resp, requestErr := http.Get(api)
  20904. if requestErr != nil {
  20905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20906. return
  20907. }
  20908. body, ioErr := ioutil.ReadAll(resp.Body)
  20909. if ioErr != nil {
  20910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20912. return
  20913. }
  20914. var respJSON map[string]interface{}
  20915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20918. return
  20919. }
  20920. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20921. if status == "0" {
  20922. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20923. c.ServeSuccessJSON(map[string]interface{}{
  20924. "failed_code": -10,
  20925. "msg": err_msg,
  20926. })
  20927. return
  20928. }
  20929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20930. result, _ := json.Marshal(respJSON)
  20931. fmt.Println("log")
  20932. fmt.Println(string(result))
  20933. if err := json.Unmarshal(result, &ahres); err != nil {
  20934. utils.ErrorLog("解析失败:%v", err)
  20935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20936. return
  20937. }
  20938. res.InfRefmsgid = ahres.InfRefmsgid
  20939. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20940. // 创建对应的Time类型
  20941. t := time.UnixMilli(timestamp)
  20942. // 格式化成指定的日期字符串
  20943. str := t.Format("2006-01-02 15:04:05")
  20944. res.Output.Setlinfo.SetlTime = str
  20945. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20946. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20947. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20948. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20949. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20950. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20951. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20952. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20953. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20954. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20955. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20956. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20957. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20958. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20959. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20960. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20961. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20962. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20963. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20964. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20965. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20966. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20967. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20968. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20969. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20970. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20971. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20972. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20973. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20974. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20975. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20976. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20977. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20978. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20979. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20980. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20981. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20982. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20983. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20984. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20985. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20986. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20987. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20988. res.Output.Setldetail = ahres.Output.Setldetail
  20989. res.ErrMsg = ahres.ErrMsg
  20990. res.Cainfo = ahres.Cainfo
  20991. res.WarnMsg = ahres.WarnMsg
  20992. res.Infcode = ahres.Infcode
  20993. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20994. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20995. var cert_no string
  20996. if his.IdCardType == 1 {
  20997. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20998. } else if his.IdCardType == 2 {
  20999. cert_no = his.IdCardNo
  21000. } else {
  21001. cert_no = psn_info.VerifyNumber
  21002. }
  21003. 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, "")
  21004. var dat map[string]interface{}
  21005. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21006. fmt.Println(dat)
  21007. } else {
  21008. fmt.Println(err)
  21009. }
  21010. saveLog(result2, src_resquest, "2207", "结算")
  21011. userJSONBytes, _ := json.Marshal(dat)
  21012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21013. utils.ErrorLog("解析失败:%v", err)
  21014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21015. return
  21016. }
  21017. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21018. psn_info, _ := service.GetPsnByPatientId(id)
  21019. var verify_number string
  21020. if psn_info.IdCardType == 4 {
  21021. verify_number = psn_info.VerifyNumber
  21022. } else if psn_info.IdCardType == 1 {
  21023. bas := strings.Split(psn_info.CardInfo, "|")
  21024. cardNumber := bas[2]
  21025. verify_number = cardNumber
  21026. } else {
  21027. verify_number = psn_info.Certno
  21028. psn_info.IdCardType = 2
  21029. }
  21030. var api string
  21031. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21032. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21033. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21034. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21035. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21036. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21037. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  21038. resp, requestErr := http.Get(api)
  21039. if requestErr != nil {
  21040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21041. return
  21042. }
  21043. body, ioErr := ioutil.ReadAll(resp.Body)
  21044. if ioErr != nil {
  21045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21047. return
  21048. }
  21049. var respJSON map[string]interface{}
  21050. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21053. return
  21054. }
  21055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21056. result, _ := json.Marshal(respJSON)
  21057. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21058. utils.ErrorLog("解析失败:%v", err)
  21059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21060. return
  21061. }
  21062. } else {
  21063. var src_resquest string
  21064. if miConfig.Code == "H15049901371" {
  21065. //赤峰地区国家医保医疗类别
  21066. //职工透析:医疗类别选特殊情况门诊990502
  21067. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21068. var med_type string
  21069. if his.Insutype == "390" {
  21070. if reg_type == 14 {
  21071. med_type = "9933"
  21072. } else if reg_type == 11 {
  21073. med_type = "11"
  21074. }
  21075. } else if his.Insutype == "310" {
  21076. if reg_type == 14 {
  21077. med_type = "990502"
  21078. } else if reg_type == 11 {
  21079. med_type = "11"
  21080. }
  21081. }
  21082. 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)
  21083. } else {
  21084. if his.IdCardType == 4 {
  21085. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21086. token := psn_info.VerifyNumber
  21087. 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)
  21088. } else {
  21089. 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)
  21090. }
  21091. }
  21092. var dat map[string]interface{}
  21093. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21094. fmt.Println(dat)
  21095. } else {
  21096. fmt.Println(err)
  21097. }
  21098. saveLog(result2, src_resquest, "2207", "结算")
  21099. userJSONBytes, _ := json.Marshal(dat)
  21100. if miConfig.Code == "H15049901371" {
  21101. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21102. utils.ErrorLog("解析失败:%v", err)
  21103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21104. return
  21105. }
  21106. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21107. res.Output = resSeven10265.Output
  21108. res.ErrMsg = resSeven10265.ErrMsg
  21109. res.Cainfo = resSeven10265.Cainfo
  21110. res.WarnMsg = resSeven10265.WarnMsg
  21111. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21112. res.Infcode = infocode
  21113. } else {
  21114. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21115. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21116. utils.ErrorLog("解析失败:%v", err)
  21117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21118. return
  21119. }
  21120. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21121. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21122. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21123. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21124. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21125. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21126. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21127. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21128. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21129. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21130. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21131. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21132. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21133. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21134. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21135. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  21136. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21137. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21138. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21139. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21140. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21141. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21142. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21143. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21144. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21145. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21146. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21147. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21148. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21149. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21150. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  21151. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  21152. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  21153. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21154. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21155. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21156. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21157. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  21158. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21159. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  21160. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  21161. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21162. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21163. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21164. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21165. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21166. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21167. res.Cainfo = gzresSeven10265Two.Cainfo
  21168. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21169. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21170. //res.Infcode = infocode
  21171. } else {
  21172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21173. utils.ErrorLog("解析失败:%v", err)
  21174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21175. return
  21176. }
  21177. }
  21178. }
  21179. }
  21180. if res.Infcode != 0 {
  21181. errlog := &models.HisOrderError{
  21182. UserOrgId: adminUser.CurrentOrgId,
  21183. Ctime: time.Now().Unix(),
  21184. Mtime: time.Now().Unix(),
  21185. Number: chrg_bchno,
  21186. ErrMsg: res.ErrMsg,
  21187. Status: 1,
  21188. PatientId: id,
  21189. RecordTime: recordDateTime,
  21190. Stage: 6,
  21191. }
  21192. service.CreateErrMsgLog(errlog)
  21193. c.ServeSuccessJSON(map[string]interface{}{
  21194. "failed_code": -10,
  21195. "msg": res.ErrMsg,
  21196. })
  21197. return
  21198. } else {
  21199. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21200. order.OrderStatus = 2
  21201. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21202. order.SetlId = res.Output.Setlinfo.SetlID
  21203. order.PsnNo = res.Output.Setlinfo.PsnNo
  21204. order.PsnName = res.Output.Setlinfo.PsnName
  21205. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21206. order.Certno = res.Output.Setlinfo.Certno
  21207. order.Gend = res.Output.Setlinfo.Gend
  21208. order.Naty = res.Output.Setlinfo.Naty
  21209. order.Age = res.Output.Setlinfo.Age
  21210. order.Insutype = res.Output.Setlinfo.Insutype
  21211. order.PsnType = res.Output.Setlinfo.PsnType
  21212. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21213. order.SetlTime = res.Output.Setlinfo.SetlTime
  21214. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21215. order.PayWays = pay_ways
  21216. order.AcctUsedFlag = acct_used_flag
  21217. order.WechatPay = wechat_pay
  21218. order.AliPay = ali_pay
  21219. order.JifenPay = jifen_pay
  21220. order.BandCardPay = band_card_pay
  21221. order.CashPay = cash_pay
  21222. order.OthDesc = oth_desc
  21223. //order.MedType = res.Output.Setlinfo.MedType
  21224. if reg_type == 1112 {
  21225. order.MedType = "1112"
  21226. }
  21227. if reg_type == 1111 {
  21228. order.MedType = "1111"
  21229. }
  21230. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21231. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21232. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21233. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21234. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21235. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21236. order.HifpPay = res.Output.Setlinfo.HifpPay
  21237. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21238. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21239. order.HifesPay = res.Output.Setlinfo.HifesPay
  21240. order.HifobPay = res.Output.Setlinfo.HifobPay
  21241. order.MafPay = res.Output.Setlinfo.MafPay
  21242. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21243. order.OthPay = res.Output.Setlinfo.OthPay
  21244. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21245. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21246. order.AcctPay = res.Output.Setlinfo.AcctPay
  21247. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21248. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21249. order.Balc = res.Output.Setlinfo.Balc
  21250. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21251. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21252. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21253. order.ClrWay = res.Output.Setlinfo.ClrWay
  21254. order.Creator = order.Creator
  21255. order.ClrType = res.Output.Setlinfo.ClrType
  21256. order.Modify = roles.AdminUserId
  21257. order.RequestLog = src_resquest
  21258. order.Diagnosis = diagnosis_id
  21259. order.FaPiaoNumber = fapiao_number
  21260. order.FaPiaoCode = fapiao_code
  21261. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21262. detailStr := string(setlDetail)
  21263. order.SetlDetail = detailStr
  21264. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21265. err = service.UpDateOrder(order)
  21266. if err == nil {
  21267. //判断是否使用了押金
  21268. if dec_way == "true" {
  21269. tmpstring := strconv.FormatInt(order.ID, 10)
  21270. //扣押金
  21271. order.Decimal = decimal
  21272. service.UpDateOrder(order)
  21273. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21274. if errmsg != nil {
  21275. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21276. return
  21277. }
  21278. }
  21279. c.ServeSuccessJSON(map[string]interface{}{
  21280. "msg": "结算成功",
  21281. })
  21282. } else {
  21283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21284. return
  21285. }
  21286. }
  21287. }
  21288. }
  21289. }
  21290. // 上传明细-预结算-
  21291. func (c *HisApiController) GetPreUploadInfo() {
  21292. id, _ := c.GetInt64("id")
  21293. record_time := c.GetString("record_time")
  21294. his_patient_id, _ := c.GetInt64("his_patient_id")
  21295. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21296. admin_user_id, _ := c.GetInt64("admin_user_id")
  21297. diagnosis_id := c.GetString("diagnosis")
  21298. sick_type, _ := c.GetInt64("sick_type")
  21299. reg_type, _ := c.GetInt64("p_type")
  21300. begin_time := c.GetString("begin_time")
  21301. acct_used_flag := c.GetString("acct_used_flag")
  21302. id_str := c.GetString("ids")
  21303. ids_arr := strings.Split(id_str, ",")
  21304. timeLayout := "2006-01-02"
  21305. loc, _ := time.LoadLocation("Local")
  21306. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21307. if err != nil {
  21308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21309. return
  21310. }
  21311. recordDateTime := theTime.Unix()
  21312. adminUser := c.GetAdminUserInfo()
  21313. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21314. var config []*models.HisXtDiagnoseConfig
  21315. for _, item := range diagnosis_ids {
  21316. id, _ := strconv.ParseInt(item, 10, 64)
  21317. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21318. config = append(config, &diagnosisConfig)
  21319. }
  21320. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21321. sickConfig, _ := service.FindSickById(sick_type)
  21322. var prescriptions []*models.HisPrescription
  21323. var start_time int64
  21324. var end_time int64
  21325. var isSuccess bool = true
  21326. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21327. fmt.Println(his_patient_id)
  21328. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21329. timestamp := time.Now().Unix()
  21330. tempTime := time.Unix(timestamp, 0)
  21331. timeFormat := tempTime.Format("20060102150405")
  21332. chrgBchno := rand.Intn(100000) + 10000
  21333. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21334. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21335. var patientPrescription models.HisPrescriptionInfo
  21336. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21337. if patientPrescription.ID == 0 {
  21338. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21339. }
  21340. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21341. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21342. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21343. strconv.FormatInt(his.PatientId, 10)
  21344. var res2406 Result2406
  21345. //安徽单病种处理
  21346. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21347. data := make(map[string]interface{})
  21348. client := &http.Client{}
  21349. data["psn_no"] = his.PsnNo
  21350. data["mdtrt_id"] = his.Number
  21351. data["operator"] = roles.UserName
  21352. data["cert_no"] = his.IdCardNo
  21353. data["org_name"] = miConfig.OrgName
  21354. data["psn_name"] = his.Name
  21355. data["ipt_otp_no"] = his.IptOtpNo
  21356. data["ipt_psn_sp_flag_type"] = "0901"
  21357. data["ipt_psn_sp_flag"] = "1"
  21358. data["fixmedins_code"] = miConfig.Code
  21359. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21360. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21361. data["url"] = miConfig.Url
  21362. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21363. bytesData, _ := json.Marshal(data)
  21364. var req *http.Request
  21365. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21366. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21367. resp, _ := client.Do(req)
  21368. defer resp.Body.Close()
  21369. body, ioErr := ioutil.ReadAll(resp.Body)
  21370. if ioErr != nil {
  21371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21373. return
  21374. }
  21375. var respJSON map[string]interface{}
  21376. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21379. return
  21380. }
  21381. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21382. if status == "0" {
  21383. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21384. c.ServeSuccessJSON(map[string]interface{}{
  21385. "failed_code": -10,
  21386. "msg": err_msg,
  21387. })
  21388. return
  21389. }
  21390. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21391. userJSONBytes, _ := json.Marshal(respJSON)
  21392. fmt.Println("log")
  21393. fmt.Println(string(userJSONBytes))
  21394. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21395. utils.ErrorLog("解析失败:%v", err)
  21396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21397. return
  21398. }
  21399. }
  21400. if res2406.Infcode != 0 {
  21401. adminUser := c.GetAdminUserInfo()
  21402. errlog := &models.HisOrderError{
  21403. UserOrgId: adminUser.CurrentOrgId,
  21404. Ctime: time.Now().Unix(),
  21405. Mtime: time.Now().Unix(),
  21406. ErrMsg: res2406.ErrMsg,
  21407. Status: 1,
  21408. PatientId: id,
  21409. RecordTime: recordDateTime,
  21410. Stage: 3,
  21411. }
  21412. service.CreateErrMsgLog(errlog)
  21413. c.ServeSuccessJSON(map[string]interface{}{
  21414. "failed_code": -10,
  21415. "msg": res2406.ErrMsg,
  21416. })
  21417. return
  21418. }
  21419. var res2 ResultSix
  21420. var res3 GZResultSix
  21421. var resSix10265 ResultSix10265
  21422. //var time_stamp string
  21423. if miConfig.MdtrtareaAdmvs == "421300" {
  21424. data := make(map[string]interface{})
  21425. client := &http.Client{}
  21426. data["psn_no"] = his.PsnNo
  21427. data["mdtrt_id"] = his.Number
  21428. data["department"] = department.Name
  21429. data["org_name"] = miConfig.OrgName
  21430. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21431. data["doctor_id"] = doctor_info.DoctorNumber
  21432. data["doctor_name"] = roles.UserName
  21433. data["fixmedins_code"] = miConfig.Code
  21434. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21435. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21436. data["secret_key"] = miConfig.SecretKey
  21437. data["sick_code"] = sickConfig.CountryCode
  21438. data["sick_name"] = sickConfig.ClassName
  21439. data["begin_time"] = begin_time
  21440. data["dept"] = strconv.FormatInt(department.ID, 10)
  21441. data["config"] = config
  21442. data["opter"] = roles.UserName
  21443. fmt.Println(data)
  21444. bytesData, _ := json.Marshal(data)
  21445. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21446. resp, _ := client.Do(req)
  21447. defer resp.Body.Close()
  21448. body, ioErr := ioutil.ReadAll(resp.Body)
  21449. if ioErr != nil {
  21450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21452. return
  21453. }
  21454. var respJSON map[string]interface{}
  21455. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21458. return
  21459. }
  21460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21461. userJSONBytes, _ := json.Marshal(respJSON)
  21462. fmt.Println("log")
  21463. fmt.Println(string(userJSONBytes))
  21464. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21465. utils.ErrorLog("解析失败:%v", err)
  21466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21467. return
  21468. }
  21469. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21470. data := make(map[string]interface{})
  21471. client := &http.Client{}
  21472. data["psn_no"] = his.PsnNo
  21473. data["mdtrt_id"] = his.Number
  21474. data["department"] = department.Name
  21475. data["org_name"] = miConfig.OrgName
  21476. if reg_type == 11 && his.Insutype == "390" {
  21477. data["med_type"] = "110104"
  21478. } else {
  21479. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21480. }
  21481. data["doctor_id"] = doctor_info.DoctorNumber
  21482. data["doctor_name"] = roles.UserName
  21483. data["fixmedins_code"] = miConfig.Code
  21484. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21485. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21486. data["secret_key"] = miConfig.SecretKey
  21487. data["sick_code"] = sickConfig.CountryCode
  21488. data["sick_name"] = sickConfig.ClassName
  21489. data["begin_time"] = begin_time
  21490. data["dept"] = strconv.FormatInt(department.ID, 10)
  21491. data["config"] = config
  21492. data["opter"] = roles.UserName
  21493. fmt.Println(data)
  21494. bytesData, _ := json.Marshal(data)
  21495. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21496. resp, _ := client.Do(req)
  21497. defer resp.Body.Close()
  21498. body, ioErr := ioutil.ReadAll(resp.Body)
  21499. if ioErr != nil {
  21500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21502. return
  21503. }
  21504. var respJSON map[string]interface{}
  21505. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21508. return
  21509. }
  21510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21511. userJSONBytes, _ := json.Marshal(respJSON)
  21512. fmt.Println("log")
  21513. fmt.Println(string(userJSONBytes))
  21514. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21515. utils.ErrorLog("解析失败:%v", err)
  21516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21517. return
  21518. }
  21519. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21520. data := make(map[string]interface{})
  21521. client := &http.Client{}
  21522. data["psn_no"] = his.PsnNo
  21523. data["mdtrt_id"] = his.Number
  21524. data["department"] = department.Name
  21525. data["org_name"] = miConfig.OrgName
  21526. if reg_type == 11 && his.Insutype == "390" {
  21527. data["med_type"] = "110104"
  21528. } else {
  21529. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21530. }
  21531. data["doctor_id"] = doctor_info.DoctorNumber
  21532. data["doctor_name"] = roles.UserName
  21533. data["fixmedins_code"] = miConfig.Code
  21534. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21535. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21536. data["secret_key"] = miConfig.SecretKey
  21537. data["sick_code"] = sickConfig.CountryCode
  21538. data["sick_name"] = sickConfig.ClassName
  21539. data["begin_time"] = begin_time
  21540. data["dept"] = strconv.FormatInt(department.ID, 10)
  21541. data["config"] = config
  21542. data["opter"] = roles.UserName
  21543. fmt.Println(data)
  21544. bytesData, _ := json.Marshal(data)
  21545. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21546. resp, _ := client.Do(req)
  21547. defer resp.Body.Close()
  21548. body, ioErr := ioutil.ReadAll(resp.Body)
  21549. if ioErr != nil {
  21550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21552. return
  21553. }
  21554. var respJSON map[string]interface{}
  21555. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21558. return
  21559. }
  21560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21561. userJSONBytes, _ := json.Marshal(respJSON)
  21562. fmt.Println("log")
  21563. fmt.Println(string(userJSONBytes))
  21564. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21565. utils.ErrorLog("解析失败:%v", err)
  21566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21567. return
  21568. }
  21569. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21570. data := make(map[string]interface{})
  21571. client := &http.Client{}
  21572. data["psn_no"] = his.PsnNo
  21573. data["mdtrt_id"] = his.Number
  21574. data["department"] = department.Name
  21575. data["org_name"] = miConfig.OrgName
  21576. if reg_type == 11 && his.Insutype == "390" {
  21577. data["med_type"] = "110104"
  21578. } else {
  21579. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21580. }
  21581. data["doctor_id"] = doctor_info.DoctorNumber
  21582. data["doctor_name"] = roles.UserName
  21583. data["fixmedins_code"] = miConfig.Code
  21584. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21586. data["secret_key"] = miConfig.SecretKey
  21587. data["sick_code"] = sickConfig.CountryCode
  21588. data["sick_name"] = sickConfig.ClassName
  21589. data["begin_time"] = begin_time
  21590. data["dept"] = strconv.FormatInt(department.ID, 10)
  21591. data["config"] = config
  21592. data["opter"] = roles.UserName
  21593. fmt.Println(data)
  21594. bytesData, _ := json.Marshal(data)
  21595. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21596. resp, _ := client.Do(req)
  21597. defer resp.Body.Close()
  21598. body, ioErr := ioutil.ReadAll(resp.Body)
  21599. if ioErr != nil {
  21600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21602. return
  21603. }
  21604. var respJSON map[string]interface{}
  21605. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21608. return
  21609. }
  21610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21611. userJSONBytes, _ := json.Marshal(respJSON)
  21612. fmt.Println("log")
  21613. fmt.Println(string(userJSONBytes))
  21614. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21615. utils.ErrorLog("解析失败:%v", err)
  21616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21617. return
  21618. }
  21619. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21620. data := make(map[string]interface{})
  21621. client := &http.Client{}
  21622. data["psn_no"] = his.PsnNo
  21623. data["mdtrt_id"] = his.Number
  21624. data["doctor"] = roles.UserName
  21625. data["department"] = department.Name
  21626. data["org_name"] = miConfig.OrgName
  21627. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21628. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21629. data["fixmedins_code"] = miConfig.Code
  21630. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21631. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21632. data["secret_key"] = miConfig.SecretKey
  21633. data["sick_code"] = sickConfig.CountryCode
  21634. data["sick_name"] = sickConfig.ClassName
  21635. data["begin_time"] = begin_time
  21636. data["dept"] = strconv.FormatInt(department.ID, 10)
  21637. data["config"] = config
  21638. data["url"] = miConfig.Url
  21639. data["ak"] = miConfig.AccessKey
  21640. data["cainfo"] = miConfig.Cainfo
  21641. bytesData, _ := json.Marshal(data)
  21642. var req *http.Request
  21643. if miConfig.MdtrtareaAdmvs == "320921" {
  21644. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21645. } else {
  21646. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21647. }
  21648. resp, _ := client.Do(req)
  21649. defer resp.Body.Close()
  21650. body, ioErr := ioutil.ReadAll(resp.Body)
  21651. if ioErr != nil {
  21652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21654. return
  21655. }
  21656. var respJSON map[string]interface{}
  21657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21660. return
  21661. }
  21662. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21663. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21664. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21666. userJSONBytes, _ := json.Marshal(respJSON)
  21667. fmt.Println("log")
  21668. fmt.Println(string(userJSONBytes))
  21669. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21670. utils.ErrorLog("解析失败:%v", err)
  21671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21672. return
  21673. }
  21674. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21675. res2.Output = resSix10265.Output
  21676. res2.ErrMsg = resSix10265.ErrMsg
  21677. res2.Cainfo = resSix10265.Cainfo
  21678. res2.WarnMsg = resSix10265.WarnMsg
  21679. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21680. res2.Infcode = infocode
  21681. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21682. data := make(map[string]interface{})
  21683. client := &http.Client{}
  21684. data["psn_no"] = his.PsnNo
  21685. data["mdtrt_id"] = his.Number
  21686. data["doctor"] = roles.UserName
  21687. data["department"] = department.Name
  21688. data["org_name"] = miConfig.OrgName
  21689. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21690. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21691. data["fixmedins_code"] = miConfig.Code
  21692. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21693. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21694. data["secret_key"] = miConfig.SecretKey
  21695. data["sick_code"] = sickConfig.CountryCode
  21696. data["sick_name"] = sickConfig.ClassName
  21697. data["begin_time"] = begin_time
  21698. data["dept"] = strconv.FormatInt(department.ID, 10)
  21699. data["config"] = config
  21700. //data["url"] = miConfig.Url
  21701. //data["ak"] = miConfig.AccessKey
  21702. data["cainfo"] = miConfig.Cainfo
  21703. fmt.Println(data)
  21704. bytesData, _ := json.Marshal(data)
  21705. var req *http.Request
  21706. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21707. resp, _ := client.Do(req)
  21708. defer resp.Body.Close()
  21709. body, ioErr := ioutil.ReadAll(resp.Body)
  21710. if ioErr != nil {
  21711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21713. return
  21714. }
  21715. var respJSON map[string]interface{}
  21716. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21719. return
  21720. }
  21721. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21722. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21723. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21725. userJSONBytes, _ := json.Marshal(respJSON)
  21726. fmt.Println("log")
  21727. fmt.Println(string(userJSONBytes))
  21728. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21729. utils.ErrorLog("解析失败:%v", err)
  21730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21731. return
  21732. }
  21733. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21734. res2.Output = resSix10265.Output
  21735. res2.ErrMsg = resSix10265.ErrMsg
  21736. res2.Cainfo = resSix10265.Cainfo
  21737. res2.WarnMsg = resSix10265.WarnMsg
  21738. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21739. res2.Infcode = infocode
  21740. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21741. 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)
  21742. saveLog(result, requestLog, "2203", "上传就诊信息")
  21743. var respJSON2 map[string]interface{}
  21744. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21747. return
  21748. }
  21749. userJSONBytes2, _ := json.Marshal(respJSON2)
  21750. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21751. utils.ErrorLog("解析失败:%v", err)
  21752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21753. return
  21754. }
  21755. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21756. var result string
  21757. var requestLog string
  21758. 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, "")
  21759. saveLog(result, requestLog, "2203", "上传就诊信息")
  21760. var respJSON2 map[string]interface{}
  21761. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21764. return
  21765. }
  21766. userJSONBytes2, _ := json.Marshal(respJSON2)
  21767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21768. utils.ErrorLog("解析失败:%v", err)
  21769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21770. return
  21771. }
  21772. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21773. data := make(map[string]interface{})
  21774. client := &http.Client{}
  21775. data["psn_no"] = his.PsnNo
  21776. data["mdtrt_id"] = his.Number
  21777. data["operator"] = roles.UserName
  21778. data["department"] = department.Name
  21779. data["org_name"] = miConfig.OrgName
  21780. var med_type string
  21781. if his.Insutype == "390" {
  21782. if reg_type == 992102 {
  21783. med_type = "992102"
  21784. data["sick_code"] = "ZDZ940"
  21785. data["sick_name"] = "慢性肾衰竭"
  21786. }
  21787. if reg_type == 140104 {
  21788. med_type = "140104"
  21789. data["sick_code"] = sickConfig.CountryCode
  21790. data["sick_name"] = sickConfig.ClassName
  21791. }
  21792. if reg_type == 14 {
  21793. med_type = "140104"
  21794. data["sick_code"] = sickConfig.CountryCode
  21795. data["sick_name"] = sickConfig.ClassName
  21796. }
  21797. } else if his.Insutype == "310" {
  21798. if reg_type == 992102 {
  21799. med_type = "992102"
  21800. data["sick_code"] = "ZDZ940"
  21801. data["sick_name"] = "慢性肾衰竭"
  21802. }
  21803. if reg_type == 140104 {
  21804. med_type = "140104"
  21805. data["sick_code"] = sickConfig.CountryCode
  21806. data["sick_name"] = sickConfig.ClassName
  21807. }
  21808. if reg_type == 14 {
  21809. med_type = "14"
  21810. data["sick_code"] = sickConfig.CountryCode
  21811. data["sick_name"] = sickConfig.ClassName
  21812. }
  21813. }
  21814. data["med_type"] = med_type
  21815. data["doctor_number"] = doctor_info.DoctorNumber
  21816. data["doctor_name"] = doctor_info.UserName
  21817. data["fixmedins_code"] = miConfig.Code
  21818. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21819. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21820. data["secret_key"] = miConfig.SecretKey
  21821. data["begin_time"] = begin_time
  21822. data["dept"] = strconv.FormatInt(department.ID, 10)
  21823. data["config"] = config
  21824. data["url"] = miConfig.Url
  21825. data["ak"] = miConfig.AccessKey
  21826. data["cainfo"] = miConfig.Cainfo
  21827. bytesData, _ := json.Marshal(data)
  21828. var req *http.Request
  21829. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21830. resp, _ := client.Do(req)
  21831. defer resp.Body.Close()
  21832. body, ioErr := ioutil.ReadAll(resp.Body)
  21833. if ioErr != nil {
  21834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21836. return
  21837. }
  21838. var respJSON map[string]interface{}
  21839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21842. return
  21843. }
  21844. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21845. if status == "0" {
  21846. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21847. c.ServeSuccessJSON(map[string]interface{}{
  21848. "failed_code": -10,
  21849. "msg": err_msg,
  21850. })
  21851. return
  21852. }
  21853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21854. userJSONBytes, _ := json.Marshal(respJSON)
  21855. fmt.Println("log")
  21856. fmt.Println(string(userJSONBytes))
  21857. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21858. utils.ErrorLog("解析失败:%v", err)
  21859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21860. return
  21861. }
  21862. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21863. var result string
  21864. var requestLog string
  21865. 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, "")
  21866. saveLog(result, requestLog, "2203", "上传就诊信息")
  21867. var respJSON2 map[string]interface{}
  21868. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21871. return
  21872. }
  21873. userJSONBytes2, _ := json.Marshal(respJSON2)
  21874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21875. utils.ErrorLog("解析失败:%v", err)
  21876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21877. return
  21878. }
  21879. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21880. data := make(map[string]interface{})
  21881. client := &http.Client{}
  21882. data["psn_no"] = his.PsnNo
  21883. data["mdtrt_id"] = his.Number
  21884. data["doctor"] = roles.UserName
  21885. data["department"] = department.Name
  21886. data["org_name"] = miConfig.OrgName
  21887. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21888. data["doctor_id"] = doctor_info.DoctorNumber
  21889. data["fixmedins_code"] = miConfig.Code
  21890. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21891. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21892. data["secret_key"] = miConfig.SecretKey
  21893. data["sick_code"] = sickConfig.CountryCode
  21894. data["sick_name"] = sickConfig.ClassName
  21895. data["begin_time"] = begin_time
  21896. data["new_doctor_name"] = doctor_info.UserName
  21897. data["dept"] = strconv.FormatInt(department.ID, 10)
  21898. data["config"] = config
  21899. bytesData, _ := json.Marshal(data)
  21900. var req *http.Request
  21901. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21902. resp, _ := client.Do(req)
  21903. defer resp.Body.Close()
  21904. body, ioErr := ioutil.ReadAll(resp.Body)
  21905. if ioErr != nil {
  21906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21908. return
  21909. }
  21910. var respJSON map[string]interface{}
  21911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21914. return
  21915. }
  21916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21917. userJSONBytes, _ := json.Marshal(respJSON)
  21918. fmt.Println("log")
  21919. fmt.Println(string(userJSONBytes))
  21920. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21921. utils.ErrorLog("解析失败:%v", err)
  21922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21923. return
  21924. }
  21925. } else {
  21926. var result string
  21927. var requestLog string
  21928. if miConfig.MdtrtareaAdmvs == "440781" { //
  21929. 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)
  21930. } else {
  21931. if miConfig.Code == "H15049901371" {
  21932. //赤峰地区国家医保医疗类别
  21933. //职工透析:医疗类别选特殊情况门诊990502
  21934. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21935. var med_type string
  21936. if his.Insutype == "390" {
  21937. if reg_type == 14 {
  21938. med_type = "9933"
  21939. } else if reg_type == 11 {
  21940. med_type = "11"
  21941. }
  21942. } else if his.Insutype == "310" {
  21943. if reg_type == 14 {
  21944. med_type = "990502"
  21945. } else if reg_type == 11 {
  21946. med_type = "11"
  21947. }
  21948. }
  21949. 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)
  21950. } else {
  21951. 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)
  21952. }
  21953. saveLog(result, requestLog, "2203", "上传就诊信息")
  21954. var respJSON2 map[string]interface{}
  21955. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21958. return
  21959. }
  21960. userJSONBytes2, _ := json.Marshal(respJSON2)
  21961. if miConfig.Code == "H15049901371" {
  21962. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21963. utils.ErrorLog("解析失败:%v", err)
  21964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21965. return
  21966. }
  21967. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21968. res2.Output = resSix10265.Output
  21969. res2.ErrMsg = resSix10265.ErrMsg
  21970. res2.Cainfo = resSix10265.Cainfo
  21971. res2.WarnMsg = resSix10265.WarnMsg
  21972. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21973. res2.Infcode = infocode
  21974. } else {
  21975. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21976. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21977. utils.ErrorLog("解析失败:%v", err)
  21978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21979. return
  21980. }
  21981. res2.Infcode = res3.Infcode
  21982. } else {
  21983. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21984. utils.ErrorLog("解析失败:%v", err)
  21985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21986. return
  21987. }
  21988. }
  21989. }
  21990. }
  21991. }
  21992. if res2.Infcode == -1 {
  21993. adminUser := c.GetAdminUserInfo()
  21994. errlog := &models.HisOrderError{
  21995. UserOrgId: adminUser.CurrentOrgId,
  21996. Ctime: time.Now().Unix(),
  21997. Mtime: time.Now().Unix(),
  21998. ErrMsg: res2.ErrMsg,
  21999. Status: 1,
  22000. PatientId: id,
  22001. RecordTime: recordDateTime,
  22002. Stage: 3,
  22003. }
  22004. service.CreateErrMsgLog(errlog)
  22005. c.ServeSuccessJSON(map[string]interface{}{
  22006. "failed_code": -10,
  22007. "msg": res2.ErrMsg,
  22008. })
  22009. return
  22010. }
  22011. if res2.Infcode != 0 {
  22012. adminUser := c.GetAdminUserInfo()
  22013. errlog := &models.HisOrderError{
  22014. UserOrgId: adminUser.CurrentOrgId,
  22015. Ctime: time.Now().Unix(),
  22016. Mtime: time.Now().Unix(),
  22017. ErrMsg: res2.ErrMsg,
  22018. Status: 1,
  22019. PatientId: id,
  22020. RecordTime: recordDateTime,
  22021. Stage: 3,
  22022. }
  22023. service.CreateErrMsgLog(errlog)
  22024. c.ServeSuccessJSON(map[string]interface{}{
  22025. "failed_code": -10,
  22026. "msg": res2.ErrMsg,
  22027. })
  22028. return
  22029. } else {
  22030. his.Diagnosis = diagnosis_id
  22031. his.SickType = sickConfig.ID
  22032. his.PType = fmt.Sprintf("%d", reg_type)
  22033. service.UpdateHisPatientThree(&his)
  22034. data := make(map[string]interface{})
  22035. if settle_accounts_type == 1 { //日结
  22036. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22037. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22038. } else {
  22039. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22040. }
  22041. data["pre"] = prescriptions
  22042. } else { //月结
  22043. start_time_str := c.GetString("start_time")
  22044. end_time_str := c.GetString("end_time")
  22045. timeLayout := "2006-01-02"
  22046. loc, _ := time.LoadLocation("Local")
  22047. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22048. if err != nil {
  22049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22050. return
  22051. }
  22052. recordStartTime := theStartTime.Unix()
  22053. start_time = recordStartTime
  22054. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22055. if err != nil {
  22056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22057. return
  22058. }
  22059. recordEndTime := theEndTime.Unix()
  22060. end_time = recordEndTime
  22061. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22062. data["pre"] = prescriptions
  22063. }
  22064. client := &http.Client{}
  22065. data["psn_no"] = his.PsnNo
  22066. data["mdtrt_id"] = his.Number
  22067. data["chrg_bchno"] = chrg_bchno
  22068. data["org_name"] = miConfig.OrgName
  22069. data["doctor"] = doctor_info.UserName
  22070. data["doctor_id"] = doctor_info.DoctorNumber
  22071. data["dept"] = department.Name
  22072. data["fixmedins_code"] = miConfig.Code
  22073. data["opter"] = roles.UserName
  22074. data["dept_code"] = department.Number
  22075. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22076. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22077. data["secret_key"] = miConfig.SecretKey
  22078. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22079. data["url"] = miConfig.Url
  22080. data["ak"] = miConfig.AccessKey
  22081. data["new_doctor_name"] = patientPrescription.Doctor
  22082. if his.Insutype == "390" {
  22083. if reg_type == 992102 {
  22084. data["diag_code"] = "ZDZ940"
  22085. }
  22086. if reg_type == 140104 {
  22087. data["diag_code"] = sickConfig.CountryCode
  22088. }
  22089. if reg_type == 14 {
  22090. data["diag_code"] = sickConfig.CountryCode
  22091. }
  22092. } else if his.Insutype == "310" {
  22093. if reg_type == 992102 {
  22094. data["diag_code"] = "ZDZ940"
  22095. }
  22096. if reg_type == 14 {
  22097. data["diag_code"] = sickConfig.CountryCode
  22098. }
  22099. }
  22100. data["cainfo"] = miConfig.Cainfo
  22101. data["opter"] = roles.UserName
  22102. var ids []int64
  22103. for _, item := range prescriptions {
  22104. ids = append(ids, item.ID)
  22105. }
  22106. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22107. if config.IsOpen == 1 { //对接了医保,走医保流程
  22108. var res ResultFour
  22109. var resFour10265 ResultFour10265
  22110. if miConfig.MdtrtareaAdmvs == "421300" {
  22111. bytesData, _ := json.Marshal(data)
  22112. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22113. resp, _ := client.Do(req)
  22114. defer resp.Body.Close()
  22115. body, ioErr := ioutil.ReadAll(resp.Body)
  22116. if ioErr != nil {
  22117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22119. return
  22120. }
  22121. var respJSON map[string]interface{}
  22122. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22125. return
  22126. }
  22127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22128. userJSONBytes, _ := json.Marshal(respJSON)
  22129. fmt.Println("log")
  22130. fmt.Println(string(userJSONBytes))
  22131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22132. utils.ErrorLog("解析失败:%v", err)
  22133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22134. return
  22135. }
  22136. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22137. bytesData, _ := json.Marshal(data)
  22138. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22139. resp, _ := client.Do(req)
  22140. defer resp.Body.Close()
  22141. body, ioErr := ioutil.ReadAll(resp.Body)
  22142. if ioErr != nil {
  22143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22145. return
  22146. }
  22147. var respJSON map[string]interface{}
  22148. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22151. return
  22152. }
  22153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22154. userJSONBytes, _ := json.Marshal(respJSON)
  22155. fmt.Println("log")
  22156. fmt.Println(string(userJSONBytes))
  22157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22158. utils.ErrorLog("解析失败:%v", err)
  22159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22160. return
  22161. }
  22162. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22163. bytesData, _ := json.Marshal(data)
  22164. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22165. resp, _ := client.Do(req)
  22166. defer resp.Body.Close()
  22167. body, ioErr := ioutil.ReadAll(resp.Body)
  22168. if ioErr != nil {
  22169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22171. return
  22172. }
  22173. var respJSON map[string]interface{}
  22174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22177. return
  22178. }
  22179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22180. userJSONBytes, _ := json.Marshal(respJSON)
  22181. fmt.Println("log")
  22182. fmt.Println(string(userJSONBytes))
  22183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22184. utils.ErrorLog("解析失败:%v", err)
  22185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22186. return
  22187. }
  22188. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22189. bytesData, _ := json.Marshal(data)
  22190. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22191. resp, _ := client.Do(req)
  22192. defer resp.Body.Close()
  22193. body, ioErr := ioutil.ReadAll(resp.Body)
  22194. if ioErr != nil {
  22195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22197. return
  22198. }
  22199. var respJSON map[string]interface{}
  22200. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22203. return
  22204. }
  22205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22206. userJSONBytes, _ := json.Marshal(respJSON)
  22207. fmt.Println("log")
  22208. fmt.Println(string(userJSONBytes))
  22209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22210. utils.ErrorLog("解析失败:%v", err)
  22211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22212. return
  22213. }
  22214. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22215. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22216. if result3101.Infcode == "0" {
  22217. if len(result3101.Output.Result) > 0 {
  22218. var errMsgs []string
  22219. for _, item := range result3101.Output.Result {
  22220. errMsgs = append(errMsgs, item.VolaCont)
  22221. }
  22222. c.ServeSuccessJSON(map[string]interface{}{
  22223. "failed_code": -10,
  22224. "msg": errMsgs,
  22225. })
  22226. return
  22227. } else {
  22228. if miConfig.MdtrtareaAdmvs == "320921" {
  22229. data["doctor_id"] = "D320923012139"
  22230. } else {
  22231. data["doctor_id"] = "D371621008686"
  22232. }
  22233. bytesData, _ := json.Marshal(data)
  22234. var req *http.Request
  22235. if miConfig.MdtrtareaAdmvs == "320921" {
  22236. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22237. } else {
  22238. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22239. }
  22240. resp, _ := client.Do(req)
  22241. defer resp.Body.Close()
  22242. body, ioErr := ioutil.ReadAll(resp.Body)
  22243. if ioErr != nil {
  22244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22246. return
  22247. }
  22248. var respJSON map[string]interface{}
  22249. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22252. return
  22253. }
  22254. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22255. userJSONBytes, _ := json.Marshal(respJSON)
  22256. fmt.Println("log")
  22257. fmt.Println(string(userJSONBytes))
  22258. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22259. utils.ErrorLog("解析失败:%v", err)
  22260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22261. return
  22262. }
  22263. res.InfRefmsgid = resFour10265.InfRefmsgid
  22264. res.Output = resFour10265.Output
  22265. res.ErrMsg = resFour10265.ErrMsg
  22266. res.Cainfo = resFour10265.Cainfo
  22267. res.WarnMsg = resFour10265.WarnMsg
  22268. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22269. res.Infcode = infocode
  22270. }
  22271. }
  22272. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22273. var pagesize int = 5
  22274. var start int = 1
  22275. var stop int
  22276. var pagecount int
  22277. var curpage int
  22278. data["doctor_id"] = doctor_info.DoctorNumber
  22279. var res2 ResultFour
  22280. //var result res.
  22281. //总页数,向上取整,注意除之前要先转换类型为float64
  22282. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22283. for curpage = 1; curpage <= pagecount; curpage++ {
  22284. if curpage == 1 {
  22285. start = 1
  22286. } else {
  22287. start = (curpage-1)*pagesize + 1
  22288. }
  22289. stop = curpage * pagesize
  22290. if stop > len(prescriptions) {
  22291. stop = len(prescriptions)
  22292. }
  22293. //var requestLog string
  22294. data["pre"] = prescriptions[start-1 : stop]
  22295. fmt.Println(data["pre"])
  22296. bytesData, _ := json.Marshal(data)
  22297. var req *http.Request
  22298. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22299. resp, _ := client.Do(req)
  22300. defer resp.Body.Close()
  22301. body, ioErr := ioutil.ReadAll(resp.Body)
  22302. if ioErr != nil {
  22303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22305. return
  22306. }
  22307. var respJSON map[string]interface{}
  22308. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22311. return
  22312. }
  22313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22314. userJSONBytes, _ := json.Marshal(respJSON)
  22315. fmt.Println("log")
  22316. fmt.Println(string(userJSONBytes))
  22317. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22318. utils.ErrorLog("解析失败:%v", err)
  22319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22320. return
  22321. }
  22322. res.InfRefmsgid = resFour10265.InfRefmsgid
  22323. res.Output = resFour10265.Output
  22324. res.ErrMsg = resFour10265.ErrMsg
  22325. res.Cainfo = resFour10265.Cainfo
  22326. res.WarnMsg = resFour10265.WarnMsg
  22327. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22328. res.Infcode = infocode
  22329. if infocode == 0 {
  22330. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22331. } else {
  22332. isSuccess = false
  22333. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22334. res.Infcode = -1
  22335. res.ErrMsg = resFour10265.ErrMsg
  22336. errlog := &models.HisOrderError{
  22337. UserOrgId: adminUser.CurrentOrgId,
  22338. Ctime: time.Now().Unix(),
  22339. Mtime: time.Now().Unix(),
  22340. Number: chrg_bchno,
  22341. ErrMsg: "",
  22342. Status: 1,
  22343. PatientId: id,
  22344. RecordTime: recordDateTime,
  22345. Stage: 4,
  22346. }
  22347. service.CreateErrMsgLog(errlog)
  22348. }
  22349. }
  22350. if isSuccess {
  22351. res.Infcode = 0
  22352. res.Output.Result = res2.Output.Result
  22353. } else {
  22354. order := &models.HisOrder{
  22355. UserOrgId: adminUser.CurrentOrgId,
  22356. HisPatientId: his.ID,
  22357. PatientId: his.PatientId,
  22358. SettleAccountsDate: recordDateTime,
  22359. Ctime: time.Now().Unix(),
  22360. Mtime: time.Now().Unix(),
  22361. MdtrtId: his.Number,
  22362. PsnNo: his.PsnNo,
  22363. MedType: strconv.FormatInt(reg_type, 10),
  22364. Status: 1,
  22365. Number: chrg_bchno,
  22366. Infcode: res.Infcode,
  22367. WarnMsg: res.WarnMsg,
  22368. Cainfo: res.Cainfo,
  22369. ErrMsg: res.ErrMsg,
  22370. RespondTime: res.RefmsgTime,
  22371. InfRefmsgid: res.InfRefmsgid,
  22372. OrderStatus: 1,
  22373. IsMedicineInsurance: 1,
  22374. SettleType: settle_accounts_type,
  22375. SettleStartTime: start_time,
  22376. SettleEndTime: end_time,
  22377. Creator: roles.AdminUserId,
  22378. Modify: roles.AdminUserId,
  22379. PType: 2,
  22380. Diagnosis: diagnosis_id,
  22381. }
  22382. err = service.CreateOrder(order)
  22383. if err != nil {
  22384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22385. return
  22386. }
  22387. c.ServeSuccessJSON(map[string]interface{}{
  22388. "failed_code": -10,
  22389. "msg": res2.ErrMsg,
  22390. })
  22391. return
  22392. }
  22393. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22394. 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)
  22395. var dat map[string]interface{}
  22396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22397. fmt.Println(dat)
  22398. } else {
  22399. fmt.Println(err)
  22400. }
  22401. saveLog(result, request_log, "2204", "上传费用明细")
  22402. userJSONBytes, _ := json.Marshal(dat)
  22403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22404. utils.ErrorLog("解析失败:%v", err)
  22405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22406. return
  22407. }
  22408. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22409. 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, "", "")
  22410. var dat map[string]interface{}
  22411. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22412. fmt.Println(dat)
  22413. } else {
  22414. fmt.Println(err)
  22415. }
  22416. saveLog(result, request_log, "2204", "上传费用明细")
  22417. userJSONBytes, _ := json.Marshal(dat)
  22418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22419. utils.ErrorLog("解析失败:%v", err)
  22420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22421. return
  22422. }
  22423. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22424. bytesData, _ := json.Marshal(data)
  22425. var req *http.Request
  22426. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22427. resp, _ := client.Do(req)
  22428. defer resp.Body.Close()
  22429. body, ioErr := ioutil.ReadAll(resp.Body)
  22430. if ioErr != nil {
  22431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22433. return
  22434. }
  22435. var respJSON map[string]interface{}
  22436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22439. return
  22440. }
  22441. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22442. if status == "0" {
  22443. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22444. c.ServeSuccessJSON(map[string]interface{}{
  22445. "failed_code": -10,
  22446. "msg": err_msg,
  22447. })
  22448. return
  22449. }
  22450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22451. userJSONBytes, _ := json.Marshal(respJSON)
  22452. fmt.Println("log")
  22453. fmt.Println(string(userJSONBytes))
  22454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22455. utils.ErrorLog("解析失败:%v", err)
  22456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22457. return
  22458. }
  22459. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22460. 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, "", "")
  22461. var dat map[string]interface{}
  22462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22463. fmt.Println(dat)
  22464. } else {
  22465. fmt.Println(err)
  22466. }
  22467. saveLog(result, request_log, "2204", "上传费用明细")
  22468. userJSONBytes, _ := json.Marshal(dat)
  22469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22470. utils.ErrorLog("解析失败:%v", err)
  22471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22472. return
  22473. }
  22474. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22475. bytesData, _ := json.Marshal(data)
  22476. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22477. resp, _ := client.Do(req)
  22478. defer resp.Body.Close()
  22479. body, ioErr := ioutil.ReadAll(resp.Body)
  22480. if ioErr != nil {
  22481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22483. return
  22484. }
  22485. var respJSON map[string]interface{}
  22486. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22489. return
  22490. }
  22491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22492. userJSONBytes, _ := json.Marshal(respJSON)
  22493. fmt.Println("log")
  22494. fmt.Println(string(userJSONBytes))
  22495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22496. utils.ErrorLog("解析失败:%v", err)
  22497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22498. return
  22499. }
  22500. } else {
  22501. if miConfig.MdtrtareaAdmvs == "441202" {
  22502. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22503. if result3101.Infcode == 0 {
  22504. if len(result3101.Output.Result) > 0 {
  22505. var errMsgs []string
  22506. for _, item := range result3101.Output.Result {
  22507. errMsgs = append(errMsgs, item.VolaCont)
  22508. }
  22509. c.ServeSuccessJSON(map[string]interface{}{
  22510. "failed_code": -10,
  22511. "msg": errMsgs,
  22512. })
  22513. return
  22514. } else {
  22515. 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)
  22516. var dat map[string]interface{}
  22517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22518. fmt.Println(dat)
  22519. } else {
  22520. fmt.Println(err)
  22521. }
  22522. saveLog(result, request_log, "2204", "上传费用明细")
  22523. userJSONBytes, _ := json.Marshal(dat)
  22524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22525. utils.ErrorLog("解析失败:%v", err)
  22526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22527. return
  22528. }
  22529. }
  22530. } else {
  22531. c.ServeSuccessJSON(map[string]interface{}{
  22532. "failed_code": -10,
  22533. "msg": result3101.ErrMsg,
  22534. })
  22535. return
  22536. }
  22537. } else {
  22538. if miConfig.Code == "H15049901371" {
  22539. 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)
  22540. var dat map[string]interface{}
  22541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22542. fmt.Println(dat)
  22543. } else {
  22544. fmt.Println(err)
  22545. }
  22546. saveLog(result, request_log, "2204", "上传费用明细")
  22547. userJSONBytes, _ := json.Marshal(dat)
  22548. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22549. utils.ErrorLog("解析失败:%v", err)
  22550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22551. return
  22552. }
  22553. res.InfRefmsgid = resFour10265.InfRefmsgid
  22554. res.Output = resFour10265.Output
  22555. res.ErrMsg = resFour10265.ErrMsg
  22556. res.Cainfo = resFour10265.Cainfo
  22557. res.WarnMsg = resFour10265.WarnMsg
  22558. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22559. res.Infcode = infocode
  22560. } else {
  22561. 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)
  22562. var dat map[string]interface{}
  22563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22564. fmt.Println(dat)
  22565. } else {
  22566. fmt.Println(err)
  22567. }
  22568. saveLog(result, request_log, "2204", "上传费用明细")
  22569. userJSONBytes, _ := json.Marshal(dat)
  22570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22571. utils.ErrorLog("解析失败:%v", err)
  22572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22573. return
  22574. }
  22575. }
  22576. }
  22577. }
  22578. var total_two float64
  22579. if res.Infcode == 0 {
  22580. order := &models.HisOrder{
  22581. UserOrgId: adminUser.CurrentOrgId,
  22582. HisPatientId: his.ID,
  22583. PatientId: his.PatientId,
  22584. SettleAccountsDate: recordDateTime,
  22585. Ctime: time.Now().Unix(),
  22586. Mtime: time.Now().Unix(),
  22587. MdtrtId: his.Number,
  22588. PsnNo: his.PsnNo,
  22589. MedType: strconv.FormatInt(reg_type, 10),
  22590. Status: 1,
  22591. Number: chrg_bchno,
  22592. Infcode: res.Infcode,
  22593. WarnMsg: res.WarnMsg,
  22594. Cainfo: res.Cainfo,
  22595. ErrMsg: res.ErrMsg,
  22596. RespondTime: res.RefmsgTime,
  22597. InfRefmsgid: res.InfRefmsgid,
  22598. OrderStatus: 1,
  22599. IsMedicineInsurance: 1,
  22600. SettleType: settle_accounts_type,
  22601. SettleStartTime: start_time,
  22602. SettleEndTime: end_time,
  22603. Creator: roles.AdminUserId,
  22604. Modify: roles.AdminUserId,
  22605. PType: 2,
  22606. Diagnosis: diagnosis_id,
  22607. }
  22608. err = service.CreateOrder(order)
  22609. if err != nil {
  22610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22611. return
  22612. }
  22613. for _, item := range res.Output.Result {
  22614. temp := strings.Split(item.FeedetlSn, "-")
  22615. var advice_id int64 = 0
  22616. var project_id int64 = 0
  22617. var types int64 = 0
  22618. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22619. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22620. if temp[1] == "1" {
  22621. advice_id = id
  22622. project_id = 0
  22623. } else if temp[1] == "2" {
  22624. advice_id = 0
  22625. project_id = id
  22626. }
  22627. total_two = total_two + item.DetItemFeeSumamt
  22628. info := &models.HisOrderInfo{
  22629. OrderNumber: order.Number,
  22630. FeedetlSn: item.FeedetlSn,
  22631. UploadDate: time.Now().Unix(),
  22632. AdviceId: advice_id,
  22633. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22634. Cnt: item.Cnt,
  22635. Pric: float64(item.Pric),
  22636. PatientId: his.PatientId,
  22637. PricUplmtAmt: item.PricUplmtAmt,
  22638. SelfpayProp: item.SelfpayProp,
  22639. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22640. OverlmtAmt: item.OverlmtAmt,
  22641. PreselfpayAmt: item.PreselfpayAmt,
  22642. BasMednFlag: item.BasMednFlag,
  22643. MedChrgitmType: item.MedChrgitmType,
  22644. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22645. Status: 1,
  22646. Memo: item.Memo,
  22647. Mtime: time.Now().Unix(),
  22648. InscpScpAmt: item.InscpScpAmt,
  22649. DrtReimFlag: item.DrtReimFlag,
  22650. Ctime: time.Now().Unix(),
  22651. ListSpItemFlag: item.ListSpItemFlag,
  22652. ChldMedcFlag: item.ChldMedcFlag,
  22653. LmtUsedFlag: item.LmtUsedFlag,
  22654. ChrgitmLv: item.ChrgitmLv,
  22655. UserOrgId: adminUser.CurrentOrgId,
  22656. HisPatientId: his.ID,
  22657. OrderId: order.ID,
  22658. ProjectId: project_id,
  22659. Type: types,
  22660. }
  22661. service.CreateOrderInfo(info)
  22662. }
  22663. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22664. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22665. var total float64
  22666. for _, item := range prescriptions {
  22667. if item.Type == 1 { //药品
  22668. for _, subItem := range item.HisDoctorAdviceInfo {
  22669. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22670. total_one := price * subItem.PrescribingNumber
  22671. fmt.Println("subItem")
  22672. fmt.Println(subItem.Price)
  22673. fmt.Println("price")
  22674. fmt.Println(price)
  22675. fmt.Println("total_one")
  22676. fmt.Println(total_one)
  22677. total = total + total_one
  22678. fmt.Println(total)
  22679. }
  22680. }
  22681. if item.Type == 2 { //项目
  22682. for _, subItem := range item.HisPrescriptionProject {
  22683. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22684. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22685. total_one := price * cnt
  22686. total = total + total_one
  22687. }
  22688. }
  22689. }
  22690. allTotal := fmt.Sprintf("%.2f", total)
  22691. if res.Infcode == 0 {
  22692. var rf []*ResultFive
  22693. json.Unmarshal([]byte(his.Iinfo), &rf)
  22694. chrg_bchno := chrg_bchno
  22695. cert_no := his.Certno
  22696. var insutypes []string
  22697. var insutype string
  22698. var is390 int = 0
  22699. var is310 int = 0
  22700. for _, item := range rf {
  22701. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22702. insutypes = append(insutypes, item.Insutype)
  22703. }
  22704. }
  22705. if len(insutypes) == 1 {
  22706. insutype = insutypes[0]
  22707. } else {
  22708. for _, i := range insutypes {
  22709. if i == "390" {
  22710. is390 = 1
  22711. }
  22712. if i == "310" {
  22713. is310 = 1
  22714. }
  22715. }
  22716. }
  22717. if is390 == 1 {
  22718. insutype = "390"
  22719. }
  22720. if is310 == 1 {
  22721. insutype = "310"
  22722. }
  22723. if len(insutypes) == 0 {
  22724. insutype = "390"
  22725. }
  22726. if len(insutypes) == 2 {
  22727. insutype = strconv.FormatInt(his.SocialType, 10)
  22728. }
  22729. //insutype = "390"
  22730. if his.IdCardType == 1 {
  22731. cert_no = his.MedicalInsuranceNumber
  22732. } else {
  22733. cert_no = his.Certno
  22734. }
  22735. var res ResultSeven
  22736. var ahres ResultSevenAH
  22737. var resSeven10265 ResultSeven10265
  22738. var resSeven10265Two ResultSeven10265Two
  22739. var gzresSeven10265Two GZResultSeven10265Two
  22740. if miConfig.MdtrtareaAdmvs == "421300" {
  22741. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22742. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22743. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22744. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22745. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22746. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22747. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22748. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22749. resp, requestErr := http.Get(api)
  22750. if requestErr != nil {
  22751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22752. return
  22753. }
  22754. body, ioErr := ioutil.ReadAll(resp.Body)
  22755. if ioErr != nil {
  22756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22758. return
  22759. }
  22760. var respJSON map[string]interface{}
  22761. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22764. return
  22765. }
  22766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22767. result, _ := json.Marshal(respJSON)
  22768. fmt.Println("log")
  22769. fmt.Println(string(result))
  22770. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22771. utils.ErrorLog("解析失败:%v", err)
  22772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22773. return
  22774. }
  22775. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22776. if reg_type == 11 && his.Insutype == "390" {
  22777. reg_type = 110104
  22778. }
  22779. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22780. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22781. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22783. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22784. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22785. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22786. resp, requestErr := http.Get(api)
  22787. if requestErr != nil {
  22788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22789. return
  22790. }
  22791. body, ioErr := ioutil.ReadAll(resp.Body)
  22792. if ioErr != nil {
  22793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22795. return
  22796. }
  22797. var respJSON map[string]interface{}
  22798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22801. return
  22802. }
  22803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22804. result, _ := json.Marshal(respJSON)
  22805. fmt.Println("log")
  22806. fmt.Println(string(result))
  22807. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22808. utils.ErrorLog("解析失败:%v", err)
  22809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22810. return
  22811. }
  22812. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22813. if reg_type == 11 && his.Insutype == "390" {
  22814. reg_type = 110104
  22815. }
  22816. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22817. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22818. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22820. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22821. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22822. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22823. resp, requestErr := http.Get(api)
  22824. if requestErr != nil {
  22825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22826. return
  22827. }
  22828. body, ioErr := ioutil.ReadAll(resp.Body)
  22829. if ioErr != nil {
  22830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22832. return
  22833. }
  22834. var respJSON map[string]interface{}
  22835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22838. return
  22839. }
  22840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22841. result, _ := json.Marshal(respJSON)
  22842. fmt.Println("log")
  22843. fmt.Println(string(result))
  22844. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22845. utils.ErrorLog("解析失败:%v", err)
  22846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22847. return
  22848. }
  22849. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22850. if reg_type == 11 && his.Insutype == "390" {
  22851. reg_type = 110104
  22852. }
  22853. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22854. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22855. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22856. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22857. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22858. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22859. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22860. resp, requestErr := http.Get(api)
  22861. if requestErr != nil {
  22862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22863. return
  22864. }
  22865. body, ioErr := ioutil.ReadAll(resp.Body)
  22866. if ioErr != nil {
  22867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22869. return
  22870. }
  22871. var respJSON map[string]interface{}
  22872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22875. return
  22876. }
  22877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22878. result, _ := json.Marshal(respJSON)
  22879. fmt.Println("log")
  22880. fmt.Println(string(result))
  22881. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22882. utils.ErrorLog("解析失败:%v", err)
  22883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22884. return
  22885. }
  22886. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22887. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22888. if result3101.Infcode == "0" {
  22889. if len(result3101.Output.Result) > 0 {
  22890. var errMsgs []string
  22891. for _, item := range result3101.Output.Result {
  22892. errMsgs = append(errMsgs, item.VolaCont)
  22893. }
  22894. c.ServeSuccessJSON(map[string]interface{}{
  22895. "failed_code": -10,
  22896. "msg": errMsgs,
  22897. })
  22898. return
  22899. } else {
  22900. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22901. if his.IdCardType != 4 {
  22902. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22903. bas := strings.Split(psn_info.CardInfo, "|")
  22904. if his.IdCardType == 1 {
  22905. cert_no = bas[2]
  22906. } else {
  22907. cert_no = bas[1]
  22908. }
  22909. } else {
  22910. cert_no = his.Certno
  22911. }
  22912. //江苏地区国家医保医疗类别
  22913. //职工透析:医疗类别选特殊情况门诊9933
  22914. //居民血透门慢: 医疗类别选门诊慢病1402
  22915. //var med_type string
  22916. //if his.Insutype == "310" {
  22917. // if reg_type == 14 {
  22918. // med_type = "9933"
  22919. // } else if reg_type == 11 {
  22920. // med_type = "11"
  22921. //
  22922. // }
  22923. //} else if his.Insutype == "390" {
  22924. // if reg_type == 14 {
  22925. // med_type = "1402"
  22926. // } else if reg_type == 11 {
  22927. // med_type = "11"
  22928. // }
  22929. //}
  22930. var api string
  22931. if miConfig.MdtrtareaAdmvs == "320921" {
  22932. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22933. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22934. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22935. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22936. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22937. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22938. "&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
  22939. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22940. } else {
  22941. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22942. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22943. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22944. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22945. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22946. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22947. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22948. "&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
  22949. }
  22950. resp, requestErr := http.Get(api)
  22951. if requestErr != nil {
  22952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22953. return
  22954. }
  22955. body, ioErr := ioutil.ReadAll(resp.Body)
  22956. if ioErr != nil {
  22957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22959. return
  22960. }
  22961. var respJSON map[string]interface{}
  22962. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22965. return
  22966. }
  22967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22968. result, _ := json.Marshal(respJSON)
  22969. fmt.Println("log")
  22970. fmt.Println(string(result))
  22971. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22972. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22973. utils.ErrorLog("解析失败:%v", err)
  22974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22975. return
  22976. }
  22977. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22978. res.Output = resSeven10265.Output
  22979. res.ErrMsg = resSeven10265.ErrMsg
  22980. res.Cainfo = resSeven10265.Cainfo
  22981. res.WarnMsg = resSeven10265.WarnMsg
  22982. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22983. res.Infcode = infocode
  22984. } else {
  22985. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22986. utils.ErrorLog("解析失败:%v", err)
  22987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22988. return
  22989. }
  22990. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22991. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22992. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22993. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22994. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22995. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22996. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22997. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22998. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22999. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  23000. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  23001. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23002. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  23003. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  23004. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23005. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23006. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  23007. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  23008. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  23009. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  23010. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  23011. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23012. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  23013. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  23014. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  23015. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  23016. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  23017. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  23018. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  23019. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  23020. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23021. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  23022. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  23023. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  23024. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23025. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23026. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23027. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23028. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  23029. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23030. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  23031. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  23032. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  23033. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  23034. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  23035. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  23036. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  23037. res.ErrMsg = resSeven10265Two.ErrMsg
  23038. res.Cainfo = resSeven10265Two.Cainfo
  23039. res.WarnMsg = resSeven10265Two.WarnMsg
  23040. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23041. res.Infcode = infocode
  23042. }
  23043. }
  23044. }
  23045. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23046. psn_info, _ := service.GetPsnByPatientId(id)
  23047. var verify_number string
  23048. if psn_info.IdCardType == 4 {
  23049. verify_number = psn_info.VerifyNumber
  23050. } else if psn_info.IdCardType == 1 {
  23051. bas := strings.Split(psn_info.CardInfo, "|")
  23052. cardNumber := bas[2]
  23053. verify_number = cardNumber
  23054. } else {
  23055. psn_info.IdCardType = 2
  23056. verify_number = psn_info.Certno
  23057. }
  23058. var api string
  23059. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23060. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23061. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23063. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23064. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23065. "&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
  23066. resp, requestErr := http.Get(api)
  23067. if requestErr != nil {
  23068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23069. return
  23070. }
  23071. body, ioErr := ioutil.ReadAll(resp.Body)
  23072. if ioErr != nil {
  23073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23075. return
  23076. }
  23077. var respJSON map[string]interface{}
  23078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23081. return
  23082. }
  23083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23084. result, _ := json.Marshal(respJSON)
  23085. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23086. utils.ErrorLog("解析失败:%v", err)
  23087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23088. return
  23089. }
  23090. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23091. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  23092. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  23093. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23094. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  23095. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  23096. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  23097. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  23098. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  23099. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  23100. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  23101. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  23102. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  23103. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23104. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  23105. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  23106. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  23107. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  23108. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  23109. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  23110. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23111. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  23112. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  23113. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  23114. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  23115. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  23116. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  23117. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  23118. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  23119. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  23120. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  23121. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  23122. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  23123. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  23124. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23125. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  23126. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  23127. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  23128. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  23129. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  23130. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  23131. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  23132. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  23133. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  23134. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  23135. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  23136. res.ErrMsg = resSeven10265.ErrMsg
  23137. res.Cainfo = resSeven10265.Cainfo
  23138. res.WarnMsg = resSeven10265.WarnMsg
  23139. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23140. res.Infcode = infocode
  23141. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23142. acct_used_flag := "1"
  23143. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  23144. var result string
  23145. var request_log string
  23146. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  23147. 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)
  23148. } else {
  23149. 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)
  23150. }
  23151. var dat map[string]interface{}
  23152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23153. fmt.Println(dat)
  23154. } else {
  23155. fmt.Println(err)
  23156. }
  23157. saveLog(result, request_log, "2206", "预结算")
  23158. userJSONBytes, _ := json.Marshal(dat)
  23159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23160. utils.ErrorLog("解析失败:%v", err)
  23161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23162. return
  23163. }
  23164. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23165. var result string
  23166. var request_log string
  23167. if his.IdCardType == 2 {
  23168. 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, "")
  23169. } else if his.IdCardType == 1 {
  23170. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23171. bas := strings.Split(psn_info.CardInfo, "|")
  23172. basNumber := bas[2]
  23173. card_sn := bas[3]
  23174. var rf []*ResultFive
  23175. json.Unmarshal([]byte(his.Iinfo), &rf)
  23176. var psn_type string
  23177. for _, item := range rf {
  23178. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23179. psn_type = item.PsnType
  23180. }
  23181. }
  23182. 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)
  23183. } else {
  23184. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23185. result, request_log = service.Jxyb2206(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, "")
  23186. }
  23187. var dat map[string]interface{}
  23188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23189. fmt.Println(dat)
  23190. } else {
  23191. fmt.Println(err)
  23192. }
  23193. saveLog(result, request_log, "2206", "预结算")
  23194. userJSONBytes, _ := json.Marshal(dat)
  23195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23196. utils.ErrorLog("解析失败:%v", err)
  23197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23198. return
  23199. }
  23200. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23201. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23202. if his.IdCardType == 4 {
  23203. psn_info.VerifyNumber = psn_info.VerifyNumber
  23204. cert_no = psn_info.Certno
  23205. } else if his.IdCardType == 2 {
  23206. cert_no = psn_info.Certno
  23207. psn_info.VerifyNumber = psn_info.Certno
  23208. } else {
  23209. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23210. bas := strings.Split(psn_info.CardInfo, "|")
  23211. if his.IdCardType == 1 {
  23212. cert_no = bas[2]
  23213. } else {
  23214. cert_no = bas[1]
  23215. }
  23216. }
  23217. var api string
  23218. var med_type string
  23219. if his.Insutype == "390" {
  23220. if reg_type == 992102 {
  23221. med_type = "992102"
  23222. }
  23223. if reg_type == 140104 {
  23224. med_type = "140104"
  23225. }
  23226. if reg_type == 14 {
  23227. med_type = "140104"
  23228. }
  23229. } else if his.Insutype == "310" {
  23230. if reg_type == 992102 {
  23231. med_type = "992102"
  23232. }
  23233. if reg_type == 14 {
  23234. med_type = "14"
  23235. }
  23236. }
  23237. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23238. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23239. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23241. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23242. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23243. "&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
  23244. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23245. resp, requestErr := http.Get(api)
  23246. if requestErr != nil {
  23247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23248. return
  23249. }
  23250. body, ioErr := ioutil.ReadAll(resp.Body)
  23251. if ioErr != nil {
  23252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23254. return
  23255. }
  23256. var respJSON map[string]interface{}
  23257. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23260. return
  23261. }
  23262. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23263. if status == "0" {
  23264. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23265. c.ServeSuccessJSON(map[string]interface{}{
  23266. "failed_code": -10,
  23267. "msg": err_msg,
  23268. })
  23269. return
  23270. }
  23271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23272. result, _ := json.Marshal(respJSON)
  23273. fmt.Println("log")
  23274. fmt.Println(string(result))
  23275. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23276. utils.ErrorLog("解析失败:%v", err)
  23277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23278. return
  23279. }
  23280. res.InfRefmsgid = ahres.InfRefmsgid
  23281. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23282. // 创建对应的Time类型
  23283. t := time.UnixMilli(timestamp)
  23284. // 格式化成指定的日期字符串
  23285. str := t.Format("2006-01-02 15:04:05")
  23286. res.Output.Setlinfo.SetlTime = str
  23287. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23288. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23289. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23290. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23291. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23292. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23293. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23294. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23295. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23296. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23297. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23298. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23299. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23300. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23301. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23302. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23303. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23304. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23305. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23306. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23307. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23308. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23309. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23310. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23311. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23312. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23313. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23314. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23315. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23316. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23317. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23318. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23319. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23320. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23321. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23322. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23323. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23324. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23325. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23326. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23327. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23328. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23329. //res.Output.Setldetail = ahres.Output.Setldetail
  23330. res.ErrMsg = ahres.ErrMsg
  23331. res.Cainfo = ahres.Cainfo
  23332. res.WarnMsg = ahres.WarnMsg
  23333. res.Infcode = ahres.Infcode
  23334. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23335. var result string
  23336. var request_log string
  23337. if his.IdCardType == 2 {
  23338. 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")
  23339. } else if his.IdCardType == 1 {
  23340. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23341. bas := strings.Split(psn_info.CardInfo, "|")
  23342. basNumber := bas[2]
  23343. card_sn := bas[3]
  23344. 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")
  23345. } else {
  23346. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23347. 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")
  23348. }
  23349. var dat map[string]interface{}
  23350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23351. fmt.Println(dat)
  23352. } else {
  23353. fmt.Println(err)
  23354. }
  23355. saveLog(result, request_log, "2206", "预结算")
  23356. userJSONBytes, _ := json.Marshal(dat)
  23357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23358. utils.ErrorLog("解析失败:%v", err)
  23359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23360. return
  23361. }
  23362. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23363. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23364. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23365. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23366. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23367. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23368. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23369. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23370. resp, requestErr := http.Get(api)
  23371. if requestErr != nil {
  23372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23373. return
  23374. }
  23375. body, ioErr := ioutil.ReadAll(resp.Body)
  23376. if ioErr != nil {
  23377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23379. return
  23380. }
  23381. var respJSON map[string]interface{}
  23382. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23385. return
  23386. }
  23387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23388. result, _ := json.Marshal(respJSON)
  23389. fmt.Println("log")
  23390. fmt.Println(string(result))
  23391. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23392. utils.ErrorLog("解析失败:%v", err)
  23393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23394. return
  23395. }
  23396. } else {
  23397. if miConfig.MdtrtareaAdmvs == "441202" {
  23398. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23399. if result3101.Infcode == 0 {
  23400. if len(result3101.Output.Result) > 0 {
  23401. var errMsgs []string
  23402. for _, item := range result3101.Output.Result {
  23403. errMsgs = append(errMsgs, item.VolaCont)
  23404. }
  23405. c.ServeSuccessJSON(map[string]interface{}{
  23406. "failed_code": -10,
  23407. "msg": errMsgs,
  23408. })
  23409. return
  23410. } else {
  23411. var result string
  23412. var request_log string
  23413. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23414. allTotal = fmt.Sprintf("%.2f", total_two)
  23415. if his.IdCardType == 4 {
  23416. 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)
  23417. } else {
  23418. 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)
  23419. }
  23420. var dat map[string]interface{}
  23421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23422. fmt.Println(dat)
  23423. } else {
  23424. fmt.Println(err)
  23425. }
  23426. saveLog(result, request_log, "2206", "预结算")
  23427. //userJSONBytes, _ := json.Marshal(dat)
  23428. //
  23429. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23430. // utils.ErrorLog("解析失败:%v", err)
  23431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23432. // return
  23433. //}
  23434. userJSONBytes, _ := json.Marshal(dat)
  23435. if miConfig.Code == "H15049901371" {
  23436. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23437. utils.ErrorLog("解析失败:%v", err)
  23438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23439. return
  23440. }
  23441. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23442. res.Output = resSeven10265.Output
  23443. res.ErrMsg = resSeven10265.ErrMsg
  23444. res.Cainfo = resSeven10265.Cainfo
  23445. res.WarnMsg = resSeven10265.WarnMsg
  23446. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23447. res.Infcode = infocode
  23448. } else {
  23449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23450. utils.ErrorLog("解析失败:%v", err)
  23451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23452. return
  23453. }
  23454. }
  23455. }
  23456. } else {
  23457. c.ServeSuccessJSON(map[string]interface{}{
  23458. "failed_code": -10,
  23459. "msg": result3101.ErrMsg,
  23460. })
  23461. return
  23462. }
  23463. } else {
  23464. var result string
  23465. var request_log string
  23466. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23467. allTotal = fmt.Sprintf("%.2f", total_two)
  23468. if his.IdCardType == 4 {
  23469. 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)
  23470. } else {
  23471. 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)
  23472. }
  23473. var dat map[string]interface{}
  23474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23475. fmt.Println(dat)
  23476. } else {
  23477. fmt.Println(err)
  23478. }
  23479. saveLog(result, request_log, "2206", "预结算")
  23480. //userJSONBytes, _ := json.Marshal(dat)
  23481. //
  23482. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23483. // utils.ErrorLog("解析失败:%v", err)
  23484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23485. // return
  23486. //}
  23487. userJSONBytes, _ := json.Marshal(dat)
  23488. if miConfig.Code == "H15049901371" {
  23489. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23490. utils.ErrorLog("解析失败:%v", err)
  23491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23492. return
  23493. }
  23494. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23495. res.Output = resSeven10265.Output
  23496. res.ErrMsg = resSeven10265.ErrMsg
  23497. res.Cainfo = resSeven10265.Cainfo
  23498. res.WarnMsg = resSeven10265.WarnMsg
  23499. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23500. res.Infcode = infocode
  23501. } else {
  23502. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23503. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23504. utils.ErrorLog("解析失败:%v", err)
  23505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23506. return
  23507. }
  23508. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23509. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23510. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23511. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23512. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23513. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23514. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23515. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23516. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23517. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23518. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23519. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23520. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23521. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23522. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23523. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23524. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23525. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23526. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23527. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23528. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23529. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23530. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23531. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23532. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23533. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23534. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23535. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23536. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23537. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23538. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23539. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23540. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23541. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23542. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23543. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23544. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23545. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23546. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23547. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23548. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23549. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23550. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23551. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23552. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23553. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23554. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23555. res.Cainfo = gzresSeven10265Two.Cainfo
  23556. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23557. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23558. //res.Infcode = infocode
  23559. } else {
  23560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23561. utils.ErrorLog("解析失败:%v", err)
  23562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23563. return
  23564. }
  23565. }
  23566. }
  23567. }
  23568. }
  23569. utils.ErrorLog("解析失败:%v", res.Infcode)
  23570. if res.Infcode == -1 {
  23571. errlog := &models.HisOrderError{
  23572. UserOrgId: adminUser.CurrentOrgId,
  23573. Ctime: time.Now().Unix(),
  23574. Mtime: time.Now().Unix(),
  23575. Number: chrg_bchno,
  23576. ErrMsg: res.ErrMsg,
  23577. Status: 1,
  23578. PatientId: id,
  23579. RecordTime: recordDateTime,
  23580. Stage: 20,
  23581. }
  23582. service.CreateErrMsgLog(errlog)
  23583. c.ServeSuccessJSON(map[string]interface{}{
  23584. "failed_code": -10,
  23585. "msg": res.ErrMsg,
  23586. })
  23587. return
  23588. }
  23589. if res.Infcode != 0 {
  23590. errlog := &models.HisOrderError{
  23591. UserOrgId: adminUser.CurrentOrgId,
  23592. Ctime: time.Now().Unix(),
  23593. Mtime: time.Now().Unix(),
  23594. Number: chrg_bchno,
  23595. ErrMsg: res.ErrMsg,
  23596. Status: 1,
  23597. PatientId: id,
  23598. RecordTime: recordDateTime,
  23599. Stage: 20,
  23600. }
  23601. service.CreateErrMsgLog(errlog)
  23602. c.ServeSuccessJSON(map[string]interface{}{
  23603. "failed_code": -10,
  23604. "msg": res.ErrMsg,
  23605. })
  23606. return
  23607. } else {
  23608. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23609. order.OrderStatus = 1
  23610. order.IsPre = 1
  23611. order.Status = 1
  23612. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23613. order.SetlId = res.Output.Setlinfo.SetlID
  23614. order.PsnNo = res.Output.Setlinfo.PsnNo
  23615. order.PsnName = res.Output.Setlinfo.PsnName
  23616. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23617. order.Certno = res.Output.Setlinfo.Certno
  23618. order.Gend = res.Output.Setlinfo.Gend
  23619. order.Naty = res.Output.Setlinfo.Naty
  23620. order.Age = res.Output.Setlinfo.Age
  23621. order.Insutype = res.Output.Setlinfo.Insutype
  23622. order.PsnType = res.Output.Setlinfo.PsnType
  23623. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23624. order.SetlTime = res.Output.Setlinfo.SetlTime
  23625. order.AcctUsedFlag = acct_used_flag
  23626. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23627. if res.Output.Setlinfo.MedType == "140101" {
  23628. order.MedType = "14"
  23629. } else {
  23630. if res.Output.Setlinfo.MedType == "110104" {
  23631. order.MedType = "11"
  23632. } else {
  23633. order.MedType = res.Output.Setlinfo.MedType
  23634. }
  23635. }
  23636. if res.Output.Setlinfo.MedType == "992102" {
  23637. order.MedType = "992102"
  23638. }
  23639. if res.Output.Setlinfo.MedType == "140104" {
  23640. order.MedType = "140104"
  23641. }
  23642. if res.Output.Setlinfo.MedType == "14" {
  23643. order.MedType = "14"
  23644. }
  23645. if reg_type == 1112 {
  23646. order.MedType = "1112"
  23647. }
  23648. if reg_type == 1111 {
  23649. order.MedType = "1111"
  23650. }
  23651. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23652. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23653. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23654. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23655. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23656. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23657. order.HifpPay = res.Output.Setlinfo.HifpPay
  23658. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23659. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23660. order.HifesPay = res.Output.Setlinfo.HifesPay
  23661. order.HifobPay = res.Output.Setlinfo.HifobPay
  23662. order.MafPay = res.Output.Setlinfo.MafPay
  23663. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23664. order.OthPay = res.Output.Setlinfo.OthPay
  23665. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23666. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23667. order.AcctPay = res.Output.Setlinfo.AcctPay
  23668. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23669. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23670. order.Balc = res.Output.Setlinfo.Balc
  23671. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23672. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23673. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23674. order.ClrWay = res.Output.Setlinfo.ClrWay
  23675. order.Creator = order.Creator
  23676. order.Modify = roles.AdminUserId
  23677. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23678. //detailStr := string(setlDetail)
  23679. //order.SetlDetail = detailStr
  23680. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23681. err = service.UpDateOrder(order)
  23682. if err == nil {
  23683. c.ServeSuccessJSON(map[string]interface{}{
  23684. "msg": "预结算成功",
  23685. })
  23686. } else {
  23687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23688. return
  23689. }
  23690. }
  23691. } else {
  23692. adminUser := c.GetAdminUserInfo()
  23693. errlog := &models.HisOrderError{
  23694. UserOrgId: adminUser.CurrentOrgId,
  23695. Ctime: time.Now().Unix(),
  23696. Mtime: time.Now().Unix(),
  23697. ErrMsg: res.ErrMsg,
  23698. Status: 1,
  23699. PatientId: id,
  23700. RecordTime: recordDateTime,
  23701. Stage: 4,
  23702. }
  23703. service.CreateErrMsgLog(errlog)
  23704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23705. return
  23706. }
  23707. } else {
  23708. if miConfig.MdtrtareaAdmvs == "150499" {
  23709. order := &models.HisOrder{
  23710. UserOrgId: adminUser.CurrentOrgId,
  23711. HisPatientId: his.ID,
  23712. PatientId: his.PatientId,
  23713. SettleAccountsDate: recordDateTime,
  23714. Ctime: time.Now().Unix(),
  23715. Mtime: time.Now().Unix(),
  23716. MdtrtId: his.Number,
  23717. PsnNo: his.PsnNo,
  23718. MedType: strconv.FormatInt(reg_type, 10),
  23719. Status: 1,
  23720. Number: chrg_bchno,
  23721. Infcode: res.Infcode,
  23722. WarnMsg: res.WarnMsg,
  23723. Cainfo: res.Cainfo,
  23724. ErrMsg: res.ErrMsg,
  23725. RespondTime: res.RefmsgTime,
  23726. InfRefmsgid: res.InfRefmsgid,
  23727. OrderStatus: 1,
  23728. IsMedicineInsurance: 1,
  23729. SettleType: settle_accounts_type,
  23730. SettleStartTime: start_time,
  23731. SettleEndTime: end_time,
  23732. Creator: roles.AdminUserId,
  23733. Modify: roles.AdminUserId,
  23734. PType: 2,
  23735. Diagnosis: diagnosis_id,
  23736. }
  23737. err = service.CreateOrder(order)
  23738. if err != nil {
  23739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23740. return
  23741. }
  23742. }
  23743. adminUser := c.GetAdminUserInfo()
  23744. errlog := &models.HisOrderError{
  23745. UserOrgId: adminUser.CurrentOrgId,
  23746. Ctime: time.Now().Unix(),
  23747. Mtime: time.Now().Unix(),
  23748. ErrMsg: res.ErrMsg,
  23749. Status: 1,
  23750. PatientId: id,
  23751. RecordTime: recordDateTime,
  23752. Stage: 4,
  23753. }
  23754. service.CreateErrMsgLog(errlog)
  23755. c.ServeSuccessJSON(map[string]interface{}{
  23756. "failed_code": -10,
  23757. "msg": res.ErrMsg,
  23758. })
  23759. return
  23760. }
  23761. }
  23762. }
  23763. }
  23764. // 退款
  23765. func (c *HisApiController) Refund() {
  23766. order_id, _ := c.GetInt64("order_id")
  23767. admin_user_id, _ := c.GetInt64("admin_user_id")
  23768. adminUser := c.GetAdminUserInfo()
  23769. var order models.HisOrder
  23770. order, _ = service.GetHisOrderByID(order_id)
  23771. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23772. if order.ID == 0 {
  23773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23774. return
  23775. }
  23776. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23777. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23778. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23779. if config.IsOpen == 1 { //对接了医保,走医保流程
  23780. var res ResultSixteen
  23781. var ahres ResultSevenAH
  23782. var resSixteen10265 ResultSixteen10265
  23783. var resSixteen10265Two ResultSixteen10265Two
  23784. var gz ResultgzSixteen10265Two
  23785. var src_resquest string
  23786. var result string
  23787. if miConfig.MdtrtareaAdmvs == "421300" {
  23788. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23789. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23790. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23791. resp3, requestErr3 := http.Get(api3)
  23792. if requestErr3 != nil {
  23793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23794. return
  23795. }
  23796. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23797. if ioErr3 != nil {
  23798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23800. return
  23801. }
  23802. var respJSON3 map[string]interface{}
  23803. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23806. return
  23807. }
  23808. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23809. userJSONBytes3, _ := json.Marshal(respJSON3)
  23810. fmt.Println("log")
  23811. fmt.Println(string(userJSONBytes3))
  23812. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23813. utils.ErrorLog("解析失败:%v", err)
  23814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23815. return
  23816. }
  23817. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23818. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23819. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23820. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23821. resp3, requestErr3 := http.Get(api3)
  23822. if requestErr3 != nil {
  23823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23824. return
  23825. }
  23826. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23827. if ioErr3 != nil {
  23828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23830. return
  23831. }
  23832. var respJSON3 map[string]interface{}
  23833. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23836. return
  23837. }
  23838. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23839. userJSONBytes3, _ := json.Marshal(respJSON3)
  23840. fmt.Println("log")
  23841. fmt.Println(string(userJSONBytes3))
  23842. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23843. utils.ErrorLog("解析失败:%v", err)
  23844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23845. return
  23846. }
  23847. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23848. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23849. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23851. resp3, requestErr3 := http.Get(api3)
  23852. if requestErr3 != nil {
  23853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23854. return
  23855. }
  23856. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23857. if ioErr3 != nil {
  23858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23860. return
  23861. }
  23862. var respJSON3 map[string]interface{}
  23863. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23866. return
  23867. }
  23868. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23869. userJSONBytes3, _ := json.Marshal(respJSON3)
  23870. fmt.Println("log")
  23871. fmt.Println(string(userJSONBytes3))
  23872. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23873. utils.ErrorLog("解析失败:%v", err)
  23874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23875. return
  23876. }
  23877. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23878. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23879. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23880. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23881. resp3, requestErr3 := http.Get(api3)
  23882. if requestErr3 != nil {
  23883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23884. return
  23885. }
  23886. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23887. if ioErr3 != nil {
  23888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23890. return
  23891. }
  23892. var respJSON3 map[string]interface{}
  23893. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23896. return
  23897. }
  23898. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23899. userJSONBytes3, _ := json.Marshal(respJSON3)
  23900. fmt.Println("log")
  23901. fmt.Println(string(userJSONBytes3))
  23902. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23903. utils.ErrorLog("解析失败:%v", err)
  23904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23905. return
  23906. }
  23907. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23908. var api3 string
  23909. if miConfig.MdtrtareaAdmvs == "320921" {
  23910. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23911. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23912. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23913. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23914. } else {
  23915. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23916. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23917. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23918. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23919. }
  23920. resp3, requestErr3 := http.Get(api3)
  23921. if requestErr3 != nil {
  23922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23923. return
  23924. }
  23925. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23926. if ioErr3 != nil {
  23927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23929. return
  23930. }
  23931. var respJSON3 map[string]interface{}
  23932. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23935. return
  23936. }
  23937. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23938. userJSONBytes3, _ := json.Marshal(respJSON3)
  23939. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23940. utils.ErrorLog("解析失败:%v", err)
  23941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23942. return
  23943. }
  23944. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23945. res.Output = resSixteen10265.Output
  23946. res.ErrMsg = resSixteen10265.ErrMsg
  23947. res.Cainfo = resSixteen10265.Cainfo
  23948. res.WarnMsg = resSixteen10265.WarnMsg
  23949. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23950. res.Infcode = infocode
  23951. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23952. var api3 string
  23953. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23954. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23955. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23956. resp3, requestErr3 := http.Get(api3)
  23957. if requestErr3 != nil {
  23958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23959. return
  23960. }
  23961. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23962. if ioErr3 != nil {
  23963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23965. return
  23966. }
  23967. var respJSON3 map[string]interface{}
  23968. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23971. return
  23972. }
  23973. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23974. userJSONBytes3, _ := json.Marshal(respJSON3)
  23975. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23976. utils.ErrorLog("解析失败:%v", err)
  23977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23978. return
  23979. }
  23980. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23981. res.Output = resSixteen10265.Output
  23982. res.ErrMsg = resSixteen10265.ErrMsg
  23983. res.Cainfo = resSixteen10265.Cainfo
  23984. res.WarnMsg = resSixteen10265.WarnMsg
  23985. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23986. res.Infcode = infocode
  23987. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23988. 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)
  23989. var dat map[string]interface{}
  23990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23991. fmt.Println(dat)
  23992. } else {
  23993. fmt.Println(err)
  23994. }
  23995. saveLog(result, src_resquest, "2208", "退费")
  23996. userJSONBytes, _ := json.Marshal(dat)
  23997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23998. utils.ErrorLog("解析失败:%v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24003. 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, "")
  24004. var dat map[string]interface{}
  24005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24006. fmt.Println(dat)
  24007. } else {
  24008. fmt.Println(err)
  24009. }
  24010. saveLog(result, src_resquest, "2208", "退费")
  24011. userJSONBytes, _ := json.Marshal(dat)
  24012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24013. utils.ErrorLog("解析失败:%v", err)
  24014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24015. return
  24016. }
  24017. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24018. var api3 string
  24019. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  24020. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24021. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24022. resp3, requestErr3 := http.Get(api3)
  24023. if requestErr3 != nil {
  24024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24025. return
  24026. }
  24027. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24028. if ioErr3 != nil {
  24029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24031. return
  24032. }
  24033. var respJSON3 map[string]interface{}
  24034. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24037. return
  24038. }
  24039. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24040. if status == "0" {
  24041. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24042. c.ServeSuccessJSON(map[string]interface{}{
  24043. "failed_code": -10,
  24044. "msg": err_msg,
  24045. })
  24046. return
  24047. }
  24048. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24049. userJSONBytes3, _ := json.Marshal(respJSON3)
  24050. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24051. // utils.ErrorLog("解析失败:%v", err)
  24052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24053. // return
  24054. //}
  24055. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  24056. utils.ErrorLog("解析失败:%v", err)
  24057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24058. return
  24059. }
  24060. res.InfRefmsgid = ahres.InfRefmsgid
  24061. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24062. // 创建对应的Time类型
  24063. t := time.UnixMilli(timestamp)
  24064. // 格式化成指定的日期字符串
  24065. str := t.Format("2006-01-02 15:04:05")
  24066. res.Output.Setlinfo.SetlTime = str
  24067. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24068. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24069. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24070. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24071. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24072. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24073. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24074. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24075. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24076. //
  24077. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24078. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24079. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24080. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24081. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24082. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24083. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24084. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24085. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24086. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24087. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24088. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24089. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24090. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24091. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24092. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24093. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24094. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24095. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24096. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24097. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24098. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24099. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24100. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24101. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24102. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24103. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24104. //res.Output.Setldetail = ahres.Output.Setldetail
  24105. res.ErrMsg = ahres.ErrMsg
  24106. res.Cainfo = ahres.Cainfo
  24107. res.WarnMsg = ahres.WarnMsg
  24108. res.Infcode = ahres.Infcode
  24109. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24110. 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, "")
  24111. var dat map[string]interface{}
  24112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24113. fmt.Println(dat)
  24114. } else {
  24115. fmt.Println(err)
  24116. }
  24117. saveLog(result, src_resquest, "2208", "退费")
  24118. userJSONBytes, _ := json.Marshal(dat)
  24119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24120. utils.ErrorLog("解析失败:%v", err)
  24121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24122. return
  24123. }
  24124. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24125. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  24126. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24127. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24128. resp3, requestErr3 := http.Get(api3)
  24129. if requestErr3 != nil {
  24130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24131. return
  24132. }
  24133. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24134. if ioErr3 != nil {
  24135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24137. return
  24138. }
  24139. var respJSON3 map[string]interface{}
  24140. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24143. return
  24144. }
  24145. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24146. userJSONBytes3, _ := json.Marshal(respJSON3)
  24147. fmt.Println("log")
  24148. fmt.Println(string(userJSONBytes3))
  24149. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24150. utils.ErrorLog("解析失败:%v", err)
  24151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24152. return
  24153. }
  24154. } else {
  24155. if miConfig.Code == "H15049901371" {
  24156. 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)
  24157. var dat map[string]interface{}
  24158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24159. fmt.Println(dat)
  24160. } else {
  24161. fmt.Println(err)
  24162. }
  24163. saveLog(result, src_resquest, "2208", "退费")
  24164. userJSONBytes, _ := json.Marshal(dat)
  24165. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  24166. utils.ErrorLog("解析失败:%v", err)
  24167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24168. return
  24169. }
  24170. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24171. res.Output = resSixteen10265.Output
  24172. res.ErrMsg = resSixteen10265.ErrMsg
  24173. res.Cainfo = resSixteen10265.Cainfo
  24174. res.WarnMsg = resSixteen10265.WarnMsg
  24175. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24176. res.Infcode = infocode
  24177. } else {
  24178. 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)
  24179. var dat map[string]interface{}
  24180. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24181. fmt.Println(dat)
  24182. } else {
  24183. fmt.Println(err)
  24184. }
  24185. saveLog(result, src_resquest, "2208", "退费")
  24186. userJSONBytes, _ := json.Marshal(dat)
  24187. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24188. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24189. utils.ErrorLog("解析失败:%v", err)
  24190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24191. return
  24192. }
  24193. res.Infcode = gz.Infcode
  24194. } else {
  24195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24196. utils.ErrorLog("解析失败:%v", err)
  24197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24198. return
  24199. }
  24200. }
  24201. }
  24202. }
  24203. if res.Infcode == 0 {
  24204. var res2 ResultSix
  24205. var resSix10265 ResultSix10265
  24206. if miConfig.MdtrtareaAdmvs == "421300" {
  24207. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24208. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24209. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24210. resp3, requestErr3 := http.Get(api3)
  24211. if requestErr3 != nil {
  24212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24213. return
  24214. }
  24215. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24216. if ioErr3 != nil {
  24217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24219. return
  24220. }
  24221. var respJSON3 map[string]interface{}
  24222. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24225. return
  24226. }
  24227. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24228. userJSONBytes3, _ := json.Marshal(respJSON3)
  24229. fmt.Println("log")
  24230. fmt.Println(string(userJSONBytes3))
  24231. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24232. utils.ErrorLog("解析失败:%v", err)
  24233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24234. return
  24235. }
  24236. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24237. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24238. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24239. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24240. resp3, requestErr3 := http.Get(api3)
  24241. if requestErr3 != nil {
  24242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24243. return
  24244. }
  24245. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24246. if ioErr3 != nil {
  24247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24249. return
  24250. }
  24251. var respJSON3 map[string]interface{}
  24252. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24255. return
  24256. }
  24257. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24258. userJSONBytes3, _ := json.Marshal(respJSON3)
  24259. fmt.Println("log")
  24260. fmt.Println(string(userJSONBytes3))
  24261. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24262. utils.ErrorLog("解析失败:%v", err)
  24263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24264. return
  24265. }
  24266. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24267. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24268. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24269. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24270. resp3, requestErr3 := http.Get(api3)
  24271. if requestErr3 != nil {
  24272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24273. return
  24274. }
  24275. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24276. if ioErr3 != nil {
  24277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24279. return
  24280. }
  24281. var respJSON3 map[string]interface{}
  24282. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24285. return
  24286. }
  24287. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24288. userJSONBytes3, _ := json.Marshal(respJSON3)
  24289. fmt.Println("log")
  24290. fmt.Println(string(userJSONBytes3))
  24291. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24292. utils.ErrorLog("解析失败:%v", err)
  24293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24294. return
  24295. }
  24296. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24297. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24298. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24299. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24300. resp3, requestErr3 := http.Get(api3)
  24301. if requestErr3 != nil {
  24302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24303. return
  24304. }
  24305. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24306. if ioErr3 != nil {
  24307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24309. return
  24310. }
  24311. var respJSON3 map[string]interface{}
  24312. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24315. return
  24316. }
  24317. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24318. userJSONBytes3, _ := json.Marshal(respJSON3)
  24319. fmt.Println("log")
  24320. fmt.Println(string(userJSONBytes3))
  24321. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24322. utils.ErrorLog("解析失败:%v", err)
  24323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24324. return
  24325. }
  24326. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24327. var api3 string
  24328. if miConfig.MdtrtareaAdmvs == "320921" {
  24329. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24330. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24331. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24332. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24333. } else {
  24334. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24335. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24336. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24337. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24338. }
  24339. resp3, requestErr3 := http.Get(api3)
  24340. if requestErr3 != nil {
  24341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24342. return
  24343. }
  24344. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24345. if ioErr3 != nil {
  24346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24348. return
  24349. }
  24350. var respJSON3 map[string]interface{}
  24351. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24354. return
  24355. }
  24356. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24357. userJSONBytes3, _ := json.Marshal(respJSON3)
  24358. fmt.Println("log")
  24359. fmt.Println(string(userJSONBytes3))
  24360. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24361. utils.ErrorLog("解析失败:%v", err)
  24362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24363. return
  24364. }
  24365. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24366. res2.Output = resSix10265.Output
  24367. res2.ErrMsg = resSix10265.ErrMsg
  24368. res2.Cainfo = resSix10265.Cainfo
  24369. res2.WarnMsg = resSix10265.WarnMsg
  24370. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24371. res2.Infcode = infocode
  24372. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24373. var api3 string
  24374. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24375. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24376. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24377. resp3, requestErr3 := http.Get(api3)
  24378. if requestErr3 != nil {
  24379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24380. return
  24381. }
  24382. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24383. if ioErr3 != nil {
  24384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24386. return
  24387. }
  24388. var respJSON3 map[string]interface{}
  24389. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24392. return
  24393. }
  24394. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24395. userJSONBytes3, _ := json.Marshal(respJSON3)
  24396. fmt.Println("log")
  24397. fmt.Println(string(userJSONBytes3))
  24398. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24399. utils.ErrorLog("解析失败:%v", err)
  24400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24401. return
  24402. }
  24403. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24404. res2.Output = resSix10265.Output
  24405. res2.ErrMsg = resSix10265.ErrMsg
  24406. res2.Cainfo = resSix10265.Cainfo
  24407. res2.WarnMsg = resSix10265.WarnMsg
  24408. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24409. res2.Infcode = infocode
  24410. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24411. 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)
  24412. var dat map[string]interface{}
  24413. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24414. fmt.Println(dat)
  24415. } else {
  24416. fmt.Println(err)
  24417. }
  24418. saveLog(result2, src_request, "2205", "撤销明细")
  24419. userJSONBytes, _ := json.Marshal(dat)
  24420. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24421. utils.ErrorLog("解析失败:%v", err)
  24422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24423. return
  24424. }
  24425. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24426. 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, "")
  24427. var dat map[string]interface{}
  24428. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24429. fmt.Println(dat)
  24430. } else {
  24431. fmt.Println(err)
  24432. }
  24433. saveLog(result2, src_request, "2205", "撤销明细")
  24434. userJSONBytes, _ := json.Marshal(dat)
  24435. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24436. utils.ErrorLog("解析失败:%v", err)
  24437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24438. return
  24439. }
  24440. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24441. var api3 string
  24442. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24443. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24444. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24445. resp3, requestErr3 := http.Get(api3)
  24446. if requestErr3 != nil {
  24447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24448. return
  24449. }
  24450. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24451. if ioErr3 != nil {
  24452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24454. return
  24455. }
  24456. var respJSON3 map[string]interface{}
  24457. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24460. return
  24461. }
  24462. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24463. if status == "0" {
  24464. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24465. c.ServeSuccessJSON(map[string]interface{}{
  24466. "failed_code": -10,
  24467. "msg": err_msg,
  24468. })
  24469. return
  24470. }
  24471. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24472. userJSONBytes3, _ := json.Marshal(respJSON3)
  24473. fmt.Println("log")
  24474. fmt.Println(string(userJSONBytes3))
  24475. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24476. utils.ErrorLog("解析失败:%v", err)
  24477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24478. return
  24479. }
  24480. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24481. 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, "")
  24482. var dat map[string]interface{}
  24483. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24484. fmt.Println(dat)
  24485. } else {
  24486. fmt.Println(err)
  24487. }
  24488. saveLog(result2, src_request, "2205", "撤销明细")
  24489. userJSONBytes, _ := json.Marshal(dat)
  24490. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24491. utils.ErrorLog("解析失败:%v", err)
  24492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24493. return
  24494. }
  24495. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24496. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24497. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24498. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24499. resp3, requestErr3 := http.Get(api3)
  24500. if requestErr3 != nil {
  24501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24502. return
  24503. }
  24504. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24505. if ioErr3 != nil {
  24506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24508. return
  24509. }
  24510. var respJSON3 map[string]interface{}
  24511. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24514. return
  24515. }
  24516. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24517. userJSONBytes3, _ := json.Marshal(respJSON3)
  24518. fmt.Println("log")
  24519. fmt.Println(string(userJSONBytes3))
  24520. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24521. utils.ErrorLog("解析失败:%v", err)
  24522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24523. return
  24524. }
  24525. } else {
  24526. if miConfig.Code == "H15049901371" {
  24527. 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)
  24528. var dat map[string]interface{}
  24529. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24530. fmt.Println(dat)
  24531. } else {
  24532. fmt.Println(err)
  24533. }
  24534. saveLog(result2, src_request, "2205", "撤销明细")
  24535. userJSONBytes, _ := json.Marshal(dat)
  24536. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24537. utils.ErrorLog("解析失败:%v", err)
  24538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24539. return
  24540. }
  24541. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24542. res2.Output = resSix10265.Output
  24543. res2.ErrMsg = resSix10265.ErrMsg
  24544. res2.Cainfo = resSix10265.Cainfo
  24545. res2.WarnMsg = resSix10265.WarnMsg
  24546. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24547. res2.Infcode = infocode
  24548. } else {
  24549. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24550. res2.Infcode = 0
  24551. } else {
  24552. 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)
  24553. var dat map[string]interface{}
  24554. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24555. fmt.Println(dat)
  24556. } else {
  24557. fmt.Println(err)
  24558. }
  24559. saveLog(result2, src_request, "2205", "撤销明细")
  24560. userJSONBytes, _ := json.Marshal(dat)
  24561. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24562. utils.ErrorLog("解析失败:%v", err)
  24563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24564. return
  24565. }
  24566. }
  24567. }
  24568. }
  24569. if res2.Infcode == -1 {
  24570. c.ServeSuccessJSON(map[string]interface{}{
  24571. "failed_code": -10,
  24572. "msg": res2.ErrMsg,
  24573. })
  24574. return
  24575. }
  24576. if res2.Infcode == 0 {
  24577. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24578. if err == nil {
  24579. //当押金不为零时产生退费记录
  24580. if order.Decimal != 0 {
  24581. tmp := strconv.FormatInt(order.ID, 10)
  24582. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24583. if err != nil {
  24584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24585. return
  24586. }
  24587. }
  24588. c.ServeSuccessJSON(map[string]interface{}{
  24589. "msg": "退费成功",
  24590. })
  24591. } else {
  24592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24593. return
  24594. }
  24595. } else {
  24596. c.ServeSuccessJSON(map[string]interface{}{
  24597. "failed_code": -10,
  24598. "msg": res2.ErrMsg,
  24599. })
  24600. }
  24601. } else {
  24602. c.ServeSuccessJSON(map[string]interface{}{
  24603. "failed_code": -10,
  24604. "msg": res.ErrMsg,
  24605. })
  24606. }
  24607. }
  24608. }
  24609. func (c *HisApiController) RefundNumber() {
  24610. record_time := c.GetString("record_time")
  24611. //patient_id, _ := c.GetInt64("patient_id")
  24612. admin_user_id, _ := c.GetInt64("admin_user_id")
  24613. his_patient_id, _ := c.GetInt64("id")
  24614. timeLayout := "2006-01-02"
  24615. loc, _ := time.LoadLocation("Local")
  24616. adminUser := c.GetAdminUserInfo()
  24617. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24618. fmt.Println(err)
  24619. if err != nil {
  24620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24621. return
  24622. }
  24623. recordDateTime := theTime.Unix()
  24624. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24625. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24626. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24627. //order, _ := service.GetHisOrderByID(order_id)
  24628. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24629. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24630. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24631. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24632. if count > 0 {
  24633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24634. return
  24635. }
  24636. if config.IsOpen == 1 { //对接了医保,走医保流程
  24637. var res2 ResultSix
  24638. var res3 GZResultSix
  24639. var resSix10265 ResultSix10265
  24640. if miConfig.MdtrtareaAdmvs == "421300" {
  24641. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24642. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24643. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24644. resp3, requestErr3 := http.Get(api3)
  24645. if requestErr3 != nil {
  24646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24647. return
  24648. }
  24649. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24650. if ioErr3 != nil {
  24651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24653. return
  24654. }
  24655. var respJSON3 map[string]interface{}
  24656. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24659. return
  24660. }
  24661. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24662. userJSONBytes3, _ := json.Marshal(respJSON3)
  24663. fmt.Println("log")
  24664. fmt.Println(string(userJSONBytes3))
  24665. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24666. utils.ErrorLog("解析失败:%v", err)
  24667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24668. return
  24669. }
  24670. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24671. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24672. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24674. resp3, requestErr3 := http.Get(api3)
  24675. if requestErr3 != nil {
  24676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24677. return
  24678. }
  24679. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24680. if ioErr3 != nil {
  24681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24683. return
  24684. }
  24685. var respJSON3 map[string]interface{}
  24686. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24689. return
  24690. }
  24691. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24692. userJSONBytes3, _ := json.Marshal(respJSON3)
  24693. fmt.Println("log")
  24694. fmt.Println(string(userJSONBytes3))
  24695. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24696. utils.ErrorLog("解析失败:%v", err)
  24697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24698. return
  24699. }
  24700. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24701. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24702. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24703. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24704. resp3, requestErr3 := http.Get(api3)
  24705. if requestErr3 != nil {
  24706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24707. return
  24708. }
  24709. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24710. if ioErr3 != nil {
  24711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24713. return
  24714. }
  24715. var respJSON3 map[string]interface{}
  24716. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24719. return
  24720. }
  24721. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24722. userJSONBytes3, _ := json.Marshal(respJSON3)
  24723. fmt.Println("log")
  24724. fmt.Println(string(userJSONBytes3))
  24725. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24726. utils.ErrorLog("解析失败:%v", err)
  24727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24728. return
  24729. }
  24730. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24731. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24732. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24734. resp3, requestErr3 := http.Get(api3)
  24735. if requestErr3 != nil {
  24736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24737. return
  24738. }
  24739. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24740. if ioErr3 != nil {
  24741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24743. return
  24744. }
  24745. var respJSON3 map[string]interface{}
  24746. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24749. return
  24750. }
  24751. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24752. userJSONBytes3, _ := json.Marshal(respJSON3)
  24753. fmt.Println("log")
  24754. fmt.Println(string(userJSONBytes3))
  24755. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24756. utils.ErrorLog("解析失败:%v", err)
  24757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24758. return
  24759. }
  24760. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24761. var api3 string
  24762. if miConfig.MdtrtareaAdmvs == "320921" {
  24763. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24764. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24765. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24766. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24767. } else {
  24768. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24769. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24770. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24771. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24772. }
  24773. resp3, requestErr3 := http.Get(api3)
  24774. if requestErr3 != nil {
  24775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24776. return
  24777. }
  24778. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24779. if ioErr3 != nil {
  24780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24782. return
  24783. }
  24784. var respJSON3 map[string]interface{}
  24785. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24788. return
  24789. }
  24790. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24791. userJSONBytes3, _ := json.Marshal(respJSON3)
  24792. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24793. utils.ErrorLog("解析失败:%v", err)
  24794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24795. return
  24796. }
  24797. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24798. res2.Output = resSix10265.Output
  24799. res2.ErrMsg = resSix10265.ErrMsg
  24800. res2.Cainfo = resSix10265.Cainfo
  24801. res2.WarnMsg = resSix10265.WarnMsg
  24802. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24803. res2.Infcode = infocode
  24804. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24805. var api3 string
  24806. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24807. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24808. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24809. resp3, requestErr3 := http.Get(api3)
  24810. if requestErr3 != nil {
  24811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24812. return
  24813. }
  24814. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24815. if ioErr3 != nil {
  24816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24818. return
  24819. }
  24820. var respJSON3 map[string]interface{}
  24821. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24824. return
  24825. }
  24826. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24827. userJSONBytes3, _ := json.Marshal(respJSON3)
  24828. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24829. utils.ErrorLog("解析失败:%v", err)
  24830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24831. return
  24832. }
  24833. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24834. res2.Output = resSix10265.Output
  24835. res2.ErrMsg = resSix10265.ErrMsg
  24836. res2.Cainfo = resSix10265.Cainfo
  24837. res2.WarnMsg = resSix10265.WarnMsg
  24838. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24839. res2.Infcode = infocode
  24840. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24841. 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)
  24842. var dat map[string]interface{}
  24843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24844. fmt.Println(dat)
  24845. } else {
  24846. fmt.Println(err)
  24847. }
  24848. saveLog(result, request, "2202", "退号")
  24849. userJSONBytes, _ := json.Marshal(dat)
  24850. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24851. utils.ErrorLog("解析失败:%v", err)
  24852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24853. return
  24854. }
  24855. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24856. 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, "")
  24857. var dat map[string]interface{}
  24858. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24859. fmt.Println(dat)
  24860. } else {
  24861. fmt.Println(err)
  24862. }
  24863. saveLog(result, request, "2202", "退号")
  24864. userJSONBytes, _ := json.Marshal(dat)
  24865. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24866. utils.ErrorLog("解析失败:%v", err)
  24867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24868. return
  24869. }
  24870. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24871. var api3 string
  24872. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  24873. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24874. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24875. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24876. resp3, requestErr3 := http.Get(api3)
  24877. if requestErr3 != nil {
  24878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24879. return
  24880. }
  24881. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24882. if ioErr3 != nil {
  24883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24885. return
  24886. }
  24887. var respJSON3 map[string]interface{}
  24888. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24891. return
  24892. }
  24893. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24894. if status == "0" {
  24895. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24896. c.ServeSuccessJSON(map[string]interface{}{
  24897. "failed_code": -10,
  24898. "msg": err_msg,
  24899. })
  24900. return
  24901. }
  24902. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24903. userJSONBytes3, _ := json.Marshal(respJSON3)
  24904. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24905. utils.ErrorLog("解析失败:%v", err)
  24906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24907. return
  24908. }
  24909. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  24910. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24911. 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, "")
  24912. var dat map[string]interface{}
  24913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24914. fmt.Println(dat)
  24915. } else {
  24916. fmt.Println(err)
  24917. }
  24918. saveLog(result, request, "2202", "退号")
  24919. userJSONBytes, _ := json.Marshal(dat)
  24920. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24921. utils.ErrorLog("解析失败:%v", err)
  24922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24923. return
  24924. }
  24925. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24926. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  24927. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24928. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24929. resp3, requestErr3 := http.Get(api3)
  24930. if requestErr3 != nil {
  24931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24932. return
  24933. }
  24934. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24935. if ioErr3 != nil {
  24936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24938. return
  24939. }
  24940. var respJSON3 map[string]interface{}
  24941. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24944. return
  24945. }
  24946. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24947. userJSONBytes3, _ := json.Marshal(respJSON3)
  24948. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24949. utils.ErrorLog("解析失败:%v", err)
  24950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24951. return
  24952. }
  24953. } else {
  24954. var api3 string
  24955. if miConfig.Code == "H15049901371" {
  24956. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  24957. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24958. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24959. } else {
  24960. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  24961. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24963. }
  24964. resp3, requestErr3 := http.Get(api3)
  24965. if requestErr3 != nil {
  24966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24967. return
  24968. }
  24969. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24970. if ioErr3 != nil {
  24971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24973. return
  24974. }
  24975. var respJSON3 map[string]interface{}
  24976. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24979. return
  24980. }
  24981. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24982. userJSONBytes3, _ := json.Marshal(respJSON3)
  24983. if miConfig.Code == "H15049901371" {
  24984. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24985. utils.ErrorLog("解析失败:%v", err)
  24986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24987. return
  24988. }
  24989. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24990. res2.Output = resSix10265.Output
  24991. res2.ErrMsg = resSix10265.ErrMsg
  24992. res2.Cainfo = resSix10265.Cainfo
  24993. res2.WarnMsg = resSix10265.WarnMsg
  24994. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24995. res2.Infcode = infocode
  24996. } else {
  24997. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24998. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24999. utils.ErrorLog("解析失败:%v", err)
  25000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25001. return
  25002. }
  25003. res2.Infcode = res3.Infcode
  25004. } else {
  25005. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25006. utils.ErrorLog("解析失败:%v", err)
  25007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25008. return
  25009. }
  25010. }
  25011. }
  25012. }
  25013. if res2.Infcode == -1 {
  25014. utils.ErrorLog("解析失败:%v", res2.Infcode)
  25015. c.ServeSuccessJSON(map[string]interface{}{
  25016. "failed_code": -10,
  25017. "msg": res2.ErrMsg,
  25018. })
  25019. return
  25020. }
  25021. if res2.Infcode == 0 {
  25022. if err == nil {
  25023. c.ServeSuccessJSON(map[string]interface{}{
  25024. "msg": "退号成功",
  25025. })
  25026. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  25027. } else {
  25028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25029. return
  25030. }
  25031. }
  25032. } else {
  25033. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  25034. //if err == nil {
  25035. // c.ServeSuccessJSON(map[string]interface{}{
  25036. // "msg": "退费成功",
  25037. // })
  25038. //} else {
  25039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25040. // return
  25041. //}
  25042. }
  25043. }
  25044. func (c *HisApiController) RefundDetail() {
  25045. order_id, _ := c.GetInt64("order_id")
  25046. admin_user_id, _ := c.GetInt64("admin_user_id")
  25047. //his_patient_id, _ := c.GetInt64("his_patient_id")
  25048. number := c.GetString("number")
  25049. record_time := c.GetString("record_time")
  25050. patient_id, _ := c.GetInt64("patient_id")
  25051. //med_type, _ := c.GetInt64("med_type")
  25052. timeLayout := "2006-01-02"
  25053. loc, _ := time.LoadLocation("Local")
  25054. adminUser := c.GetAdminUserInfo()
  25055. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25056. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25057. fmt.Println(err)
  25058. if err != nil {
  25059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25060. return
  25061. }
  25062. recordDateTime := theTime.Unix()
  25063. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25064. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25065. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25066. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25067. var order models.HisOrder
  25068. order, _ = service.GetHisOrderByID(order_id)
  25069. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25070. if config.IsOpen == 1 { //对接了医保,走医保流程
  25071. var res2 ResultSix
  25072. if miConfig.MdtrtareaAdmvs == "421300" {
  25073. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25074. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25075. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25076. resp3, requestErr3 := http.Get(api3)
  25077. if requestErr3 != nil {
  25078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25079. return
  25080. }
  25081. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25082. if ioErr3 != nil {
  25083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25085. return
  25086. }
  25087. var respJSON3 map[string]interface{}
  25088. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25091. return
  25092. }
  25093. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25094. userJSONBytes3, _ := json.Marshal(respJSON3)
  25095. fmt.Println("log")
  25096. fmt.Println(string(userJSONBytes3))
  25097. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25098. utils.ErrorLog("解析失败:%v", err)
  25099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25100. return
  25101. }
  25102. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25103. if err == nil {
  25104. c.ServeSuccessJSON(map[string]interface{}{
  25105. "msg": "撤销明细成功",
  25106. })
  25107. return
  25108. } else {
  25109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25110. return
  25111. }
  25112. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25113. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25114. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25115. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25116. resp3, requestErr3 := http.Get(api3)
  25117. if requestErr3 != nil {
  25118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25119. return
  25120. }
  25121. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25122. if ioErr3 != nil {
  25123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25125. return
  25126. }
  25127. var respJSON3 map[string]interface{}
  25128. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25131. return
  25132. }
  25133. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25134. userJSONBytes3, _ := json.Marshal(respJSON3)
  25135. fmt.Println("log")
  25136. fmt.Println(string(userJSONBytes3))
  25137. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25138. utils.ErrorLog("解析失败:%v", err)
  25139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25140. return
  25141. }
  25142. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25143. if err == nil {
  25144. c.ServeSuccessJSON(map[string]interface{}{
  25145. "msg": "撤销明细成功",
  25146. })
  25147. return
  25148. } else {
  25149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25150. return
  25151. }
  25152. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25153. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25154. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25155. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25156. resp3, requestErr3 := http.Get(api3)
  25157. if requestErr3 != nil {
  25158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25159. return
  25160. }
  25161. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25162. if ioErr3 != nil {
  25163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25165. return
  25166. }
  25167. var respJSON3 map[string]interface{}
  25168. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25174. userJSONBytes3, _ := json.Marshal(respJSON3)
  25175. fmt.Println("log")
  25176. fmt.Println(string(userJSONBytes3))
  25177. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25178. utils.ErrorLog("解析失败:%v", err)
  25179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25180. return
  25181. }
  25182. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25183. if err == nil {
  25184. c.ServeSuccessJSON(map[string]interface{}{
  25185. "msg": "撤销明细成功",
  25186. })
  25187. return
  25188. } else {
  25189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25190. return
  25191. }
  25192. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25193. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25194. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25195. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25196. resp3, requestErr3 := http.Get(api3)
  25197. if requestErr3 != nil {
  25198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25199. return
  25200. }
  25201. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25202. if ioErr3 != nil {
  25203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25205. return
  25206. }
  25207. var respJSON3 map[string]interface{}
  25208. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25211. return
  25212. }
  25213. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25214. userJSONBytes3, _ := json.Marshal(respJSON3)
  25215. fmt.Println("log")
  25216. fmt.Println(string(userJSONBytes3))
  25217. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25218. utils.ErrorLog("解析失败:%v", err)
  25219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25220. return
  25221. }
  25222. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25223. if err == nil {
  25224. c.ServeSuccessJSON(map[string]interface{}{
  25225. "msg": "撤销明细成功",
  25226. })
  25227. return
  25228. } else {
  25229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25230. return
  25231. }
  25232. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25233. var resSix10265 ResultSix10265
  25234. var api3 string
  25235. if miConfig.MdtrtareaAdmvs == "320921" {
  25236. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25237. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25239. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25240. } else {
  25241. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25242. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25243. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25244. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25245. }
  25246. resp3, requestErr3 := http.Get(api3)
  25247. utils.ErrorLog("接口: %v", requestErr3)
  25248. if requestErr3 != nil {
  25249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25250. return
  25251. }
  25252. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25253. if ioErr3 != nil {
  25254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25256. return
  25257. }
  25258. var respJSON3 map[string]interface{}
  25259. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25262. return
  25263. }
  25264. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25265. userJSONBytes3, _ := json.Marshal(respJSON3)
  25266. fmt.Println("log")
  25267. fmt.Println(string(userJSONBytes3))
  25268. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25269. utils.ErrorLog("解析失败:%v", err)
  25270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25271. return
  25272. }
  25273. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25274. res2.Output = resSix10265.Output
  25275. res2.ErrMsg = resSix10265.ErrMsg
  25276. res2.Cainfo = resSix10265.Cainfo
  25277. res2.WarnMsg = resSix10265.WarnMsg
  25278. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25279. res2.Infcode = infocode
  25280. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25281. if err == nil {
  25282. c.ServeSuccessJSON(map[string]interface{}{
  25283. "msg": "撤销明细成功",
  25284. })
  25285. return
  25286. } else {
  25287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25288. return
  25289. }
  25290. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25291. var api3 string
  25292. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25293. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25294. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25295. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25296. resp3, requestErr3 := http.Get(api3)
  25297. utils.ErrorLog("接口: %v", requestErr3)
  25298. if requestErr3 != nil {
  25299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25300. return
  25301. }
  25302. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25303. if ioErr3 != nil {
  25304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25306. return
  25307. }
  25308. var respJSON3 map[string]interface{}
  25309. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25312. return
  25313. }
  25314. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25315. if status == "0" {
  25316. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25317. c.ServeSuccessJSON(map[string]interface{}{
  25318. "failed_code": -10,
  25319. "msg": err_msg,
  25320. })
  25321. return
  25322. }
  25323. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25324. userJSONBytes3, _ := json.Marshal(respJSON3)
  25325. fmt.Println("log")
  25326. fmt.Println(string(userJSONBytes3))
  25327. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25328. utils.ErrorLog("解析失败:%v", err)
  25329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25330. return
  25331. }
  25332. fmt.Println(res2.Infcode)
  25333. if res2.Infcode == -1 {
  25334. c.ServeSuccessJSON(map[string]interface{}{
  25335. "failed_code": -10,
  25336. "msg": res2.ErrMsg,
  25337. })
  25338. return
  25339. }
  25340. if res2.Infcode == 0 {
  25341. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25342. if err == nil {
  25343. c.ServeSuccessJSON(map[string]interface{}{
  25344. "msg": "撤销明细成功",
  25345. })
  25346. return
  25347. } else {
  25348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25349. return
  25350. }
  25351. } else {
  25352. c.ServeSuccessJSON(map[string]interface{}{
  25353. "failed_code": -10,
  25354. "msg": res2.ErrMsg,
  25355. })
  25356. }
  25357. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25358. if err == nil {
  25359. c.ServeSuccessJSON(map[string]interface{}{
  25360. "msg": "撤销明细成功",
  25361. })
  25362. return
  25363. } else {
  25364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25365. return
  25366. }
  25367. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25368. var resSix10265 ResultSix10265
  25369. var api3 string
  25370. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25371. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25372. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25373. resp3, requestErr3 := http.Get(api3)
  25374. if requestErr3 != nil {
  25375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25376. return
  25377. }
  25378. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25379. if ioErr3 != nil {
  25380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25382. return
  25383. }
  25384. var respJSON3 map[string]interface{}
  25385. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25388. return
  25389. }
  25390. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25391. userJSONBytes3, _ := json.Marshal(respJSON3)
  25392. fmt.Println("log")
  25393. fmt.Println(string(userJSONBytes3))
  25394. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25395. utils.ErrorLog("解析失败:%v", err)
  25396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25397. return
  25398. }
  25399. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25400. res2.Output = resSix10265.Output
  25401. res2.ErrMsg = resSix10265.ErrMsg
  25402. res2.Cainfo = resSix10265.Cainfo
  25403. res2.WarnMsg = resSix10265.WarnMsg
  25404. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25405. res2.Infcode = infocode
  25406. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25407. if err == nil {
  25408. c.ServeSuccessJSON(map[string]interface{}{
  25409. "msg": "撤销明细成功",
  25410. })
  25411. return
  25412. } else {
  25413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25414. return
  25415. }
  25416. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25417. 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)
  25418. var dat map[string]interface{}
  25419. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25420. fmt.Println(dat)
  25421. } else {
  25422. fmt.Println(err)
  25423. }
  25424. saveLog(result2, src_request, "2205", "撤销明细")
  25425. userJSONBytes, _ := json.Marshal(dat)
  25426. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25427. utils.ErrorLog("解析失败:%v", err)
  25428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25429. return
  25430. }
  25431. if res2.Infcode == 0 {
  25432. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25433. if err == nil {
  25434. c.ServeSuccessJSON(map[string]interface{}{
  25435. "msg": "撤销明细成功",
  25436. })
  25437. return
  25438. } else {
  25439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25440. return
  25441. }
  25442. } else {
  25443. c.ServeSuccessJSON(map[string]interface{}{
  25444. "failed_code": -10,
  25445. "msg": res2.ErrMsg,
  25446. })
  25447. }
  25448. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25449. 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, "")
  25450. var dat map[string]interface{}
  25451. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25452. fmt.Println(dat)
  25453. } else {
  25454. fmt.Println(err)
  25455. }
  25456. saveLog(result2, src_request, "2205", "撤销明细")
  25457. userJSONBytes, _ := json.Marshal(dat)
  25458. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25459. utils.ErrorLog("解析失败:%v", err)
  25460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25461. return
  25462. }
  25463. if res2.Infcode == 0 {
  25464. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25465. if err == nil {
  25466. c.ServeSuccessJSON(map[string]interface{}{
  25467. "msg": "撤销明细成功",
  25468. })
  25469. return
  25470. } else {
  25471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25472. return
  25473. }
  25474. } else {
  25475. c.ServeSuccessJSON(map[string]interface{}{
  25476. "failed_code": -10,
  25477. "msg": res2.ErrMsg,
  25478. })
  25479. }
  25480. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25481. 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, "")
  25482. var dat map[string]interface{}
  25483. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25484. fmt.Println(dat)
  25485. } else {
  25486. fmt.Println(err)
  25487. }
  25488. saveLog(result2, src_request, "2205", "撤销明细")
  25489. userJSONBytes, _ := json.Marshal(dat)
  25490. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25491. utils.ErrorLog("解析失败:%v", err)
  25492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25493. return
  25494. }
  25495. if res2.Infcode == 0 {
  25496. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25497. if err == nil {
  25498. c.ServeSuccessJSON(map[string]interface{}{
  25499. "msg": "撤销明细成功",
  25500. })
  25501. return
  25502. } else {
  25503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25504. return
  25505. }
  25506. } else {
  25507. c.ServeSuccessJSON(map[string]interface{}{
  25508. "failed_code": -10,
  25509. "msg": res2.ErrMsg,
  25510. })
  25511. }
  25512. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25513. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25514. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25516. resp2, requestErr2 := http.Get(api2)
  25517. if requestErr2 != nil {
  25518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25519. return
  25520. }
  25521. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25522. if ioErr2 != nil {
  25523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25525. return
  25526. }
  25527. var respJSON2 map[string]interface{}
  25528. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25531. return
  25532. }
  25533. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25534. userJSONBytes3, _ := json.Marshal(respJSON2)
  25535. fmt.Println("log")
  25536. fmt.Println(string(userJSONBytes3))
  25537. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25538. utils.ErrorLog("解析失败:%v", err)
  25539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25540. return
  25541. }
  25542. if res2.Infcode == 0 {
  25543. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25544. if err == nil {
  25545. c.ServeSuccessJSON(map[string]interface{}{
  25546. "msg": "撤销明细成功",
  25547. })
  25548. return
  25549. } else {
  25550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25551. return
  25552. }
  25553. } else {
  25554. c.ServeSuccessJSON(map[string]interface{}{
  25555. "failed_code": -10,
  25556. "msg": res2.ErrMsg,
  25557. })
  25558. }
  25559. } else {
  25560. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25561. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25562. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25563. resp2, requestErr2 := http.Get(api2)
  25564. if requestErr2 != nil {
  25565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25566. return
  25567. }
  25568. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25569. if ioErr2 != nil {
  25570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25572. return
  25573. }
  25574. var respJSON2 map[string]interface{}
  25575. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25578. return
  25579. }
  25580. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25581. if err == nil {
  25582. c.ServeSuccessJSON(map[string]interface{}{
  25583. "msg": "撤销明细成功",
  25584. })
  25585. return
  25586. } else {
  25587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25588. return
  25589. }
  25590. }
  25591. } else {
  25592. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25593. if err == nil {
  25594. c.ServeSuccessJSON(map[string]interface{}{
  25595. "msg": "退费成功",
  25596. })
  25597. } else {
  25598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25599. return
  25600. }
  25601. }
  25602. }
  25603. // 对账
  25604. func (c *HisApiController) GetCheckAccount() {
  25605. start_time := c.GetString("start_time")
  25606. end_time := c.GetString("end_time")
  25607. insutype := c.GetString("insutype")
  25608. clr_type := c.GetString("clr_type")
  25609. clr_org := c.GetString("clr_optins")
  25610. admin_user_id, _ := c.GetInt64("admin_user_id")
  25611. adminUser := c.GetAdminUserInfo()
  25612. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25613. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25614. if len(clr_org) == 0 {
  25615. clr_org = miConfig.InsuplcAdmdvs
  25616. }
  25617. timeLayout := "2006-01-02"
  25618. loc, _ := time.LoadLocation("Local")
  25619. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25620. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25621. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25622. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25623. fixmedins_setl_cnt := int64(len(orders))
  25624. var medfee_sumamt float64
  25625. var acct_pay float64
  25626. var fund_pay_sumamt float64
  25627. for _, item := range orders {
  25628. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25629. acct_pay = acct_pay + item.AcctPay
  25630. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25631. }
  25632. var user_name string
  25633. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25634. if role.ID == 0 {
  25635. user_name = "xxx"
  25636. } else {
  25637. user_name = role.UserName
  25638. }
  25639. var res ResultEight
  25640. var res10188 ResultEightFor10188
  25641. if config.IsOpen == 1 {
  25642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25643. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25644. "insutype=" + insutype +
  25645. "&clr_type=" + clr_type +
  25646. "&setl_optins=" + clr_org +
  25647. "&stmt_begndate=" + start_time +
  25648. "&stm_enddate=" + end_time +
  25649. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25650. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25651. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25652. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25653. "&fixmedins_code=" + miConfig.Code +
  25654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25655. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25656. "&secret_key=" + miConfig.SecretKey +
  25657. "&org_name=" + miConfig.OrgName +
  25658. "&doctor=" + user_name +
  25659. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25660. fmt.Println(api)
  25661. resp, requestErr := http.Get(api)
  25662. if requestErr != nil {
  25663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25664. return
  25665. }
  25666. body, ioErr := ioutil.ReadAll(resp.Body)
  25667. fmt.Println(body)
  25668. if ioErr != nil {
  25669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25671. return
  25672. }
  25673. var respJSON map[string]interface{}
  25674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25677. return
  25678. }
  25679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25680. userJSONBytes, _ := json.Marshal(respJSON)
  25681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25682. utils.ErrorLog("解析失败:%v", err)
  25683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25684. return
  25685. }
  25686. res.InfRefmsgid = res10188.InfRefmsgid
  25687. res.Output = res10188.Output
  25688. res.ErrMsg = res10188.ErrMsg
  25689. res.Cainfo = res10188.Cainfo
  25690. res.WarnMsg = res10188.WarnMsg
  25691. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25692. res.Infcode = infocode
  25693. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25694. if clr_type != "9903" {
  25695. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25696. }
  25697. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25698. "insutype=" + insutype +
  25699. "&clr_type=" + clr_type +
  25700. "&setl_optins=" + clr_org +
  25701. "&stmt_begndate=" + start_time +
  25702. "&stm_enddate=" + end_time +
  25703. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25704. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25705. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25706. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25707. "&fixmedins_code=" + miConfig.Code +
  25708. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25709. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25710. "&secret_key=" + miConfig.SecretKey +
  25711. "&org_name=" + miConfig.OrgName +
  25712. "&doctor=" + user_name
  25713. resp, requestErr := http.Get(api)
  25714. if requestErr != nil {
  25715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25716. return
  25717. }
  25718. body, ioErr := ioutil.ReadAll(resp.Body)
  25719. if ioErr != nil {
  25720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25722. return
  25723. }
  25724. var respJSON map[string]interface{}
  25725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25728. return
  25729. }
  25730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25731. result, _ := json.Marshal(respJSON)
  25732. fmt.Println("log")
  25733. fmt.Println(string(result))
  25734. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25735. utils.ErrorLog("解析失败:%v", err)
  25736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25737. return
  25738. }
  25739. res.InfRefmsgid = res10188.InfRefmsgid
  25740. res.Output = res10188.Output
  25741. res.ErrMsg = res10188.ErrMsg
  25742. res.Cainfo = res10188.Cainfo
  25743. res.WarnMsg = res10188.WarnMsg
  25744. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25745. res.Infcode = infocode
  25746. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25747. var baseParams models.BaseParams
  25748. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25749. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25750. baseParams.SecretKey = miConfig.SecretKey
  25751. baseParams.OrgName = miConfig.OrgName
  25752. baseParams.FixmedinsCode = miConfig.Code
  25753. baseParams.EncKey = miConfig.EncKey
  25754. baseParams.AppSecret = miConfig.AppSecret
  25755. baseParams.SignKey = miConfig.SignKey
  25756. baseParams.AppID = miConfig.Code
  25757. baseParams.Doctor = role.UserName
  25758. baseParams.RequestUrl = miConfig.Url
  25759. businessParams := models.BusinessParams{
  25760. Insutype: insutype,
  25761. ClrType: clr_type,
  25762. SetlOptins: clr_org,
  25763. StmtBegndate: start_time,
  25764. StmtEnddate: end_time,
  25765. MedfeeSumamt: medfee_sumamt,
  25766. FundPaySumamt: fund_pay_sumamt,
  25767. AcctPay: acct_pay,
  25768. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25769. }
  25770. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25771. fmt.Println(requestLog)
  25772. fmt.Println(result)
  25773. fmt.Println(err_msg)
  25774. var dat map[string]interface{}
  25775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25776. fmt.Println(dat)
  25777. } else {
  25778. fmt.Println(err)
  25779. }
  25780. userJSONBytes, _ := json.Marshal(dat)
  25781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25782. utils.ErrorLog("解析失败:%v", err)
  25783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25784. return
  25785. }
  25786. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25787. var baseParams models.BaseParams
  25788. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25789. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25790. baseParams.SecretKey = miConfig.SecretKey
  25791. baseParams.OrgName = miConfig.OrgName
  25792. baseParams.FixmedinsCode = miConfig.Code
  25793. baseParams.EncKey = miConfig.EncKey
  25794. baseParams.AppSecret = miConfig.AppSecret
  25795. baseParams.SignKey = miConfig.SignKey
  25796. baseParams.AppID = miConfig.Code
  25797. baseParams.Doctor = role.UserName
  25798. baseParams.RequestUrl = miConfig.Url
  25799. baseParams.AccessKey = miConfig.AccessKey
  25800. businessParams := models.BusinessParams{
  25801. Insutype: insutype,
  25802. ClrType: clr_type,
  25803. SetlOptins: "430822",
  25804. StmtBegndate: start_time,
  25805. StmtEnddate: end_time,
  25806. MedfeeSumamt: medfee_sumamt,
  25807. FundPaySumamt: fund_pay_sumamt,
  25808. AcctPay: acct_pay,
  25809. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25810. }
  25811. 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)
  25812. fmt.Println(requestLog)
  25813. fmt.Println(result)
  25814. var dat map[string]interface{}
  25815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25816. fmt.Println(dat)
  25817. } else {
  25818. fmt.Println(err)
  25819. }
  25820. userJSONBytes, _ := json.Marshal(dat)
  25821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25822. utils.ErrorLog("解析失败:%v", err)
  25823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25824. return
  25825. }
  25826. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25827. var baseParams models.BaseParams
  25828. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25829. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25830. baseParams.SecretKey = miConfig.SecretKey
  25831. baseParams.OrgName = miConfig.OrgName
  25832. baseParams.FixmedinsCode = miConfig.Code
  25833. baseParams.EncKey = miConfig.EncKey
  25834. baseParams.AppSecret = miConfig.AppSecret
  25835. baseParams.SignKey = miConfig.SignKey
  25836. baseParams.AppID = miConfig.Code
  25837. baseParams.Doctor = role.UserName
  25838. baseParams.RequestUrl = miConfig.Url
  25839. businessParams := models.BusinessParams{
  25840. Insutype: insutype,
  25841. ClrType: clr_type,
  25842. SetlOptins: clr_org,
  25843. StmtBegndate: start_time,
  25844. StmtEnddate: end_time,
  25845. MedfeeSumamt: medfee_sumamt,
  25846. FundPaySumamt: fund_pay_sumamt,
  25847. AcctPay: acct_pay,
  25848. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25849. }
  25850. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25851. fmt.Println(requestLog)
  25852. fmt.Println(result)
  25853. fmt.Println(err_msg)
  25854. var dat map[string]interface{}
  25855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25856. fmt.Println(dat)
  25857. } else {
  25858. fmt.Println(err)
  25859. }
  25860. userJSONBytes, _ := json.Marshal(dat)
  25861. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25862. utils.ErrorLog("解析失败:%v", err)
  25863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25864. return
  25865. }
  25866. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25867. if len(clr_type) == 0 {
  25868. clr_type = "11"
  25869. }
  25870. api := miConfig.Url + "gdyb/ten?" +
  25871. "insutype=" + insutype +
  25872. "&clr_type=" + clr_type +
  25873. "&setl_optins=" + clr_org +
  25874. "&stmt_begndate=" + start_time +
  25875. "&stm_enddate=" + end_time +
  25876. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25877. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25878. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25879. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25880. "&fixmedins_code=" + miConfig.Code +
  25881. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25882. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25883. "&secret_key=" + miConfig.SecretKey +
  25884. "&org_name=" + miConfig.OrgName +
  25885. "&doctor=" + user_name
  25886. fmt.Println(api)
  25887. resp, requestErr := http.Get(api)
  25888. if requestErr != nil {
  25889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25890. return
  25891. }
  25892. body, ioErr := ioutil.ReadAll(resp.Body)
  25893. fmt.Println(body)
  25894. if ioErr != nil {
  25895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25897. return
  25898. }
  25899. var respJSON map[string]interface{}
  25900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25903. return
  25904. }
  25905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25906. userJSONBytes, _ := json.Marshal(respJSON)
  25907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25908. utils.ErrorLog("解析失败:%v", err)
  25909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25910. return
  25911. }
  25912. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25913. var baseParams models.BaseParams
  25914. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25915. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25916. baseParams.SecretKey = miConfig.SecretKey
  25917. baseParams.OrgName = miConfig.OrgName
  25918. baseParams.FixmedinsCode = miConfig.Code
  25919. baseParams.EncKey = miConfig.EncKey
  25920. baseParams.AppSecret = miConfig.AppSecret
  25921. baseParams.SignKey = miConfig.SignKey
  25922. baseParams.AppID = miConfig.Code
  25923. baseParams.Doctor = role.UserName
  25924. baseParams.RequestUrl = miConfig.Url
  25925. if clr_type == "9903" {
  25926. clr_type = "9901"
  25927. }
  25928. businessParams := models.BusinessParams{
  25929. Insutype: insutype,
  25930. ClrType: clr_type,
  25931. SetlOptins: "360302",
  25932. StmtBegndate: start_time,
  25933. StmtEnddate: end_time,
  25934. MedfeeSumamt: 0,
  25935. FundPaySumamt: 0,
  25936. AcctPay: 0,
  25937. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25938. }
  25939. 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))
  25940. fmt.Println(requestLog)
  25941. fmt.Println(result)
  25942. var dat map[string]interface{}
  25943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25944. fmt.Println(dat)
  25945. } else {
  25946. fmt.Println(err)
  25947. }
  25948. userJSONBytes, _ := json.Marshal(dat)
  25949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25950. utils.ErrorLog("解析失败:%v", err)
  25951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25952. return
  25953. }
  25954. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25955. var api string
  25956. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  25957. "&clr_type=" + clr_type +
  25958. "&setl_optins=" + clr_org +
  25959. "&stmt_begndate=" + start_time +
  25960. "&stm_enddate=" + end_time +
  25961. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25962. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25963. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25964. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25965. "&fixmedins_code=" + miConfig.Code +
  25966. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25967. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25968. "&secret_key=" + miConfig.SecretKey +
  25969. "&org_name=" + miConfig.OrgName +
  25970. "&doctor=" + user_name + "&url=" + miConfig.Url
  25971. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25972. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25973. resp, requestErr := http.Get(api)
  25974. if requestErr != nil {
  25975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25976. return
  25977. }
  25978. body, ioErr := ioutil.ReadAll(resp.Body)
  25979. if ioErr != nil {
  25980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25982. return
  25983. }
  25984. var respJSON map[string]interface{}
  25985. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25988. return
  25989. }
  25990. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25991. if status == "0" {
  25992. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25993. c.ServeSuccessJSON(map[string]interface{}{
  25994. "failed_code": -10,
  25995. "msg": err_msg,
  25996. })
  25997. return
  25998. }
  25999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26000. userJSONBytes, _ := json.Marshal(respJSON)
  26001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26002. utils.ErrorLog("解析失败:%v", err)
  26003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26004. return
  26005. }
  26006. } else {
  26007. if len(clr_type) == 0 {
  26008. clr_type = "11"
  26009. }
  26010. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26011. "insutype=" + insutype +
  26012. "&clr_type=" + clr_type +
  26013. "&setl_optins=" + clr_org +
  26014. "&stmt_begndate=" + start_time +
  26015. "&stm_enddate=" + end_time +
  26016. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26017. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26018. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26019. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26020. "&fixmedins_code=" + miConfig.Code +
  26021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26022. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26023. "&secret_key=" + miConfig.SecretKey +
  26024. "&org_name=" + miConfig.OrgName +
  26025. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26026. fmt.Println(api)
  26027. resp, requestErr := http.Get(api)
  26028. if requestErr != nil {
  26029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26030. return
  26031. }
  26032. body, ioErr := ioutil.ReadAll(resp.Body)
  26033. fmt.Println(body)
  26034. if ioErr != nil {
  26035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26037. return
  26038. }
  26039. var respJSON map[string]interface{}
  26040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26043. return
  26044. }
  26045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26046. userJSONBytes, _ := json.Marshal(respJSON)
  26047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26048. utils.ErrorLog("解析失败:%v", err)
  26049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26050. return
  26051. }
  26052. }
  26053. if res.Infcode == 0 {
  26054. if res.Output.Stmtinfo.StmtRslt == "0" {
  26055. micc := &models.MedicalInsuranceCostCompare{
  26056. StartTime: startime.Unix(),
  26057. EndTime: endtime.Unix(),
  26058. Insutype: insutype,
  26059. CheckType: 1,
  26060. Num: fixmedins_setl_cnt,
  26061. Mtime: time.Now().Unix(),
  26062. Status: 1,
  26063. UserOrgId: adminUser.CurrentOrgId,
  26064. CostTotal: medfee_sumamt,
  26065. FuncTotal: fund_pay_sumamt,
  26066. PsnPay: acct_pay,
  26067. Creator: admin_user_id,
  26068. Ctime: time.Now().Unix(),
  26069. ClrType: clr_type,
  26070. }
  26071. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  26072. if err == nil {
  26073. c.ServeSuccessJSON(map[string]interface{}{
  26074. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26075. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26076. })
  26077. } else {
  26078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26079. }
  26080. } else {
  26081. c.ServeSuccessJSON(map[string]interface{}{
  26082. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26083. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26084. })
  26085. }
  26086. } else {
  26087. c.ServeSuccessJSON(map[string]interface{}{
  26088. "failed_code": -10,
  26089. "msg": res.ErrMsg,
  26090. })
  26091. }
  26092. }
  26093. }
  26094. func (c *HisApiController) Check310() {
  26095. adminUser := c.GetAdminUserInfo()
  26096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26097. var user_name string
  26098. user_name = "高慧裕"
  26099. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26100. "insutype=" + "310" +
  26101. "&clr_type=" + "" +
  26102. "&setl_optins=" + "441202" +
  26103. "&stmt_begndate=" + "2022-03-01" +
  26104. "&stm_enddate=" + "2022-03-31" +
  26105. "&medfee_sumamt=" + "194930.12" +
  26106. "&fund_pay_sumamt=" + "188741.46" +
  26107. "&acct_pay=" + "0" +
  26108. "&fixmedins_setl_cnt=" + "452" +
  26109. "&fixmedins_code=" + miConfig.Code +
  26110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26111. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26112. "&secret_key=" + miConfig.SecretKey +
  26113. "&org_name=" + miConfig.OrgName +
  26114. "&doctor=" + user_name
  26115. fmt.Println(api)
  26116. resp, requestErr := http.Get(api)
  26117. if requestErr != nil {
  26118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26119. return
  26120. }
  26121. body, ioErr := ioutil.ReadAll(resp.Body)
  26122. fmt.Println(body)
  26123. if ioErr != nil {
  26124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26126. return
  26127. }
  26128. var respJSON map[string]interface{}
  26129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26132. return
  26133. }
  26134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26135. userJSONBytes, _ := json.Marshal(respJSON)
  26136. var res ResultEight
  26137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26138. utils.ErrorLog("解析失败:%v", err)
  26139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26140. return
  26141. }
  26142. }
  26143. func (c *HisApiController) Check390() {
  26144. adminUser := c.GetAdminUserInfo()
  26145. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26146. var user_name string
  26147. user_name = "高慧裕"
  26148. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26149. "insutype=" + "390" +
  26150. "&clr_type=" + "" +
  26151. "&setl_optins=" + "441202" +
  26152. "&stmt_begndate=" + "2022-03-01" +
  26153. "&stm_enddate=" + "2022-03-31" +
  26154. "&medfee_sumamt=" + "1068448.89" +
  26155. "&fund_pay_sumamt=" + "1014677.62" +
  26156. "&acct_pay=" + "0" +
  26157. "&fixmedins_setl_cnt=" + "1950" +
  26158. "&fixmedins_code=" + miConfig.Code +
  26159. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26160. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26161. "&secret_key=" + miConfig.SecretKey +
  26162. "&org_name=" + miConfig.OrgName +
  26163. "&doctor=" + user_name
  26164. fmt.Println(api)
  26165. resp, requestErr := http.Get(api)
  26166. if requestErr != nil {
  26167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26168. return
  26169. }
  26170. body, ioErr := ioutil.ReadAll(resp.Body)
  26171. fmt.Println(body)
  26172. if ioErr != nil {
  26173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26175. return
  26176. }
  26177. var respJSON map[string]interface{}
  26178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26181. return
  26182. }
  26183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26184. userJSONBytes, _ := json.Marshal(respJSON)
  26185. var res ResultEight
  26186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26187. utils.ErrorLog("解析失败:%v", err)
  26188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26189. return
  26190. }
  26191. }
  26192. // 对账明细
  26193. func (c *HisApiController) GetCheckDetailAccount() {
  26194. start_time := c.GetString("start_time")
  26195. end_time := c.GetString("end_time")
  26196. admin_user_id, _ := c.GetInt64("admin_user_id")
  26197. adminUser := c.GetAdminUserInfo()
  26198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26199. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26200. timeLayout := "2006-01-02"
  26201. loc, _ := time.LoadLocation("Local")
  26202. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26203. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26204. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26205. rand.Seed(time.Now().UnixNano())
  26206. num := rand.Intn(30000)
  26207. Mkdir(miConfig.OrgName)
  26208. file := strconv.FormatInt(int64(num), 10)
  26209. file_name := file + ".txt"
  26210. zip_name := file + ".zip"
  26211. zip_path := miConfig.OrgName + "/" + zip_name
  26212. file_path := miConfig.OrgName + "/" + file_name
  26213. decimal.DivisionPrecision = 2
  26214. var medfee_sumamt float64
  26215. var psn_cash_pay float64
  26216. var fund_pay_sumamt float64
  26217. fixmedins_setl_cnt := int64(len(orders))
  26218. for _, item := range orders {
  26219. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26220. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26221. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26222. }
  26223. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26224. defer f.Close()
  26225. if err != nil {
  26226. fmt.Println(err.Error())
  26227. } else {
  26228. for _, item := range orders {
  26229. var refd_setl_flag string
  26230. if item.OrderStatus == 2 {
  26231. refd_setl_flag = "0"
  26232. var str string
  26233. str = item.SetlId + " " +
  26234. item.MdtrtId + " " +
  26235. item.PsnNo + " " +
  26236. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26237. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26238. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26239. _, err = f.Write([]byte(str))
  26240. }
  26241. if item.OrderStatus == 3 {
  26242. var str string
  26243. str = item.SetlId + " " +
  26244. item.MdtrtId + " " +
  26245. item.PsnNo + " " +
  26246. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26247. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26248. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26249. _, err = f.Write([]byte(str))
  26250. var str2 string
  26251. str2 = item.SetlId + " " +
  26252. item.MdtrtId + " " +
  26253. item.PsnNo + " " +
  26254. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26255. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26256. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26257. _, err = f.Write([]byte(str2))
  26258. }
  26259. }
  26260. }
  26261. Zip(file_path, zip_path)
  26262. fmt.Println(ReadFile(zip_path))
  26263. fmt.Println(string(ReadFile(zip_path)))
  26264. if config.IsOpen == 1 {
  26265. var user_name string
  26266. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26267. if role.ID == 0 {
  26268. user_name = "管理员"
  26269. } else {
  26270. user_name = role.UserName
  26271. }
  26272. baseParams := models.BaseParams{
  26273. SecretKey: miConfig.SecretKey,
  26274. FixmedinsCode: miConfig.Code,
  26275. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26276. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26277. OrgName: miConfig.OrgName,
  26278. Doctor: user_name,
  26279. }
  26280. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26281. var dat map[string]interface{}
  26282. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26283. fmt.Println(dat)
  26284. } else {
  26285. fmt.Println(err)
  26286. }
  26287. userJSONBytes, _ := json.Marshal(dat)
  26288. var res ResultNine
  26289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26290. utils.ErrorLog("解析失败:%v", err)
  26291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26292. return
  26293. }
  26294. if res.Infcode == 0 {
  26295. fileNo := res.Output.FileQuryNo
  26296. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26297. "file_qury_no=" + fileNo +
  26298. "&setl_optins=" + "定点医保中心" +
  26299. "&stmt_begndate=" + start_time +
  26300. "&stm_enddate=" + end_time +
  26301. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26302. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26303. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26304. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26305. "&fixmedins_code=" + miConfig.Code +
  26306. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26307. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26308. "&secret_key=" + miConfig.SecretKey +
  26309. "&org_name=" + miConfig.OrgName +
  26310. "&doctor=" + user_name
  26311. resp, requestErr := http.Get(api)
  26312. if requestErr != nil {
  26313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26314. return
  26315. }
  26316. body, ioErr := ioutil.ReadAll(resp.Body)
  26317. if ioErr != nil {
  26318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26320. return
  26321. }
  26322. var respJSON map[string]interface{}
  26323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26326. return
  26327. }
  26328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26329. userJSONBytes, _ := json.Marshal(respJSON)
  26330. var res ResultTen
  26331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26332. utils.ErrorLog("解析失败:%v", err)
  26333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26334. return
  26335. }
  26336. if res.Infcode == 0 {
  26337. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26338. micc := &models.MedicalInsuranceCostCompare{
  26339. StartTime: startime.Unix(),
  26340. EndTime: endtime.Unix(),
  26341. Insutype: "0",
  26342. CheckType: 2,
  26343. Num: fixmedins_setl_cnt,
  26344. Mtime: time.Now().Unix(),
  26345. Status: 1,
  26346. UserOrgId: adminUser.CurrentOrgId,
  26347. CostTotal: medfee_sumamt,
  26348. FuncTotal: fund_pay_sumamt,
  26349. PsnPay: psn_cash_pay,
  26350. Creator: admin_user_id,
  26351. Ctime: time.Now().Unix(),
  26352. }
  26353. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26354. c.ServeSuccessJSON(map[string]interface{}{
  26355. "msg": "明细对账成功",
  26356. })
  26357. }
  26358. } else {
  26359. }
  26360. }
  26361. }
  26362. type CustomOrderInfo struct {
  26363. Name string
  26364. Spec string
  26365. Unit string
  26366. Count float64
  26367. Price float64
  26368. Total float64
  26369. }
  26370. func (c *HisApiController) GetBatchSettleAccounts() {
  26371. admin_user_id, _ := c.GetInt64("admin_user_id")
  26372. order_ids := c.GetString("order_ids")
  26373. order_ids_arr := strings.Split(order_ids, ",")
  26374. data3 := []map[string]interface{}{}
  26375. for _, item := range order_ids_arr {
  26376. id, _ := strconv.ParseInt(item, 10, 64)
  26377. order_id := id
  26378. adminUser := c.GetAdminUserInfo()
  26379. order, _ := service.GetHisOrderByID(order_id)
  26380. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26381. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26382. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26383. orderInfos = append(orderInfos, orderInfos_two...)
  26384. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26385. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26386. var diagnosis_ids []string
  26387. if his.ID > 0 {
  26388. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26389. } else {
  26390. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26391. }
  26392. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26393. var dia_config []*models.HisXtDiagnoseConfig
  26394. var name string
  26395. for _, item := range diagnosis_ids {
  26396. id, _ := strconv.ParseInt(item, 10, 64)
  26397. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26398. dia_config = append(dia_config, &diagnosisConfig)
  26399. if len(name) == 0 {
  26400. name = diagnosisConfig.ClassName
  26401. }
  26402. //} else {
  26403. // name = name + "," + diagnosisConfig.ClassName
  26404. //}
  26405. }
  26406. var bedCostTotal float64 = 0 //床位总费
  26407. var bedCostSelfTotal float64 = 0 //床位自费
  26408. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26409. var bedSelfTotal float64 = 0 //床位部分项目自费
  26410. var bedInscpTotal float64 = 0 //床位部分项目自费
  26411. var operationCostTotal float64 = 0 //手术费
  26412. var operationCostSelfTotal float64 = 0 //手术费
  26413. var operationCostPartSelfTotal float64 = 0 //手术费
  26414. var operationSelfTotal float64 = 0 //床位部分项目自费
  26415. var operationInscpTotal float64 = 0 //床位部分项目自费
  26416. var otherCostTotal float64 = 0 //其他费用
  26417. var otherCostSelfTotal float64 = 0 //其他费用
  26418. var otherCostPartSelfTotal float64 = 0 //其他费用
  26419. var otherSelfTotal float64 = 0 //床位部分项目自费
  26420. var otherInscpTotal float64 = 0 //床位部分项目自费
  26421. var materialCostTotal float64 = 0 //材料费
  26422. var materialCostSelfTotal float64 = 0 //材料费
  26423. var materialCostPartSelfTotal float64 = 0 //材料费
  26424. var materialSelfTotal float64 = 0 //床位部分项目自费
  26425. var materialInscpTotal float64 = 0 //床位部分项目自费
  26426. var westernMedicineCostTotal float64 = 0 //西药费
  26427. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26428. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26429. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26430. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26431. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26432. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26433. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26434. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26435. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26436. var checkCostTotal float64 = 0 //检查费
  26437. var checkCostSelfTotal float64 = 0 //检查费
  26438. var checkCostPartSelfTotal float64 = 0 //检查费
  26439. var checkSelfTotal float64 = 0 //床位部分项目自费
  26440. var checkInscpTotal float64 = 0 //床位部分项目自费
  26441. var laboratoryCostTotal float64 = 0 //化验费
  26442. var laboratoryCostSelfTotal float64 = 0 //化验费
  26443. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26444. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26445. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26446. var treatCostTotal float64 = 0 //治疗费用
  26447. var treatCostSelfTotal float64 = 0 //治疗费用
  26448. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26449. var treatSelfTotal float64 = 0 //床位部分项目自费
  26450. var treatInscpTotal float64 = 0 //床位部分项目自费
  26451. decimal.DivisionPrecision = 2
  26452. for _, item := range orderInfos {
  26453. if item.MedChrgitmType == "01" { //床位费
  26454. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26455. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26456. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26457. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26458. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26459. }
  26460. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26461. if item.MedChrgitmType == "03" { //检查费
  26462. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26463. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26464. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26465. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26466. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26467. }
  26468. } else {
  26469. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26470. fmt.Println("------------")
  26471. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26472. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26473. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26474. }
  26475. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26476. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26477. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26478. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26479. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26480. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26481. }
  26482. }
  26483. if item.MedChrgitmType == "04" { //化验费
  26484. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26485. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26486. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26487. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26488. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26489. }
  26490. if item.MedChrgitmType == "05" { //治疗费
  26491. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26492. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26493. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26494. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26495. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26496. }
  26497. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26498. fmt.Println("------------")
  26499. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26500. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26501. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26502. }
  26503. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26504. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26505. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26506. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26507. }
  26508. //if item.MedChrgitmType == "06" { //手术费
  26509. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26510. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26511. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26512. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26513. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26514. //
  26515. //}
  26516. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26517. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26518. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26519. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26520. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26521. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26522. }
  26523. if item.MedChrgitmType == "09" { //西药费
  26524. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26525. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26526. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26527. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26528. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26529. }
  26530. if item.MedChrgitmType == "11" { //中成费
  26531. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26532. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26533. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26534. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26535. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26536. }
  26537. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26538. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26539. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26540. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26541. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26542. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26543. }
  26544. }
  26545. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26546. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26547. var user_name string
  26548. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26549. if role.ID == 0 {
  26550. user_name = "管理员"
  26551. } else {
  26552. user_name = role.UserName
  26553. }
  26554. baseParams := models.BaseParams{
  26555. SecretKey: miConfig.SecretKey,
  26556. FixmedinsCode: miConfig.Code,
  26557. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26558. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26559. OrgName: miConfig.OrgName,
  26560. Doctor: user_name,
  26561. RequestUrl: miConfig.Url,
  26562. AccessKey: miConfig.AccessKey,
  26563. }
  26564. businessParams := models.BusinessParams{
  26565. PsnNo: order.PsnNo,
  26566. MdtrtId: order.MdtrtId,
  26567. SetlId: order.SetlId,
  26568. }
  26569. var res ResultEleven
  26570. var resEleven10265 ResultEleven10265
  26571. if config.IsOpen == 1 {
  26572. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26573. result := service.Gdyb5203(baseParams, businessParams)
  26574. service.Gdyb5204(baseParams, businessParams)
  26575. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26576. var dat map[string]interface{}
  26577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26578. fmt.Println(dat)
  26579. } else {
  26580. fmt.Println(err)
  26581. }
  26582. userJSONBytes, _ := json.Marshal(dat)
  26583. if miConfig.Code == "H15049901371" {
  26584. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26585. utils.ErrorLog("解析失败:%v", err)
  26586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26587. return
  26588. }
  26589. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26590. res.Output = resEleven10265.Output
  26591. res.ErrMsg = resEleven10265.ErrMsg
  26592. res.Cainfo = resEleven10265.Cainfo
  26593. res.WarnMsg = resEleven10265.WarnMsg
  26594. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26595. res.Infcode = infocode
  26596. } else {
  26597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26598. utils.ErrorLog("解析失败:%v", err)
  26599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26600. return
  26601. }
  26602. }
  26603. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26604. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26605. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26606. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26607. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26608. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26609. var doctor_name string
  26610. if roles.ID == 0 {
  26611. doctor_name = "管理员"
  26612. } else {
  26613. doctor_name = roles.UserName
  26614. }
  26615. yiliao_leibie := ""
  26616. switch order.MedType {
  26617. case "11":
  26618. yiliao_leibie = "普通门诊"
  26619. break
  26620. case "12":
  26621. yiliao_leibie = "门诊挂号"
  26622. break
  26623. case "13":
  26624. yiliao_leibie = "急诊"
  26625. break
  26626. case "14":
  26627. yiliao_leibie = "门诊特殊病"
  26628. break
  26629. case "15":
  26630. yiliao_leibie = "门诊统筹"
  26631. break
  26632. case "16":
  26633. yiliao_leibie = "门诊慢性病"
  26634. break
  26635. case "21":
  26636. yiliao_leibie = "普通住院"
  26637. break
  26638. }
  26639. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26640. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26641. if res.Infcode == 0 {
  26642. data2 := map[string]interface{}{
  26643. "diagnosis": name,
  26644. "order_infos": orderInfos,
  26645. "number": order.MdtrtId,
  26646. "date": order.SettleAccountsDate,
  26647. "charge_admin": charge_admin,
  26648. "printor_admin": printor_admin,
  26649. "info": res.Output.Setlinfo,
  26650. "order": order,
  26651. "bedCostTotal": bedCostTotal,
  26652. "bedCostSelfTotal": bedCostSelfTotal,
  26653. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26654. "bedSelfTotal": bedSelfTotal,
  26655. "bedInscpTotal": bedInscpTotal,
  26656. "operationCostTotal": operationCostTotal,
  26657. "operationCostSelfTotal": operationCostSelfTotal,
  26658. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26659. "operationSelfTotal": operationSelfTotal,
  26660. "operationInscpTotal": operationInscpTotal,
  26661. "otherCostTotal": otherCostTotal,
  26662. "otherCostSelfTotal": otherCostSelfTotal,
  26663. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26664. "otherSelfTotal": otherSelfTotal,
  26665. "otherInscpTotal": otherInscpTotal,
  26666. "materialCostTotal": materialCostTotal,
  26667. "materialCostSelfTotal": materialCostSelfTotal,
  26668. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26669. "materialSelfTotal": materialSelfTotal,
  26670. "materialInscpTotal": materialInscpTotal,
  26671. "westernMedicineCostTotal": westernMedicineCostTotal,
  26672. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26673. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26674. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26675. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26676. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26677. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26678. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26679. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26680. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26681. "checkCostTotal": checkCostTotal,
  26682. "checkCostSelfTotal": checkCostSelfTotal,
  26683. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26684. "checkSelfTotal": checkSelfTotal,
  26685. "checkInscpTotal": checkInscpTotal,
  26686. "laboratoryCostTotal": laboratoryCostTotal,
  26687. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26688. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26689. "laboratorySelfTotal": laboratorySelfTotal,
  26690. "laboratoryInscpTotal": laboratoryInscpTotal,
  26691. "treatCostTotal": treatCostTotal,
  26692. "treatCostSelfTotal": treatCostSelfTotal,
  26693. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26694. "treatSelfTotal": treatSelfTotal,
  26695. "treatInscpTotal": treatInscpTotal,
  26696. "doctor_info": doctor_info,
  26697. "doctor_code": adminRole_two.DoctorCode,
  26698. "doctor_name": doctor_name,
  26699. "health_card_no": order.PsnNo,
  26700. "department": departments.Name,
  26701. "yiliao_leibie": yiliao_leibie,
  26702. "after_money": order.AccountPrice,
  26703. "patient": patient,
  26704. "org_name": miConfig.OrgName,
  26705. "org_code": miConfig.Code,
  26706. "order_number": order.Number,
  26707. "his_hospital": his_hospital,
  26708. "his": his,
  26709. "dia_config": dia_config,
  26710. "psn_cash_pay": order.PsnCashPay,
  26711. //"check_order_info": cus_slice,
  26712. }
  26713. data3 = append(data3, data2)
  26714. }
  26715. }
  26716. }
  26717. c.ServeSuccessJSON(map[string]interface{}{
  26718. "infos": data3,
  26719. })
  26720. }
  26721. func (c *HisApiController) GetSettleAccounts() {
  26722. //id, _ := c.GetInt64("id")
  26723. //record_time := c.GetString("record_time")
  26724. order_id, _ := c.GetInt64("order_id")
  26725. admin_user_id, _ := c.GetInt64("admin_user_id")
  26726. //timeLayout := "2006-01-02"
  26727. //loc, _ := time.LoadLocation("Local")
  26728. //
  26729. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26730. //if err != nil {
  26731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26732. // return
  26733. //}Hbyb5203
  26734. //recordDateTime := theTime.Unix()
  26735. adminUser := c.GetAdminUserInfo()
  26736. order, _ := service.GetHisOrderByID(order_id)
  26737. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26738. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26739. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26740. orderInfos = append(orderInfos, orderInfos_two...)
  26741. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26742. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26743. var diagnosis_ids []string
  26744. if his.ID > 0 {
  26745. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26746. } else {
  26747. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26748. }
  26749. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26750. var dia_config []*models.HisXtDiagnoseConfig
  26751. var name string
  26752. for _, item := range diagnosis_ids {
  26753. id, _ := strconv.ParseInt(item, 10, 64)
  26754. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26755. dia_config = append(dia_config, &diagnosisConfig)
  26756. if len(name) == 0 {
  26757. name = diagnosisConfig.ClassName
  26758. } else {
  26759. name = name + "," + diagnosisConfig.ClassName
  26760. }
  26761. }
  26762. if patient.UserOrgId == 10215 {
  26763. name = "慢性肾功能不全(血透治疗)"
  26764. }
  26765. var bedCostTotal float64 = 0 //床位总费
  26766. var bedCostSelfTotal float64 = 0 //床位自费
  26767. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26768. var bedSelfTotal float64 = 0 //床位部分项目自费
  26769. var bedInscpTotal float64 = 0 //床位部分项目自费
  26770. var operationCostTotal float64 = 0 //手术费
  26771. var operationCostSelfTotal float64 = 0 //手术费
  26772. var operationCostPartSelfTotal float64 = 0 //手术费
  26773. var operationSelfTotal float64 = 0 //床位部分项目自费
  26774. var operationInscpTotal float64 = 0 //床位部分项目自费
  26775. var otherCostTotal float64 = 0 //其他费用
  26776. var otherCostSelfTotal float64 = 0 //其他费用
  26777. var otherCostPartSelfTotal float64 = 0 //其他费用
  26778. var otherSelfTotal float64 = 0 //床位部分项目自费
  26779. var otherInscpTotal float64 = 0 //床位部分项目自费
  26780. var materialCostTotal float64 = 0 //材料费
  26781. var materialCostSelfTotal float64 = 0 //材料费
  26782. var materialCostPartSelfTotal float64 = 0 //材料费
  26783. var materialSelfTotal float64 = 0 //床位部分项目自费
  26784. var materialInscpTotal float64 = 0 //床位部分项目自费
  26785. var westernMedicineCostTotal float64 = 0 //西药费
  26786. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26787. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26788. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26789. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26790. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26791. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26792. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26793. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26794. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26795. var checkCostTotal float64 = 0 //检查费
  26796. var checkCostSelfTotal float64 = 0 //检查费
  26797. var checkCostPartSelfTotal float64 = 0 //检查费
  26798. var checkSelfTotal float64 = 0 //床位部分项目自费
  26799. var checkInscpTotal float64 = 0 //床位部分项目自费
  26800. var laboratoryCostTotal float64 = 0 //化验费
  26801. var laboratoryCostSelfTotal float64 = 0 //化验费
  26802. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26803. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26804. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26805. var treatCostTotal float64 = 0 //治疗费用
  26806. var treatCostSelfTotal float64 = 0 //治疗费用
  26807. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26808. var treatSelfTotal float64 = 0 //床位部分项目自费
  26809. var treatInscpTotal float64 = 0 //床位部分项目自费
  26810. decimal.DivisionPrecision = 2
  26811. for _, item := range orderInfos {
  26812. if item.MedChrgitmType == "01" { //床位费
  26813. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26814. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26815. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26816. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26817. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26818. }
  26819. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26820. if item.MedChrgitmType == "03" { //检查费
  26821. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26822. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26823. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26824. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26825. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26826. }
  26827. } else {
  26828. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26829. fmt.Println("------------")
  26830. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26831. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26832. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26833. }
  26834. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26835. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26836. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26837. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26838. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26839. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26840. }
  26841. }
  26842. if item.MedChrgitmType == "04" { //化验费
  26843. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26844. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26845. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26846. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26847. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26848. }
  26849. if item.MedChrgitmType == "05" { //治疗费
  26850. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26851. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26852. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26853. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26854. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26855. }
  26856. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26857. fmt.Println("------------")
  26858. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26859. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26860. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26861. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26862. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26863. }
  26864. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26865. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26866. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26867. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26868. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26869. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26870. }
  26871. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26872. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26873. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26874. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26875. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26876. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26877. }
  26878. if item.MedChrgitmType == "09" { //西药费
  26879. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26880. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26881. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26882. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26883. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26884. }
  26885. if item.MedChrgitmType == "11" { //中成费
  26886. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26887. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26888. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26889. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26890. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26891. }
  26892. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26893. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26894. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26895. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26896. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26897. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26898. }
  26899. }
  26900. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26901. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26902. var user_name string
  26903. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26904. if role.ID == 0 {
  26905. user_name = "管理员"
  26906. } else {
  26907. user_name = role.UserName
  26908. }
  26909. baseParams := models.BaseParams{
  26910. SecretKey: miConfig.SecretKey,
  26911. FixmedinsCode: miConfig.Code,
  26912. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26913. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26914. OrgName: miConfig.OrgName,
  26915. Doctor: user_name,
  26916. RequestUrl: miConfig.Url,
  26917. AccessKey: miConfig.AccessKey,
  26918. }
  26919. businessParams := models.BusinessParams{
  26920. PsnNo: order.PsnNo,
  26921. MdtrtId: order.MdtrtId,
  26922. SetlId: order.SetlId,
  26923. }
  26924. var res ResultEleven
  26925. var resah ResultElevenah
  26926. var resEleven10265 ResultEleven10265
  26927. if config.IsOpen == 1 {
  26928. if miConfig.MdtrtareaAdmvs == "421300" {
  26929. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26930. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26932. resp, requestErr := http.Get(api)
  26933. if requestErr != nil {
  26934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26935. return
  26936. }
  26937. body, ioErr := ioutil.ReadAll(resp.Body)
  26938. if ioErr != nil {
  26939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26941. return
  26942. }
  26943. var respJSON map[string]interface{}
  26944. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26947. return
  26948. }
  26949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26950. result, _ := json.Marshal(respJSON)
  26951. fmt.Println("log")
  26952. fmt.Println(string(result))
  26953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26954. utils.ErrorLog("解析失败:%v", err)
  26955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26956. return
  26957. }
  26958. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26959. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26960. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26961. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26962. resp, requestErr := http.Get(api)
  26963. if requestErr != nil {
  26964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26965. return
  26966. }
  26967. body, ioErr := ioutil.ReadAll(resp.Body)
  26968. if ioErr != nil {
  26969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26971. return
  26972. }
  26973. var respJSON map[string]interface{}
  26974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26977. return
  26978. }
  26979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26980. result, _ := json.Marshal(respJSON)
  26981. fmt.Println("log")
  26982. fmt.Println(string(result))
  26983. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26984. utils.ErrorLog("解析失败:%v", err)
  26985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26986. return
  26987. }
  26988. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26989. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26990. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26991. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26992. resp, requestErr := http.Get(api)
  26993. if requestErr != nil {
  26994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26995. return
  26996. }
  26997. body, ioErr := ioutil.ReadAll(resp.Body)
  26998. if ioErr != nil {
  26999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27001. return
  27002. }
  27003. var respJSON map[string]interface{}
  27004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27007. return
  27008. }
  27009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27010. result, _ := json.Marshal(respJSON)
  27011. fmt.Println("log")
  27012. fmt.Println(string(result))
  27013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27014. utils.ErrorLog("解析失败:%v", err)
  27015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27016. return
  27017. }
  27018. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27019. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27020. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  27022. resp, requestErr := http.Get(api)
  27023. if requestErr != nil {
  27024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27025. return
  27026. }
  27027. body, ioErr := ioutil.ReadAll(resp.Body)
  27028. if ioErr != nil {
  27029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27031. return
  27032. }
  27033. var respJSON map[string]interface{}
  27034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27037. return
  27038. }
  27039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27040. result, _ := json.Marshal(respJSON)
  27041. fmt.Println("log")
  27042. fmt.Println(string(result))
  27043. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27044. utils.ErrorLog("解析失败:%v", err)
  27045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27046. return
  27047. }
  27048. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27049. var api string
  27050. if miConfig.MdtrtareaAdmvs == "320921" {
  27051. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27052. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27054. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27055. } else {
  27056. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27057. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27058. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27059. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27060. }
  27061. resp, requestErr := http.Get(api)
  27062. if requestErr != nil {
  27063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27064. return
  27065. }
  27066. body, ioErr := ioutil.ReadAll(resp.Body)
  27067. if ioErr != nil {
  27068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27070. return
  27071. }
  27072. var respJSON map[string]interface{}
  27073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27076. return
  27077. }
  27078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27079. result, _ := json.Marshal(respJSON)
  27080. fmt.Println("log")
  27081. fmt.Println(string(result))
  27082. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27083. utils.ErrorLog("解析失败:%v", err)
  27084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27085. return
  27086. }
  27087. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27088. res.Output = resEleven10265.Output
  27089. res.ErrMsg = resEleven10265.ErrMsg
  27090. res.Cainfo = resEleven10265.Cainfo
  27091. res.WarnMsg = resEleven10265.WarnMsg
  27092. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27093. res.Infcode = infocode
  27094. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27095. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  27096. saveLog(result, requestLog, "5203", "结算单")
  27097. var dat map[string]interface{}
  27098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27099. fmt.Println(dat)
  27100. } else {
  27101. fmt.Println(err)
  27102. }
  27103. userJSONBytes, _ := json.Marshal(dat)
  27104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27105. utils.ErrorLog("解析失败:%v", err)
  27106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27107. return
  27108. }
  27109. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27110. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  27111. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  27112. fmt.Println(result3)
  27113. fmt.Println(requestLog3)
  27114. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  27115. fmt.Println(result2)
  27116. fmt.Println(requestLog2)
  27117. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  27118. saveLog(result, requestLog, "5203", "结算单")
  27119. var dat map[string]interface{}
  27120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27121. fmt.Println(dat)
  27122. } else {
  27123. fmt.Println(err)
  27124. }
  27125. userJSONBytes, _ := json.Marshal(dat)
  27126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27127. utils.ErrorLog("解析失败:%v", err)
  27128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27129. return
  27130. }
  27131. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27132. var api string
  27133. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27134. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27136. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27137. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27138. resp, requestErr := http.Get(api)
  27139. if requestErr != nil {
  27140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27141. return
  27142. }
  27143. body, ioErr := ioutil.ReadAll(resp.Body)
  27144. if ioErr != nil {
  27145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27147. return
  27148. }
  27149. var respJSON map[string]interface{}
  27150. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27153. return
  27154. }
  27155. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27156. if status == "0" {
  27157. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27158. c.ServeSuccessJSON(map[string]interface{}{
  27159. "failed_code": -10,
  27160. "msg": err_msg,
  27161. })
  27162. return
  27163. }
  27164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27165. result, _ := json.Marshal(respJSON)
  27166. fmt.Println("log")
  27167. fmt.Println(string(result))
  27168. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  27169. utils.ErrorLog("解析失败:%v", err)
  27170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27171. return
  27172. }
  27173. res.InfRefmsgid = resah.InfRefmsgid
  27174. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27175. // 创建对应的Time类型
  27176. t := time.UnixMilli(timestamp)
  27177. // 格式化成指定的日期字符串
  27178. str := t.Format("2006-01-02 15:04:05")
  27179. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27180. // 创建对应的Time类型
  27181. t3 := time.UnixMilli(timestamp2)
  27182. // 格式化成指定的日期字符串
  27183. str2 := t3.Format("2006-01-02 15:04:05")
  27184. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27185. // 创建对应的Time类型
  27186. t4 := time.UnixMilli(timestamp3)
  27187. // 格式化成指定的日期字符串
  27188. str3 := t4.Format("2006-01-02 15:04:05")
  27189. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27190. // 创建对应的Time类型
  27191. t5 := time.UnixMilli(timestamp4)
  27192. // 格式化成指定的日期字符串
  27193. str5 := t5.Format("2006-01-02 15:04:05")
  27194. res.Output.Setlinfo.Brdy = str2
  27195. res.Output.Setlinfo.SetlTime = str
  27196. res.Output.Setlinfo.Begndate = str3
  27197. res.Output.Setlinfo.Enddate = str5
  27198. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27199. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27200. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27201. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27202. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27203. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27204. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27205. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27206. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27207. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27208. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27209. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27210. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27211. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27212. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27213. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27214. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27215. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27216. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27217. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27218. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27219. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27220. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27221. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27222. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27223. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27224. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27225. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27226. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27227. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27228. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27229. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27230. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27231. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27232. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27233. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27234. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27235. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27236. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27237. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27238. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27239. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27240. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27241. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27242. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27243. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27244. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27245. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27246. //res.Output.Setldetail = resah.Output.Setldetail
  27247. res.ErrMsg = resah.ErrMsg
  27248. res.Cainfo = resah.Cainfo
  27249. res.WarnMsg = resah.WarnMsg
  27250. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27251. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27252. saveLog(result, requestLog, "5203", "结算单")
  27253. var dat map[string]interface{}
  27254. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27255. fmt.Println(dat)
  27256. } else {
  27257. fmt.Println(err)
  27258. }
  27259. userJSONBytes, _ := json.Marshal(dat)
  27260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27261. utils.ErrorLog("解析失败:%v", err)
  27262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27263. return
  27264. }
  27265. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27266. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27267. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27268. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27269. resp, requestErr := http.Get(api)
  27270. if requestErr != nil {
  27271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27272. return
  27273. }
  27274. body, ioErr := ioutil.ReadAll(resp.Body)
  27275. if ioErr != nil {
  27276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27278. return
  27279. }
  27280. var respJSON map[string]interface{}
  27281. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27284. return
  27285. }
  27286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27287. result, _ := json.Marshal(respJSON)
  27288. fmt.Println("log")
  27289. fmt.Println(string(result))
  27290. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27291. utils.ErrorLog("解析失败:%v", err)
  27292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27293. return
  27294. }
  27295. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27296. res.Output = resEleven10265.Output
  27297. res.ErrMsg = resEleven10265.ErrMsg
  27298. res.Cainfo = resEleven10265.Cainfo
  27299. res.WarnMsg = resEleven10265.WarnMsg
  27300. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27301. res.Infcode = infocode
  27302. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27303. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27304. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27305. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27306. resp, requestErr := http.Get(api)
  27307. if requestErr != nil {
  27308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27309. return
  27310. }
  27311. body, ioErr := ioutil.ReadAll(resp.Body)
  27312. if ioErr != nil {
  27313. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27315. return
  27316. }
  27317. var respJSON map[string]interface{}
  27318. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27321. return
  27322. }
  27323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27324. result, _ := json.Marshal(respJSON)
  27325. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27326. utils.ErrorLog("解析失败:%v", err)
  27327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27328. return
  27329. }
  27330. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27331. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27332. //return
  27333. } else {
  27334. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27335. if len(his.InsuplcAdmdvs) == 0 {
  27336. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27337. } else {
  27338. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27339. }
  27340. result := service.Gdyb5203(baseParams, businessParams)
  27341. //service.Gdyb5204(baseParams, businessParams)
  27342. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27343. var dat map[string]interface{}
  27344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27345. fmt.Println(dat)
  27346. } else {
  27347. fmt.Println(err)
  27348. }
  27349. userJSONBytes, _ := json.Marshal(dat)
  27350. if miConfig.Code == "H15049901371" {
  27351. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27352. utils.ErrorLog("解析失败:%v", err)
  27353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27354. return
  27355. }
  27356. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27357. res.Output = resEleven10265.Output
  27358. res.ErrMsg = resEleven10265.ErrMsg
  27359. res.Cainfo = resEleven10265.Cainfo
  27360. res.WarnMsg = resEleven10265.WarnMsg
  27361. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27362. res.Infcode = infocode
  27363. } else {
  27364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27365. utils.ErrorLog("解析失败:%v", err)
  27366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27367. return
  27368. }
  27369. }
  27370. }
  27371. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27372. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27373. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27374. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27375. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27376. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27377. var doctor_name string
  27378. if roles.ID == 0 {
  27379. doctor_name = "管理员"
  27380. } else {
  27381. doctor_name = roles.UserName
  27382. }
  27383. yiliao_leibie := ""
  27384. switch order.MedType {
  27385. case "11":
  27386. yiliao_leibie = "普通门诊"
  27387. break
  27388. case "12":
  27389. yiliao_leibie = "门诊挂号"
  27390. break
  27391. case "13":
  27392. yiliao_leibie = "急诊"
  27393. break
  27394. case "14":
  27395. yiliao_leibie = "门诊特殊病"
  27396. break
  27397. case "15":
  27398. yiliao_leibie = "门诊统筹"
  27399. break
  27400. case "16":
  27401. yiliao_leibie = "门诊慢性病"
  27402. break
  27403. case "21":
  27404. yiliao_leibie = "普通住院"
  27405. break
  27406. }
  27407. //var rf []CustomFundPay
  27408. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27409. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27410. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27411. if res.Infcode == 0 {
  27412. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27413. c.ServeSuccessJSON(map[string]interface{}{
  27414. "diagnosis": name,
  27415. "order_infos": orderInfos,
  27416. "number": order.MdtrtId,
  27417. "date": order.SettleAccountsDate,
  27418. "charge_admin": charge_admin,
  27419. "printor_admin": printor_admin,
  27420. "info": res.Output.Setlinfo,
  27421. "order": order,
  27422. "bedCostTotal": bedCostTotal,
  27423. "bedCostSelfTotal": bedCostSelfTotal,
  27424. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27425. "bedSelfTotal": bedSelfTotal,
  27426. "bedInscpTotal": bedInscpTotal,
  27427. "operationCostTotal": operationCostTotal,
  27428. "operationCostSelfTotal": operationCostSelfTotal,
  27429. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27430. "operationSelfTotal": operationSelfTotal,
  27431. "operationInscpTotal": operationInscpTotal,
  27432. "otherCostTotal": otherCostTotal,
  27433. "otherCostSelfTotal": otherCostSelfTotal,
  27434. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27435. "otherSelfTotal": otherSelfTotal,
  27436. "otherInscpTotal": otherInscpTotal,
  27437. "materialCostTotal": materialCostTotal,
  27438. "materialCostSelfTotal": materialCostSelfTotal,
  27439. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27440. "materialSelfTotal": materialSelfTotal,
  27441. "materialInscpTotal": materialInscpTotal,
  27442. "westernMedicineCostTotal": westernMedicineCostTotal,
  27443. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27444. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27445. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27446. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27447. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27448. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27449. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27450. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27451. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27452. "checkCostTotal": checkCostTotal,
  27453. "checkCostSelfTotal": checkCostSelfTotal,
  27454. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27455. "checkSelfTotal": checkSelfTotal,
  27456. "checkInscpTotal": checkInscpTotal,
  27457. "laboratoryCostTotal": laboratoryCostTotal,
  27458. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27459. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27460. "laboratorySelfTotal": laboratorySelfTotal,
  27461. "laboratoryInscpTotal": laboratoryInscpTotal,
  27462. "treatCostTotal": treatCostTotal,
  27463. "treatCostSelfTotal": treatCostSelfTotal,
  27464. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27465. "treatSelfTotal": treatSelfTotal,
  27466. "treatInscpTotal": treatInscpTotal,
  27467. "doctor_info": doctor_info,
  27468. "doctor_code": adminRole_two.DoctorCode,
  27469. "doctor_name": doctor_name,
  27470. "health_card_no": order.PsnNo,
  27471. "department": departments.Name,
  27472. "yiliao_leibie": yiliao_leibie,
  27473. "after_money": order.AccountPrice,
  27474. "patient": patient,
  27475. "org_name": miConfig.OrgName,
  27476. "org_code": miConfig.Code,
  27477. "order_number": order.Number,
  27478. "his_hospital": his_hospital,
  27479. "his": his,
  27480. "dia_config": dia_config,
  27481. "psn_cash_pay": order.PsnCashPay,
  27482. //"funds": rf,
  27483. //"check_order_info": cus_slice,
  27484. })
  27485. } else {
  27486. c.ServeSuccessJSON(map[string]interface{}{
  27487. "diagnosis": name,
  27488. "order_infos": orderInfos,
  27489. "number": order.MdtrtId,
  27490. "date": order.SettleAccountsDate,
  27491. "charge_admin": charge_admin,
  27492. "printor_admin": printor_admin,
  27493. "info": order,
  27494. "order": order,
  27495. "bedCostTotal": bedCostTotal,
  27496. "bedCostSelfTotal": bedCostSelfTotal,
  27497. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27498. "bedSelfTotal": bedSelfTotal,
  27499. "bedInscpTotal": bedInscpTotal,
  27500. "operationCostTotal": operationCostTotal,
  27501. "operationCostSelfTotal": operationCostSelfTotal,
  27502. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27503. "operationSelfTotal": operationSelfTotal,
  27504. "operationInscpTotal": operationInscpTotal,
  27505. "otherCostTotal": otherCostTotal,
  27506. "otherCostSelfTotal": otherCostSelfTotal,
  27507. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27508. "otherSelfTotal": otherSelfTotal,
  27509. "otherInscpTotal": otherInscpTotal,
  27510. "materialCostTotal": materialCostTotal,
  27511. "materialCostSelfTotal": materialCostSelfTotal,
  27512. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27513. "materialSelfTotal": materialSelfTotal,
  27514. "materialInscpTotal": materialInscpTotal,
  27515. "westernMedicineCostTotal": westernMedicineCostTotal,
  27516. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27517. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27518. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27519. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27520. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27521. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27522. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27523. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27524. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27525. "checkCostTotal": checkCostTotal,
  27526. "checkCostSelfTotal": checkCostSelfTotal,
  27527. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27528. "checkSelfTotal": checkSelfTotal,
  27529. "checkInscpTotal": checkInscpTotal,
  27530. "laboratoryCostTotal": laboratoryCostTotal,
  27531. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27532. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27533. "laboratorySelfTotal": laboratorySelfTotal,
  27534. "laboratoryInscpTotal": laboratoryInscpTotal,
  27535. "treatCostTotal": treatCostTotal,
  27536. "treatCostSelfTotal": treatCostSelfTotal,
  27537. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27538. "treatSelfTotal": treatSelfTotal,
  27539. "treatInscpTotal": treatInscpTotal,
  27540. "doctor_info": doctor_info,
  27541. "doctor_code": adminRole_two.DoctorCode,
  27542. "doctor_name": doctor_name,
  27543. "health_card_no": order.PsnNo,
  27544. "department": departments.Name,
  27545. "yiliao_leibie": yiliao_leibie,
  27546. "after_money": order.AccountPrice,
  27547. "patient": patient,
  27548. "org_name": miConfig.OrgName,
  27549. "org_code": miConfig.Code,
  27550. "order_number": order.Number,
  27551. "his_hospital": his_hospital,
  27552. "his": his,
  27553. "dia_config": dia_config,
  27554. "psn_cash_pay": order.PsnCashPay,
  27555. //"funds": rf,
  27556. //"check_order_info": cus_slice,
  27557. })
  27558. }
  27559. }
  27560. }
  27561. }
  27562. //func (c *HisApiController) CheckTreatment() {
  27563. // patient_id, _ := c.GetInt64("patient_id")
  27564. // id_card_no := c.GetString("id_card_no")
  27565. // insutype := c.GetString("insutype")
  27566. // med_type := c.GetString("med_type")
  27567. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27568. //
  27569. // adminUser := c.GetAdminUserInfo()
  27570. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27571. //
  27572. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27573. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27574. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27575. //
  27576. // if miConfig.MdtrtareaAdmvs == "421300" {
  27577. // var res ResultTwo
  27578. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27579. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27580. // "&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)
  27581. // resp, requestErr := http.Get(api)
  27582. // if requestErr != nil {
  27583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27584. // return
  27585. // }
  27586. //
  27587. // body, ioErr := ioutil.ReadAll(resp.Body)
  27588. // if ioErr != nil {
  27589. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27591. // return
  27592. // }
  27593. // var respJSON map[string]interface{}
  27594. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27595. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27597. // return
  27598. // }
  27599. //
  27600. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27601. // result, _ := json.Marshal(respJSON)
  27602. //
  27603. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27604. // utils.ErrorLog("解析失败:%v", err)
  27605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27606. // return
  27607. // }
  27608. //
  27609. // if res.Infcode == 0 {
  27610. //
  27611. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27612. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27613. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27614. // resp, requestErr := http.Get(api)
  27615. // if requestErr != nil {
  27616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27617. // return
  27618. // }
  27619. //
  27620. // body, ioErr := ioutil.ReadAll(resp.Body)
  27621. // if ioErr != nil {
  27622. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27624. // return
  27625. // }
  27626. // var respJSON map[string]interface{}
  27627. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27628. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27630. // return
  27631. // }
  27632. // var res Result2001
  27633. //
  27634. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27635. // result2, _ := json.Marshal(respJSON)
  27636. //
  27637. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27638. // utils.ErrorLog("解析失败:%v", err)
  27639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27640. // return
  27641. // }
  27642. //
  27643. // if res.Infcode == 0 {
  27644. // c.ServeSuccessJSON(map[string]interface{}{
  27645. // "msg": res.Output.Trtinfo,
  27646. // })
  27647. // }
  27648. //
  27649. // } else {
  27650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27651. // return
  27652. // }
  27653. //
  27654. // } else {
  27655. //
  27656. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27657. // var dat map[string]interface{}
  27658. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27659. // fmt.Println(dat)
  27660. // } else {
  27661. // fmt.Println(err)
  27662. // }
  27663. // userJSONBytes, _ := json.Marshal(dat)
  27664. // var res ResultTwo
  27665. // var res10265 ResultTwo10265
  27666. // if miConfig.Code == "H15049901371" {
  27667. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27668. // utils.ErrorLog("解析失败:%v", err)
  27669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27670. // return
  27671. // }
  27672. // res.ErrMsg = res10265.ErrMsg
  27673. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27674. // res.Infcode = infocode
  27675. // res.Output = res10265.Output
  27676. // res.InfRefmsgid = res10265.InfRefmsgid
  27677. // } else {
  27678. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27679. // utils.ErrorLog("解析失败:%v", err)
  27680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27681. // return
  27682. // }
  27683. // }
  27684. //
  27685. // var user_name string
  27686. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27687. // if role.ID == 0 {
  27688. // user_name = "xxx"
  27689. // } else {
  27690. // user_name = role.UserName
  27691. // }
  27692. //
  27693. // baseParams := models.BaseParams{
  27694. // SecretKey: miConfig.SecretKey,
  27695. // FixmedinsCode: miConfig.Code,
  27696. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27697. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27698. // OrgName: miConfig.OrgName,
  27699. // Doctor: user_name,
  27700. // }
  27701. //
  27702. // if config.IsOpen == 1 {
  27703. // if miConfig.Code == "H15049901371" {
  27704. // if med_type == "14" {
  27705. // if insutype == "390" {
  27706. // med_type = "9933"
  27707. // } else if insutype == "310" {
  27708. // med_type = "990502"
  27709. // }
  27710. // } else if med_type == "11" {
  27711. // med_type = "11"
  27712. // }
  27713. // }
  27714. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27715. // var dat map[string]interface{}
  27716. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27717. // fmt.Println(dat)
  27718. // } else {
  27719. // fmt.Println(err)
  27720. // }
  27721. // var res Result2001
  27722. // var res10265 Result2001Org10265
  27723. // if miConfig.Code == "H15049901371" {
  27724. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27725. // utils.ErrorLog("解析失败:%v", err)
  27726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27727. // return
  27728. // }
  27729. // res.ErrMsg = res10265.ErrMsg
  27730. // res.Output = res10265.Output
  27731. // res.InfRefmsgid = res10265.InfRefmsgid
  27732. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27733. // res.Infcode = infocode
  27734. // } else {
  27735. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27736. // utils.ErrorLog("解析失败:%v", err)
  27737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27738. // return
  27739. // }
  27740. // }
  27741. // if res.Infcode == 0 {
  27742. // c.ServeSuccessJSON(map[string]interface{}{
  27743. // "msg": res.Output.Trtinfo,
  27744. // })
  27745. // }
  27746. // }
  27747. // }
  27748. //}
  27749. //func (c *HisApiController) PutRecord() {
  27750. // id, _ := c.GetInt64("id")
  27751. // record_time := c.GetString("record_time")
  27752. // timeLayout := "2006-01-02"
  27753. // loc, _ := time.LoadLocation("Local")
  27754. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27755. // if err != nil {
  27756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27757. // return
  27758. // }
  27759. // recordDateTime := theTime.Unix()
  27760. //
  27761. // adminInfo := c.GetAdminUserInfo()
  27762. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27763. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27764. //
  27765. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27766. //
  27767. // fmt.Println(miConfig.SecretKey)
  27768. //
  27769. // if patient == nil {
  27770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27771. // return
  27772. // }
  27773. // if len(patient.IdCardNo) == 0 {
  27774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27775. // return
  27776. // }
  27777. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27778. // if config.IsOpen == 1 {
  27779. // 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
  27780. // resp, requestErr := http.Get(api)
  27781. // if requestErr != nil {
  27782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27783. // return
  27784. // }
  27785. // defer resp.Body.Close()
  27786. // body, ioErr := ioutil.ReadAll(resp.Body)
  27787. // if ioErr != nil {
  27788. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27790. // return
  27791. // }
  27792. // var respJSON map[string]interface{}
  27793. //
  27794. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27795. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27797. // return
  27798. // }
  27799. //
  27800. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27801. // userJSONBytes, _ := json.Marshal(userJSON)
  27802. // var res ResultTwo
  27803. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27804. // utils.ErrorLog("解析失败:%v", err)
  27805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27806. // return
  27807. // }
  27808. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27809. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27810. // infoStr := string(Iinfos)
  27811. // idetinfoStr := string(Idetinfos)
  27812. //
  27813. // if res.Infcode == 0 {
  27814. // his := models.VMHisPatient{
  27815. // Status: 1,
  27816. // Ctime: time.Now().Unix(),
  27817. // Mtime: time.Now().Unix(),
  27818. // PsnNo: res.Output.Baseinfo.PsnNo,
  27819. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27820. // Certno: res.Output.Baseinfo.Certno,
  27821. // PsnName: res.Output.Baseinfo.PsnName,
  27822. // Gend: res.Output.Baseinfo.Gend,
  27823. // Naty: res.Output.Baseinfo.Naty,
  27824. // Brdy: res.Output.Baseinfo.Brdy,
  27825. // Age: res.Output.Baseinfo.Age,
  27826. // Iinfo: infoStr,
  27827. // Idetinfo: idetinfoStr,
  27828. // PatientId: patient.ID,
  27829. // RecordDate: theTime.Unix(),
  27830. // UserOrgId: adminInfo.CurrentOrgId,
  27831. // AdminUserId: adminInfo.AdminUser.Id,
  27832. // IsReturn: 1,
  27833. // }
  27834. //
  27835. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27836. // //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")
  27837. // //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")
  27838. //
  27839. // //var dat map[string]interface{}
  27840. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27841. // // fmt.Println(dat)
  27842. // //} else {
  27843. // // fmt.Println(err)
  27844. // //}
  27845. //
  27846. // var dat2 map[string]interface{}
  27847. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27848. // fmt.Println(dat2)
  27849. // } else {
  27850. // fmt.Println(err)
  27851. // }
  27852. //
  27853. // } else {
  27854. // adminUser := c.GetAdminUserInfo()
  27855. // errlog := &models.HisOrderError{
  27856. // UserOrgId: adminUser.CurrentOrgId,
  27857. // Ctime: time.Now().Unix(),
  27858. // Mtime: time.Now().Unix(),
  27859. // ErrMsg: res.ErrMsg,
  27860. // Status: 1,
  27861. // PatientId: id,
  27862. // RecordTime: recordDateTime,
  27863. // Stage: 1,
  27864. // }
  27865. // service.CreateErrMsgLog(errlog)
  27866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  27867. // return
  27868. // }
  27869. // }
  27870. //
  27871. //}
  27872. //func (c *HisApiController) GetUploadDiag() {
  27873. // id, _ := c.GetInt64("id")
  27874. // record_time := c.GetString("record_time")
  27875. //
  27876. // diagnosis_id, _ := c.GetInt64("diagnosis")
  27877. // sick_type, _ := c.GetInt64("sick_type")
  27878. // reg_type, _ := c.GetInt64("reg_type")
  27879. //
  27880. // timeLayout := "2006-01-02"
  27881. // loc, _ := time.LoadLocation("Local")
  27882. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27883. // if err != nil {
  27884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27885. // return
  27886. // }
  27887. //
  27888. // var patientPrescription models.HisPrescriptionInfo
  27889. // recordDateTime := theTime.Unix()
  27890. // adminInfo := c.GetAdminUserInfo()
  27891. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27892. //
  27893. // if patientPrescription.ID == 0 {
  27894. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27895. // }
  27896. //
  27897. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27898. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27899. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27900. // sickConfig, _ := service.FindSickById(sick_type)
  27901. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27902. //
  27903. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  27904. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  27905. // "&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 +
  27906. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  27907. // resp2, requestErr2 := http.Get(api2)
  27908. // if requestErr2 != nil {
  27909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27910. // return
  27911. // }
  27912. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  27913. // if ioErr2 != nil {
  27914. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  27915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27916. // return
  27917. // }
  27918. // var respJSON2 map[string]interface{}
  27919. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  27920. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27922. // return
  27923. // }
  27924. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27925. // userJSONBytes2, _ := json.Marshal(respJSON2)
  27926. //
  27927. // var res2 ResultSix
  27928. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27929. // utils.ErrorLog("解析失败:%v", err)
  27930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27931. // return
  27932. // }
  27933. // if res2.Infcode != 0 {
  27934. // adminUser := c.GetAdminUserInfo()
  27935. // errlog := &models.HisOrderError{
  27936. // UserOrgId: adminUser.CurrentOrgId,
  27937. // Ctime: time.Now().Unix(),
  27938. // Mtime: time.Now().Unix(),
  27939. // ErrMsg: res2.ErrMsg,
  27940. // Status: 1,
  27941. // PatientId: id,
  27942. // RecordTime: recordDateTime,
  27943. // Stage: 3,
  27944. // }
  27945. // service.CreateErrMsgLog(errlog)
  27946. //
  27947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  27948. // return
  27949. // }
  27950. //
  27951. // c.ServeSuccessJSON(map[string]interface{}{
  27952. // "msg": "上传成功",
  27953. // })
  27954. //
  27955. //}
  27956. type QueryResult struct {
  27957. ID int64
  27958. Name string
  27959. Code string
  27960. List_type_code string
  27961. }
  27962. func (c *HisApiController) GetCheckCode() {
  27963. ids_str := c.GetString("ids")
  27964. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27965. ids_arr := strings.Split(ids_str, ",")
  27966. var queryResult []QueryResult
  27967. ids := make([]int64, 0)
  27968. for _, item := range ids_arr {
  27969. id, _ := strconv.ParseInt(item, 10, 64)
  27970. ids = append(ids, id)
  27971. }
  27972. if record_type == 1 {
  27973. drugs, _ := service.GetBatchDrugList(ids)
  27974. for _, item := range drugs {
  27975. result := QueryResult{
  27976. ID: item.ID,
  27977. Name: item.DrugName,
  27978. Code: item.MedicalInsuranceNumber,
  27979. List_type_code: "101",
  27980. }
  27981. queryResult = append(queryResult, result)
  27982. }
  27983. } else if record_type == 2 {
  27984. goods, _ := service.GetBatchGoodInformationList(ids)
  27985. fmt.Println(goods)
  27986. for _, item := range goods {
  27987. result := QueryResult{
  27988. ID: item.ID,
  27989. Name: item.GoodName,
  27990. Code: item.SocialSecurityDirectoryCode,
  27991. List_type_code: "301",
  27992. }
  27993. queryResult = append(queryResult, result)
  27994. }
  27995. } else if record_type == 3 {
  27996. projects, _ := service.GetBathchMyPorjecgList(ids)
  27997. for _, item := range projects {
  27998. result := QueryResult{
  27999. ID: item.ID,
  28000. Name: item.ProjectName,
  28001. Code: item.MedicalCode,
  28002. List_type_code: "201",
  28003. }
  28004. queryResult = append(queryResult, result)
  28005. }
  28006. }
  28007. admin_user_id, _ := c.GetInt64("admin_user_id")
  28008. adminUser := c.GetAdminUserInfo()
  28009. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28010. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28011. var user_name string
  28012. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28013. if role.ID == 0 {
  28014. user_name = "管理员"
  28015. } else {
  28016. user_name = role.UserName
  28017. }
  28018. baseParams := models.BaseParams{
  28019. SecretKey: miConfig.SecretKey,
  28020. FixmedinsCode: miConfig.Code,
  28021. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28022. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28023. OrgName: miConfig.OrgName,
  28024. Doctor: user_name,
  28025. }
  28026. var result string
  28027. if miConfig.MdtrtareaAdmvs == "430800" {
  28028. for _, item := range queryResult {
  28029. if record_type == 1 {
  28030. 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)
  28031. } else if record_type == 2 {
  28032. fmt.Println(item.Code)
  28033. 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)
  28034. } else if record_type == 3 {
  28035. 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)
  28036. }
  28037. var dat map[string]interface{}
  28038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28039. fmt.Println(dat)
  28040. } else {
  28041. fmt.Println(err)
  28042. }
  28043. userJSONBytes, _ := json.Marshal(dat)
  28044. var res ResultSix
  28045. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28046. utils.ErrorLog("解析失败:%v", err)
  28047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28048. return
  28049. }
  28050. if res.Infcode == 0 {
  28051. if record_type == 1 {
  28052. service.UpdateBaseDrugById(item.ID)
  28053. } else if record_type == 2 {
  28054. service.UpdateGoodInformaitonByDetail(item.ID)
  28055. } else if record_type == 3 {
  28056. service.UpdateProjectById(item.ID)
  28057. }
  28058. c.ServeSuccessJSON(map[string]interface{}{
  28059. "failed_code": 0,
  28060. "msg": "目录对照成功",
  28061. })
  28062. } else {
  28063. c.ServeSuccessJSON(map[string]interface{}{
  28064. "failed_code": -10,
  28065. "msg": res.ErrMsg,
  28066. })
  28067. }
  28068. }
  28069. } else {
  28070. for _, item := range queryResult {
  28071. var result string
  28072. if record_type == 1 {
  28073. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28074. } else if record_type == 2 {
  28075. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28076. } else if record_type == 3 {
  28077. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28078. }
  28079. var dat map[string]interface{}
  28080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28081. fmt.Println(dat)
  28082. } else {
  28083. fmt.Println(err)
  28084. }
  28085. userJSONBytes, _ := json.Marshal(dat)
  28086. var res ResultSix
  28087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28088. utils.ErrorLog("解析失败:%v", err)
  28089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28090. return
  28091. }
  28092. if res.Infcode == 0 {
  28093. if record_type == 1 {
  28094. service.UpdateBaseDrugById(item.ID)
  28095. } else if record_type == 2 {
  28096. service.UpdateGoodInformaitonByDetail(item.ID)
  28097. } else if record_type == 3 {
  28098. service.UpdateProjectById(item.ID)
  28099. }
  28100. c.ServeSuccessJSON(map[string]interface{}{
  28101. "failed_code": 0,
  28102. "msg": "目录对照成功",
  28103. })
  28104. } else {
  28105. c.ServeSuccessJSON(map[string]interface{}{
  28106. "failed_code": -10,
  28107. "msg": res.ErrMsg,
  28108. })
  28109. }
  28110. }
  28111. }
  28112. }
  28113. func (c *HisApiController) UnCheckCode() {
  28114. ids_str := c.GetString("ids")
  28115. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28116. admin_user_id, _ := c.GetInt64("admin_user_id")
  28117. ids_arr := strings.Split(ids_str, ",")
  28118. var queryResult []QueryResult
  28119. ids := make([]int64, 0)
  28120. for _, item := range ids_arr {
  28121. id, _ := strconv.ParseInt(item, 10, 64)
  28122. ids = append(ids, id)
  28123. }
  28124. if record_type == 1 {
  28125. drugs, _ := service.GetBatchDrugList(ids)
  28126. for _, item := range drugs {
  28127. result := QueryResult{
  28128. ID: item.ID,
  28129. Name: item.DrugName,
  28130. Code: item.MedicalInsuranceNumber,
  28131. List_type_code: "101",
  28132. }
  28133. queryResult = append(queryResult, result)
  28134. }
  28135. } else if record_type == 2 {
  28136. goods, _ := service.GetBatchGoodInformationList(ids)
  28137. for _, item := range goods {
  28138. result := QueryResult{
  28139. ID: item.ID,
  28140. Name: item.GoodName,
  28141. Code: item.SocialSecurityDirectoryCode,
  28142. List_type_code: "301",
  28143. }
  28144. queryResult = append(queryResult, result)
  28145. }
  28146. } else if record_type == 3 {
  28147. projects, _ := service.GetBathchMyPorjecgList(ids)
  28148. for _, item := range projects {
  28149. result := QueryResult{
  28150. ID: item.ID,
  28151. Name: item.ProjectName,
  28152. Code: item.MedicalCode,
  28153. List_type_code: "201",
  28154. }
  28155. queryResult = append(queryResult, result)
  28156. }
  28157. }
  28158. adminUser := c.GetAdminUserInfo()
  28159. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28160. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28161. var user_name string
  28162. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28163. if role.ID == 0 {
  28164. user_name = "xxx"
  28165. } else {
  28166. user_name = role.UserName
  28167. }
  28168. baseParams := &models.BaseParams{
  28169. SecretKey: miConfig.SecretKey,
  28170. FixmedinsCode: miConfig.Code,
  28171. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28172. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28173. OrgName: miConfig.OrgName,
  28174. Doctor: user_name,
  28175. }
  28176. if config.IsOpen == 1 {
  28177. if miConfig.MdtrtareaAdmvs == "430800" {
  28178. for _, item := range queryResult {
  28179. var result string
  28180. if record_type == 1 {
  28181. 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)
  28182. } else if record_type == 2 {
  28183. fmt.Println(item.Code)
  28184. 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)
  28185. } else if record_type == 3 {
  28186. 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)
  28187. }
  28188. var dat map[string]interface{}
  28189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28190. fmt.Println(dat)
  28191. } else {
  28192. fmt.Println(err)
  28193. }
  28194. userJSONBytes, _ := json.Marshal(dat)
  28195. var res ResultSix
  28196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28197. utils.ErrorLog("解析失败:%v", err)
  28198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28199. return
  28200. }
  28201. if res.Infcode == 0 {
  28202. if record_type == 1 {
  28203. service.UpdateBaseDrugById(item.ID)
  28204. } else if record_type == 2 {
  28205. service.UpdateGoodInformaitonByDetail(item.ID)
  28206. } else if record_type == 3 {
  28207. service.UpdateProjectById(item.ID)
  28208. }
  28209. c.ServeSuccessJSON(map[string]interface{}{
  28210. "failed_code": 0,
  28211. "msg": "目录对照成功",
  28212. })
  28213. } else {
  28214. c.ServeSuccessJSON(map[string]interface{}{
  28215. "failed_code": -10,
  28216. "msg": res.ErrMsg,
  28217. })
  28218. }
  28219. }
  28220. } else {
  28221. for _, item := range queryResult {
  28222. var result string
  28223. if record_type == 1 {
  28224. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28225. } else if record_type == 2 {
  28226. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28227. } else if record_type == 3 {
  28228. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28229. }
  28230. var dat2 map[string]interface{}
  28231. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28232. fmt.Println(dat2)
  28233. } else {
  28234. fmt.Println(err)
  28235. }
  28236. userJSONBytes, _ := json.Marshal(dat2)
  28237. var res ResultSix
  28238. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28239. utils.ErrorLog("解析失败:%v", err)
  28240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28241. return
  28242. }
  28243. if res.Infcode == 0 {
  28244. if record_type == 1 {
  28245. service.UpdateDrugByIdDetail(item.ID)
  28246. } else if record_type == 2 {
  28247. service.UpdateGoodInfoById(item.ID)
  28248. } else if record_type == 3 {
  28249. service.UpdateMyProjectById(item.ID)
  28250. }
  28251. c.ServeSuccessJSON(map[string]interface{}{
  28252. "failed_code": 0,
  28253. "msg": "撤销目录对照成功",
  28254. })
  28255. } else {
  28256. c.ServeSuccessJSON(map[string]interface{}{
  28257. "failed_code": -10,
  28258. "msg": res.ErrMsg,
  28259. })
  28260. }
  28261. }
  28262. }
  28263. }
  28264. }
  28265. func (c *HisApiController) GetPatientInfo() {
  28266. id_card_no := c.GetString("id_card_no")
  28267. admin_user_id, _ := c.GetInt64("admin_user_id")
  28268. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28269. if patient.ID == 0 {
  28270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28271. return
  28272. }
  28273. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28274. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28275. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28276. var res ResultTwo
  28277. var res10265 ResultTwo10265
  28278. if config.IsOpen == 1 {
  28279. if miConfig.MdtrtareaAdmvs == "150499" {
  28280. //请求内网数据
  28281. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28282. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28283. "&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
  28284. resp, requestErr := http.Get(api)
  28285. if requestErr != nil {
  28286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28287. return
  28288. }
  28289. body, ioErr := ioutil.ReadAll(resp.Body)
  28290. if ioErr != nil {
  28291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28293. return
  28294. }
  28295. var respJSON map[string]interface{}
  28296. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28299. return
  28300. }
  28301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28302. result_byte, _ := json.Marshal(respJSON)
  28303. result := string(result_byte)
  28304. var dat map[string]interface{}
  28305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28306. fmt.Println(dat)
  28307. } else {
  28308. fmt.Println(err)
  28309. }
  28310. userJSONBytes, _ := json.Marshal(dat)
  28311. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28312. utils.ErrorLog("解析失败:%v", err)
  28313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28314. return
  28315. }
  28316. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28317. res.Infcode = Infcode
  28318. res.ErrMsg = res10265.ErrMsg
  28319. res.Output = res10265.Output
  28320. res.InfRefmsgid = res10265.InfRefmsgid
  28321. res.RespondTime = res10265.RespondTime
  28322. res.WarnInfo = res10265.WarnInfo
  28323. } else {
  28324. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28325. var dat map[string]interface{}
  28326. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28327. fmt.Println(dat)
  28328. } else {
  28329. fmt.Println(err)
  28330. }
  28331. userJSONBytes, _ := json.Marshal(dat)
  28332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28333. utils.ErrorLog("解析失败:%v", err)
  28334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28335. return
  28336. }
  28337. }
  28338. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28339. // utils.ErrorLog("解析失败:%v", err)
  28340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28341. // return
  28342. //}
  28343. for index, item := range res.Output.Iinfo {
  28344. if item.PsnInsuStas == "2" {
  28345. fmt.Println("--------")
  28346. res.Output.Iinfo[index].Insutype = "300"
  28347. res.Output.Iinfo[index].PsnInsuStas = "1"
  28348. }
  28349. }
  28350. fmt.Println(res.Output.Iinfo)
  28351. if res.Infcode != 0 {
  28352. c.ServeSuccessJSON(map[string]interface{}{
  28353. "failed_code": -10,
  28354. "msg": res.ErrMsg,
  28355. })
  28356. } else {
  28357. c.ServeSuccessJSON(map[string]interface{}{
  28358. "failed_code": 0,
  28359. "info": res,
  28360. })
  28361. }
  28362. }
  28363. }
  28364. func (c *HisApiController) PsnPutOnRecord() {
  28365. record_type, _ := c.GetInt64("type")
  28366. patient_id, _ := c.GetInt64("patient_id")
  28367. admin_user_id, _ := c.GetInt64("admin_user_id")
  28368. start_time := c.GetString("start_time")
  28369. end_time := c.GetString("end_time")
  28370. adminUser := c.GetAdminUserInfo()
  28371. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28372. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28373. var patients []*models.Patients
  28374. if record_type == 1 { //全部备案
  28375. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28376. patients = append(patients, patient...)
  28377. } else { //单个备案
  28378. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28379. patients = append(patients, patient)
  28380. }
  28381. var user_name string
  28382. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28383. if role.ID == 0 {
  28384. user_name = "xxx"
  28385. } else {
  28386. user_name = role.UserName
  28387. }
  28388. if config.IsOpen == 1 {
  28389. for _, item := range patients {
  28390. 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
  28391. resp, requestErr := http.Get(api)
  28392. if requestErr != nil {
  28393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28394. return
  28395. }
  28396. defer resp.Body.Close()
  28397. body, ioErr := ioutil.ReadAll(resp.Body)
  28398. if ioErr != nil {
  28399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28401. return
  28402. }
  28403. var respJSON map[string]interface{}
  28404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28407. return
  28408. }
  28409. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28410. userJSONBytes, _ := json.Marshal(userJSON)
  28411. var res ResultTwo
  28412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28413. utils.ErrorLog("解析失败:%v", err)
  28414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28415. return
  28416. }
  28417. if res.Infcode == 0 {
  28418. 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)
  28419. var dat map[string]interface{}
  28420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28421. fmt.Println(dat)
  28422. } else {
  28423. fmt.Println(err)
  28424. }
  28425. userJSONBytes, _ := json.Marshal(dat)
  28426. var res2 ResultThirteen
  28427. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28428. utils.ErrorLog("解析失败:%v", err)
  28429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28430. return
  28431. }
  28432. if res2.Infcode == 0 {
  28433. psnResult := &models.GdybPsnRecord{
  28434. UserOrgId: adminUser.CurrentOrgId,
  28435. PatientId: item.ID,
  28436. PsnNo: res.Output.Baseinfo.PsnNo,
  28437. Ctime: time.Now().Unix(),
  28438. Mtime: time.Now().Unix(),
  28439. Status: 1,
  28440. IsCancel: 1,
  28441. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28442. }
  28443. service.CreatePsnRecord(psnResult)
  28444. } else {
  28445. c.ServeSuccessJSON(map[string]interface{}{
  28446. "failed_code": -10,
  28447. "msg": res2.ErrMsg,
  28448. })
  28449. return
  28450. }
  28451. }
  28452. }
  28453. }
  28454. }
  28455. func (c *HisApiController) PsnUnPutOnRecord() {
  28456. id, _ := c.GetInt64("id")
  28457. //record_type, _ := c.GetInt64("type")
  28458. admin_user_id, _ := c.GetInt64("admin_user_id")
  28459. adminUser := c.GetAdminUserInfo()
  28460. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28461. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28462. var user_name string
  28463. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28464. if role.ID == 0 {
  28465. user_name = "xxx"
  28466. } else {
  28467. user_name = role.UserName
  28468. }
  28469. psn_record, _ := service.GetPsnRecordById(id)
  28470. if psn_record.ID == 0 {
  28471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28472. return
  28473. }
  28474. if config.IsOpen == 1 {
  28475. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28476. var dat map[string]interface{}
  28477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28478. fmt.Println(dat)
  28479. } else {
  28480. fmt.Println(err)
  28481. }
  28482. userJSONBytes, _ := json.Marshal(dat)
  28483. var res ResultFourteen
  28484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28485. utils.ErrorLog("解析失败:%v", err)
  28486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28487. return
  28488. }
  28489. if res.Infcode == 0 {
  28490. psn_record.IsCancel = 2
  28491. service.CreatePsnRecord(&psn_record)
  28492. } else {
  28493. c.ServeSuccessJSON(map[string]interface{}{
  28494. "failed_code": -10,
  28495. "msg": res.ErrMsg,
  28496. })
  28497. return
  28498. }
  28499. }
  28500. }
  28501. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28502. patient_id, _ := c.GetInt64("patient_id")
  28503. insutype_two := c.GetString("insutype")
  28504. psn_no := c.GetString("psn_no")
  28505. doctor_id, _ := c.GetInt64("doctor_id")
  28506. sick_id, _ := c.GetInt64("sick_id")
  28507. department_id, _ := c.GetInt64("department_id")
  28508. start_time := c.GetString("start_time")
  28509. end_time := c.GetString("end_time")
  28510. check_time := c.GetString("check_time")
  28511. hospital_code := c.GetString("hospital_code")
  28512. hospital_name := c.GetString("hospital_name")
  28513. adminUser := c.GetAdminUserInfo()
  28514. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28515. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28516. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28517. sick, _ := service.FindSickById(sick_id)
  28518. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28519. if len(hospital_code) == 0 {
  28520. hospital_code = miConfig.Code
  28521. }
  28522. if len(hospital_name) == 0 {
  28523. hospital_name = miConfig.OrgName
  28524. }
  28525. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28526. var res ResultTwo
  28527. var res10265 ResultTwo10265
  28528. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28529. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28530. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28531. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28532. "&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
  28533. resp, requestErr := http.Get(api)
  28534. if requestErr != nil {
  28535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28536. return
  28537. }
  28538. body, ioErr := ioutil.ReadAll(resp.Body)
  28539. if ioErr != nil {
  28540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28542. return
  28543. }
  28544. var respJSON map[string]interface{}
  28545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28548. return
  28549. }
  28550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28551. result, _ := json.Marshal(respJSON)
  28552. fmt.Println("log")
  28553. fmt.Println(string(result))
  28554. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28555. utils.ErrorLog("解析失败:%v", err)
  28556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28557. return
  28558. }
  28559. res.ErrMsg = res10265.ErrMsg
  28560. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28561. res.Infcode = infocode
  28562. res.Output = res10265.Output
  28563. res.InfRefmsgid = res10265.InfRefmsgid
  28564. } else {
  28565. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28566. if miConfig.Code == "H15049901371" {
  28567. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28568. utils.ErrorLog("解析失败:%v", err)
  28569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28570. return
  28571. }
  28572. res.ErrMsg = res10265.ErrMsg
  28573. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28574. res.Infcode = infocode
  28575. res.Output = res10265.Output
  28576. res.InfRefmsgid = res10265.InfRefmsgid
  28577. } else {
  28578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28579. utils.ErrorLog("解析失败:%v", err)
  28580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28581. return
  28582. }
  28583. }
  28584. }
  28585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28586. infoStr := string(Iinfos)
  28587. var rf []*ResultFive
  28588. json.Unmarshal([]byte(infoStr), &rf)
  28589. var insuplc_admdvs string
  28590. var insutype string
  28591. var is390 int = 0
  28592. var is310 int = 0
  28593. var insutypes []*ResultFive
  28594. for _, item := range rf {
  28595. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28596. insutypes = append(insutypes, item)
  28597. }
  28598. }
  28599. if len(insutypes) == 1 {
  28600. insutype = insutypes[0].Insutype
  28601. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28602. } else {
  28603. for _, i := range insutypes {
  28604. if i.Insutype == "390" {
  28605. is390 = 1
  28606. }
  28607. if i.Insutype == "310" {
  28608. is310 = 1
  28609. }
  28610. }
  28611. }
  28612. if is390 == 1 {
  28613. insutype = "390"
  28614. }
  28615. if is310 == 1 {
  28616. insutype = "310"
  28617. }
  28618. if len(insutypes) == 2 {
  28619. insutype = insutype_two
  28620. }
  28621. if len(insutypes) == 0 {
  28622. insutype = "310"
  28623. }
  28624. insutype = insutype_two
  28625. fmt.Println(insutype)
  28626. for _, item := range rf {
  28627. fmt.Println(item.Insutype)
  28628. fmt.Println(insutype)
  28629. if item.Insutype == insutype {
  28630. fmt.Println(item.Insutype)
  28631. fmt.Println(insutype)
  28632. insuplc_admdvs = item.InsuplcAdmdvs
  28633. }
  28634. }
  28635. fmt.Println(insuplc_admdvs)
  28636. var res2 ResultThirteen
  28637. var res10265_2 ResultThirteen10265
  28638. if config.IsOpen == 1 {
  28639. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28640. } else {
  28641. if miConfig.MdtrtareaAdmvs == "150499" {
  28642. //
  28643. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28644. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28645. // "&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
  28646. //resp, requestErr := http.Get(api)
  28647. //if requestErr != nil {
  28648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28649. // return
  28650. //}
  28651. //
  28652. //body, ioErr := ioutil.ReadAll(resp.Body)
  28653. //if ioErr != nil {
  28654. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28656. // return
  28657. //}
  28658. //var respJSON map[string]interface{}
  28659. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28660. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28662. // return
  28663. //}
  28664. //
  28665. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28666. //result, _ := json.Marshal(respJSON)
  28667. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28668. // utils.ErrorLog("解析失败:%v", err)
  28669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28670. // return
  28671. //}
  28672. //infocode = resThree.Infcode
  28673. //result, _ := json.Marshal(respJSON)
  28674. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28675. // utils.ErrorLog("解析失败:%v", err)
  28676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28677. // return
  28678. //}
  28679. //
  28680. //resThree.ErrMsg = resThree10265.ErrMsg
  28681. //
  28682. //resThree.Output = resThree10265.Output
  28683. //
  28684. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28685. //
  28686. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28687. //
  28688. } else {
  28689. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  28690. var dat map[string]interface{}
  28691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28692. fmt.Println(dat)
  28693. } else {
  28694. fmt.Println(err)
  28695. }
  28696. userJSONBytes, _ := json.Marshal(dat)
  28697. if miConfig.Code == "H15049901371" {
  28698. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28699. utils.ErrorLog("解析失败:%v", err)
  28700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28701. return
  28702. }
  28703. res2.ErrMsg = res10265_2.ErrMsg
  28704. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28705. res2.Infcode = infocode
  28706. res2.Output = res10265_2.Output
  28707. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28708. } else {
  28709. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28710. utils.ErrorLog("解析失败:%v", err)
  28711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28712. return
  28713. }
  28714. }
  28715. }
  28716. }
  28717. if res2.Infcode == 0 {
  28718. psnResult := &models.GdybPsnNcdsRecord{
  28719. UserOrgId: adminUser.CurrentOrgId,
  28720. PatientId: patient.ID,
  28721. PsnNo: psn_no,
  28722. DoctorId: doctor.AdminUserId,
  28723. DepartmentId: department_id,
  28724. SickType: sick_id,
  28725. Insutype: insutype,
  28726. Ctime: time.Now().Unix(),
  28727. Mtime: time.Now().Unix(),
  28728. Status: 1,
  28729. IsCancel: 1,
  28730. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28731. }
  28732. service.CreatePsnNCDSRecord(psnResult)
  28733. c.ServeSuccessJSON(map[string]interface{}{
  28734. "failed_code": 0,
  28735. "msg": "备案成功",
  28736. "result": psnResult,
  28737. })
  28738. } else {
  28739. c.ServeSuccessJSON(map[string]interface{}{
  28740. "failed_code": -10,
  28741. "msg": res2.ErrMsg,
  28742. })
  28743. return
  28744. }
  28745. }
  28746. }
  28747. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28748. id, _ := c.GetInt64("id")
  28749. admin_user_id, _ := c.GetInt64("admin_user_id")
  28750. adminUser := c.GetAdminUserInfo()
  28751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28752. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28753. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28754. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28755. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28756. //var user_name string
  28757. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28758. //if role.ID == 0 {
  28759. // user_name = "xxx"
  28760. //} else {
  28761. // user_name = role.UserName
  28762. //}
  28763. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28764. if psn_record.ID == 0 {
  28765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28766. return
  28767. }
  28768. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28769. var res ResultTwo
  28770. var res10265 ResultTwo10265
  28771. if miConfig.Code == "H15049901371" {
  28772. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28773. utils.ErrorLog("解析失败:%v", err)
  28774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28775. return
  28776. }
  28777. res.ErrMsg = res10265.ErrMsg
  28778. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28779. res.Infcode = infocode
  28780. res.Output = res10265.Output
  28781. res.InfRefmsgid = res10265.InfRefmsgid
  28782. } else {
  28783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28784. utils.ErrorLog("解析失败:%v", err)
  28785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28786. return
  28787. }
  28788. }
  28789. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28790. infoStr := string(Iinfos)
  28791. var rf []*ResultFive
  28792. json.Unmarshal([]byte(infoStr), &rf)
  28793. var insuplc_admdvs string
  28794. var insutype string
  28795. var is390 int = 0
  28796. var is310 int = 0
  28797. var insutypes []*ResultFive
  28798. for _, item := range rf {
  28799. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28800. insutypes = append(insutypes, item)
  28801. }
  28802. }
  28803. if len(insutypes) == 1 {
  28804. insutype = insutypes[0].Insutype
  28805. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28806. } else {
  28807. for _, i := range insutypes {
  28808. if i.Insutype == "390" {
  28809. is390 = 1
  28810. }
  28811. if i.Insutype == "310" {
  28812. is310 = 1
  28813. }
  28814. }
  28815. }
  28816. if is390 == 1 {
  28817. insutype = "390"
  28818. }
  28819. if is310 == 1 {
  28820. insutype = "310"
  28821. }
  28822. if len(insutypes) == 0 {
  28823. insutype = "310"
  28824. }
  28825. insutype = psn_record.Insutype
  28826. for _, item := range rf {
  28827. if item.Insutype == insutype {
  28828. insuplc_admdvs = item.InsuplcAdmdvs
  28829. }
  28830. }
  28831. if config.IsOpen == 1 {
  28832. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28833. var dat map[string]interface{}
  28834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28835. fmt.Println(dat)
  28836. } else {
  28837. fmt.Println(err)
  28838. }
  28839. userJSONBytes, _ := json.Marshal(dat)
  28840. var res ResultFourteen
  28841. var res10265 ResultFourteen10265
  28842. if miConfig.Code == "H15049901371" {
  28843. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28844. utils.ErrorLog("解析失败:%v", err)
  28845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28846. return
  28847. }
  28848. res.ErrMsg = res10265.ErrMsg
  28849. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28850. res.Infcode = infocode
  28851. res.Output = res10265.Output
  28852. res.InfRefmsgid = res10265.InfRefmsgid
  28853. } else {
  28854. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28855. utils.ErrorLog("解析失败:%v", err)
  28856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28857. return
  28858. }
  28859. }
  28860. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28861. // utils.ErrorLog("解析失败:%v", err)
  28862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28863. // return
  28864. //}
  28865. if res.Infcode == 0 {
  28866. psn_record.IsCancel = 2
  28867. service.CreatePsnNCDSRecord(&psn_record)
  28868. c.ServeSuccessJSON(map[string]interface{}{
  28869. "failed_code": 0,
  28870. "msg": "撤销备案成功",
  28871. })
  28872. } else {
  28873. c.ServeSuccessJSON(map[string]interface{}{
  28874. "failed_code": -10,
  28875. "msg": res.ErrMsg,
  28876. })
  28877. return
  28878. }
  28879. }
  28880. }
  28881. func (c *HisApiController) TestTest() {
  28882. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  28883. fmt.Println(patient.Iinfo)
  28884. }
  28885. type CustomData struct {
  28886. MsgId string
  28887. PsnNo string
  28888. Info string
  28889. }
  28890. func (c *HisApiController) ReversalData() {
  28891. var customData []*CustomData
  28892. custom := &CustomData{
  28893. MsgId: "H44022900158202103301714472004",
  28894. PsnNo: "44020000001101329945",
  28895. Info: "2207",
  28896. }
  28897. customData = append(customData, custom)
  28898. custom1 := &CustomData{
  28899. MsgId: "H4402290015820210330172057803",
  28900. PsnNo: "44020000001101161813",
  28901. Info: "2207",
  28902. }
  28903. customData = append(customData, custom1)
  28904. custom2 := &CustomData{
  28905. MsgId: "H44022900158202103301705198813",
  28906. PsnNo: "44190000133097375417",
  28907. Info: "2207",
  28908. }
  28909. customData = append(customData, custom2)
  28910. custom3 := &CustomData{
  28911. MsgId: "H44022900158202103301715524756",
  28912. PsnNo: "44020000001100187221",
  28913. Info: "2207",
  28914. }
  28915. customData = append(customData, custom3)
  28916. custom4 := &CustomData{
  28917. MsgId: "H44022900158202103301730376224",
  28918. PsnNo: "44020000001101959155",
  28919. Info: "2207",
  28920. }
  28921. customData = append(customData, custom4)
  28922. custom5 := &CustomData{
  28923. MsgId: "H44022900158202103301748008725",
  28924. PsnNo: "44020000001104246641",
  28925. Info: "2207",
  28926. }
  28927. customData = append(customData, custom5)
  28928. custom6 := &CustomData{
  28929. MsgId: "H44022900158202103301718096755",
  28930. PsnNo: "44020000001102211860",
  28931. Info: "2207",
  28932. }
  28933. customData = append(customData, custom6)
  28934. custom7 := &CustomData{
  28935. MsgId: "H44022900158202103301736551640",
  28936. PsnNo: "44020000001102687718",
  28937. Info: "2207",
  28938. }
  28939. customData = append(customData, custom7)
  28940. custom8 := &CustomData{
  28941. MsgId: "H44022900158202103301743097676",
  28942. PsnNo: "44020000001102127785",
  28943. Info: "2207",
  28944. }
  28945. customData = append(customData, custom8)
  28946. custom9 := &CustomData{
  28947. MsgId: "H44022900158202103301712304203",
  28948. PsnNo: "44020000001101518097",
  28949. Info: "2207",
  28950. }
  28951. customData = append(customData, custom9)
  28952. custom10 := &CustomData{
  28953. MsgId: "H44022900158202103301738448785",
  28954. PsnNo: "44020000001100500813",
  28955. Info: "2207",
  28956. }
  28957. customData = append(customData, custom10)
  28958. custom11 := &CustomData{
  28959. MsgId: "H44022900158202103301732455843",
  28960. PsnNo: "44020000001102690557",
  28961. Info: "2207",
  28962. }
  28963. customData = append(customData, custom11)
  28964. custom12 := &CustomData{
  28965. MsgId: "H44022900158202103301745421708",
  28966. PsnNo: "44020000001102211928",
  28967. Info: "2207",
  28968. }
  28969. customData = append(customData, custom12)
  28970. custom1212 := &CustomData{
  28971. MsgId: "H440229001582021033017351627",
  28972. PsnNo: "44020000001102481733",
  28973. Info: "2207",
  28974. }
  28975. customData = append(customData, custom1212)
  28976. custom13 := &CustomData{
  28977. MsgId: "H44022900158202103301740327951",
  28978. PsnNo: "44020000001103174866",
  28979. Info: "2207",
  28980. }
  28981. customData = append(customData, custom13)
  28982. custom14 := &CustomData{
  28983. MsgId: "H4402290015820210330174922668",
  28984. PsnNo: "44020000001102927272",
  28985. Info: "2207",
  28986. }
  28987. customData = append(customData, custom14)
  28988. custom15 := &CustomData{
  28989. MsgId: "H44022900158202103301752362273",
  28990. PsnNo: "44020000001102942890",
  28991. Info: "2207",
  28992. }
  28993. customData = append(customData, custom15)
  28994. custom16 := &CustomData{
  28995. MsgId: "H44022900158202103301751082917",
  28996. PsnNo: "44020000001101662162",
  28997. Info: "2207",
  28998. }
  28999. customData = append(customData, custom16)
  29000. custom17 := &CustomData{
  29001. MsgId: "H44022900158202103301754147728",
  29002. PsnNo: "44020000000229014511",
  29003. Info: "2207",
  29004. }
  29005. customData = append(customData, custom17)
  29006. adminUser := c.GetAdminUserInfo()
  29007. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29008. for _, item := range customData {
  29009. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29010. fmt.Println(result)
  29011. }
  29012. }
  29013. func (c *HisApiController) GetAllopatry() {
  29014. year := c.GetString("year")
  29015. month := c.GetString("month")
  29016. admin_user_id, _ := c.GetInt64("admin_user_id")
  29017. adminUser := c.GetAdminUserInfo()
  29018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29019. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29020. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29021. var dat map[string]interface{}
  29022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29023. fmt.Println(dat)
  29024. } else {
  29025. fmt.Println(err)
  29026. }
  29027. userJSONBytes, _ := json.Marshal(dat)
  29028. var res models.Result9001
  29029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29030. utils.ErrorLog("解析失败:%v", err)
  29031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29032. return
  29033. }
  29034. fmt.Println(res.Output.Signinoutb)
  29035. fmt.Println(res.Output.Signinoutb.SignNo)
  29036. fmt.Println(string(userJSONBytes))
  29037. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29038. var dat3 map[string]interface{}
  29039. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  29040. fmt.Println(dat3)
  29041. } else {
  29042. fmt.Println(err)
  29043. }
  29044. userJSONBytes3, _ := json.Marshal(dat3)
  29045. var res3 models.Result3260
  29046. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29047. utils.ErrorLog("解析失败:%v", err)
  29048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29049. return
  29050. }
  29051. var curpage int
  29052. var pagesize int = 100
  29053. var start int = 1
  29054. //var stop int
  29055. //pagecount := 10
  29056. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  29057. var res22 []models.Result3260
  29058. for curpage = 1; curpage <= pagecount; curpage++ {
  29059. if curpage == 1 {
  29060. start = 0
  29061. } else {
  29062. start = (curpage-1)*pagesize + 1
  29063. }
  29064. fmt.Println(start)
  29065. //stop = curpage * pagesize
  29066. //if stop > int(res3.Output.Totalrow) {
  29067. // stop =int(res3.Output.Totalrow)
  29068. //}
  29069. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  29070. var dat2 map[string]interface{}
  29071. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29072. fmt.Println(dat)
  29073. } else {
  29074. fmt.Println(err)
  29075. }
  29076. userJSONBytes2, _ := json.Marshal(dat2)
  29077. var res2 models.Result3260
  29078. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29079. utils.ErrorLog("解析失败:%v", err)
  29080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29081. return
  29082. }
  29083. if res2.Infcode == 0 {
  29084. res22 = append(res22, res2)
  29085. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29086. //var dat2 map[string]interface{}
  29087. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29088. // fmt.Println(dat)
  29089. //} else {
  29090. // fmt.Println(err)
  29091. //}
  29092. //c.ServeSuccessJSON(map[string]interface{}{
  29093. // "list": res2.Output.Data,
  29094. //})
  29095. //continue
  29096. }
  29097. }
  29098. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29099. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29100. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  29101. //var dat2 map[string]interface{}
  29102. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29103. // fmt.Println(dat)
  29104. //} else {
  29105. // fmt.Println(err)
  29106. //}
  29107. //userJSONBytes2, _ := json.Marshal(dat2)
  29108. //var res2 models.Result3260
  29109. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29110. // utils.ErrorLog("解析失败:%v", err)
  29111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29112. // return
  29113. //}
  29114. //if res2.Infcode == 0 {
  29115. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29116. // var dat2 map[string]interface{}
  29117. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29118. // fmt.Println(dat)
  29119. // } else {
  29120. // fmt.Println(err)
  29121. // }
  29122. // c.ServeSuccessJSON(map[string]interface{}{
  29123. // "list": res2.Output.Data,
  29124. // })
  29125. //}
  29126. }
  29127. func (c *HisApiController) ComfirmAllopatry() {
  29128. year := c.GetString("year")
  29129. month := c.GetString("month")
  29130. admin_user_id, _ := c.GetInt64("admin_user_id")
  29131. adminUser := c.GetAdminUserInfo()
  29132. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29133. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29134. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29135. var dat map[string]interface{}
  29136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29137. fmt.Println(dat)
  29138. } else {
  29139. fmt.Println(err)
  29140. }
  29141. userJSONBytes, _ := json.Marshal(dat)
  29142. var res models.Result9001
  29143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29144. utils.ErrorLog("解析失败:%v", err)
  29145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29146. return
  29147. }
  29148. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29149. var dat2 map[string]interface{}
  29150. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29151. fmt.Println(dat)
  29152. } else {
  29153. fmt.Println(err)
  29154. }
  29155. userJSONBytes2, _ := json.Marshal(dat2)
  29156. var res2 models.Result3260
  29157. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29158. utils.ErrorLog("解析失败:%v", err)
  29159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29160. return
  29161. }
  29162. //if res2.Infcode == 0 {
  29163. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29164. // var dat map[string]interface{}
  29165. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29166. // fmt.Println(dat)
  29167. // } else {
  29168. // fmt.Println(err)
  29169. // }
  29170. // userJSONBytes, _ := json.Marshal(dat)
  29171. // var res3 models.Result3261
  29172. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  29173. // utils.ErrorLog("解析失败:%v", err)
  29174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29175. // return
  29176. // }
  29177. //
  29178. // if res3.Infcode == 0 {
  29179. // record := &models.HisYidiClearRecord{
  29180. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29181. // Ctime: time.Now().Unix(),
  29182. // Mtime: time.Now().Unix(),
  29183. // Status: 1,
  29184. // MsgId: msgId,
  29185. // }
  29186. // service.SaveClearRecord(record)
  29187. // c.ServeSuccessJSON(map[string]interface{}{
  29188. // "msg": "提取成功",
  29189. // })
  29190. // }
  29191. //}
  29192. }
  29193. func (c *HisApiController) RefundAllopatry() {
  29194. year := c.GetString("year")
  29195. month := c.GetString("month")
  29196. //id, _ := c.GetInt64("id")
  29197. admin_user_id, _ := c.GetInt64("admin_user_id")
  29198. adminUser := c.GetAdminUserInfo()
  29199. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29200. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29201. //record, _ := service.GetClearRecordById(id)
  29202. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29203. var dat map[string]interface{}
  29204. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29205. fmt.Println(dat)
  29206. } else {
  29207. fmt.Println(err)
  29208. }
  29209. userJSONBytes, _ := json.Marshal(dat)
  29210. var res models.Result9001
  29211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29212. utils.ErrorLog("解析失败:%v", err)
  29213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29214. return
  29215. }
  29216. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29217. var dat2 map[string]interface{}
  29218. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29219. fmt.Println(dat)
  29220. } else {
  29221. fmt.Println(err)
  29222. }
  29223. userJSONBytes2, _ := json.Marshal(dat2)
  29224. var empty ResultFourteen
  29225. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29226. utils.ErrorLog("解析失败:%v", err)
  29227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29228. return
  29229. }
  29230. if empty.Infcode == 0 {
  29231. c.ServeSuccessJSON(map[string]interface{}{
  29232. "msg": "撤销成功",
  29233. })
  29234. return
  29235. }
  29236. }
  29237. func (c *HisApiController) ReversalOtherData() {
  29238. var customData []*CustomData
  29239. custom := &CustomData{
  29240. MsgId: "H44022900158202103301714472004",
  29241. PsnNo: "44020000001101329945",
  29242. Info: "2208",
  29243. }
  29244. customData = append(customData, custom)
  29245. custom1 := &CustomData{
  29246. MsgId: "H4402290015820210330172057803",
  29247. PsnNo: "44020000001101161813",
  29248. Info: "2208",
  29249. }
  29250. customData = append(customData, custom1)
  29251. custom2 := &CustomData{
  29252. MsgId: "H44022900158202103301705198813",
  29253. PsnNo: "44190000133097375417",
  29254. Info: "2208",
  29255. }
  29256. customData = append(customData, custom2)
  29257. custom3 := &CustomData{
  29258. MsgId: "H44022900158202103301715524756",
  29259. PsnNo: "44020000001100187221",
  29260. Info: "2208",
  29261. }
  29262. customData = append(customData, custom3)
  29263. custom4 := &CustomData{
  29264. MsgId: "H44022900158202103301730376224",
  29265. PsnNo: "44020000001101959155",
  29266. Info: "2208",
  29267. }
  29268. customData = append(customData, custom4)
  29269. custom5 := &CustomData{
  29270. MsgId: "H44022900158202103301748008725",
  29271. PsnNo: "44020000001104246641",
  29272. Info: "2208",
  29273. }
  29274. customData = append(customData, custom5)
  29275. custom6 := &CustomData{
  29276. MsgId: "H44022900158202103301718096755",
  29277. PsnNo: "44020000001102211860",
  29278. Info: "2208",
  29279. }
  29280. customData = append(customData, custom6)
  29281. custom7 := &CustomData{
  29282. MsgId: "H44022900158202103301736551640",
  29283. PsnNo: "44020000001102687718",
  29284. Info: "2208",
  29285. }
  29286. customData = append(customData, custom7)
  29287. custom8 := &CustomData{
  29288. MsgId: "H44022900158202103301743097676",
  29289. PsnNo: "44020000001102127785",
  29290. Info: "2208",
  29291. }
  29292. customData = append(customData, custom8)
  29293. custom9 := &CustomData{
  29294. MsgId: "H44022900158202103301712304203",
  29295. PsnNo: "44020000001101518097",
  29296. Info: "2208",
  29297. }
  29298. customData = append(customData, custom9)
  29299. custom10 := &CustomData{
  29300. MsgId: "H44022900158202103301738448785",
  29301. PsnNo: "44020000001100500813",
  29302. Info: "2208",
  29303. }
  29304. customData = append(customData, custom10)
  29305. custom11 := &CustomData{
  29306. MsgId: "H44022900158202103301732455843",
  29307. PsnNo: "44020000001102690557",
  29308. Info: "2208",
  29309. }
  29310. customData = append(customData, custom11)
  29311. custom12 := &CustomData{
  29312. MsgId: "H44022900158202103301745421708",
  29313. PsnNo: "44020000001102211928",
  29314. Info: "2208",
  29315. }
  29316. customData = append(customData, custom12)
  29317. custom1212 := &CustomData{
  29318. MsgId: "H440229001582021033017351627",
  29319. PsnNo: "44020000001102481733",
  29320. Info: "2208",
  29321. }
  29322. customData = append(customData, custom1212)
  29323. custom13 := &CustomData{
  29324. MsgId: "H44022900158202103301740327951",
  29325. PsnNo: "44020000001103174866",
  29326. Info: "2208",
  29327. }
  29328. customData = append(customData, custom13)
  29329. custom14 := &CustomData{
  29330. MsgId: "H4402290015820210330174922668",
  29331. PsnNo: "44020000001102927272",
  29332. Info: "2208",
  29333. }
  29334. customData = append(customData, custom14)
  29335. custom15 := &CustomData{
  29336. MsgId: "H44022900158202103301752362273",
  29337. PsnNo: "44020000001102942890",
  29338. Info: "2208",
  29339. }
  29340. customData = append(customData, custom15)
  29341. custom16 := &CustomData{
  29342. MsgId: "H44022900158202103301751082917",
  29343. PsnNo: "44020000001101662162",
  29344. Info: "2208",
  29345. }
  29346. customData = append(customData, custom16)
  29347. custom17 := &CustomData{
  29348. MsgId: "H44022900158202103301754147728",
  29349. PsnNo: "44020000000229014511",
  29350. Info: "2208",
  29351. }
  29352. customData = append(customData, custom17)
  29353. adminUser := c.GetAdminUserInfo()
  29354. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29355. for _, item := range customData {
  29356. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29357. fmt.Println(result)
  29358. }
  29359. }
  29360. func PathExists(path string) (bool, error) {
  29361. _, err := os.Stat(path)
  29362. if err == nil {
  29363. return true, nil
  29364. }
  29365. if os.IsNotExist(err) {
  29366. return false, nil
  29367. }
  29368. return false, err
  29369. }
  29370. // 创建文件夹
  29371. func Mkdir(dir string) {
  29372. // 创建文件夹
  29373. exist, err := PathExists(dir)
  29374. if err != nil {
  29375. fmt.Println(err.Error())
  29376. } else {
  29377. if exist {
  29378. fmt.Println(dir + "文件夹已存在!")
  29379. } else {
  29380. // 文件夹名称,权限
  29381. err := os.Mkdir(dir, os.ModePerm)
  29382. if err != nil {
  29383. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29384. } else {
  29385. fmt.Println(dir + "文件夹创建成功!")
  29386. }
  29387. }
  29388. }
  29389. }
  29390. // 压缩文件
  29391. func Zip(srcFile string, destZip string) error {
  29392. zipfile, err := os.Create(destZip)
  29393. if err != nil {
  29394. return err
  29395. }
  29396. defer zipfile.Close()
  29397. archive := zip.NewWriter(zipfile)
  29398. defer archive.Close()
  29399. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29400. if err != nil {
  29401. return err
  29402. }
  29403. header, err := zip.FileInfoHeader(info)
  29404. if err != nil {
  29405. return err
  29406. }
  29407. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29408. // header.Name = path
  29409. if info.IsDir() {
  29410. header.Name += "/"
  29411. } else {
  29412. header.Method = zip.Deflate
  29413. }
  29414. writer, err := archive.CreateHeader(header)
  29415. if err != nil {
  29416. return err
  29417. }
  29418. if !info.IsDir() {
  29419. file, err := os.Open(path)
  29420. if err != nil {
  29421. return err
  29422. }
  29423. defer file.Close()
  29424. _, err = io.Copy(writer, file)
  29425. }
  29426. return err
  29427. })
  29428. return err
  29429. }
  29430. func ReadFile(filePath string) []byte {
  29431. f, err := os.Open(filePath)
  29432. if err != nil {
  29433. fmt.Println("read file fail", err)
  29434. return nil
  29435. }
  29436. defer f.Close()
  29437. fd, err := ioutil.ReadAll(f)
  29438. if err != nil {
  29439. fmt.Println("read to fd fail", err)
  29440. return nil
  29441. }
  29442. return fd
  29443. }
  29444. func saveLogq(result string, request string, infno string, desc string) {
  29445. dir := "日志"
  29446. utils.Mkdir(dir)
  29447. month := time.Unix(1557042972, 0).Format("1")
  29448. year := time.Now().Format("2006")
  29449. month = time.Now().Format("01")
  29450. day := time.Now().Format("02")
  29451. hour := time.Now().Format("15")
  29452. min := time.Now().Format("04")
  29453. sec := time.Now().Format("05")
  29454. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29455. file := year + month + day + "_log"
  29456. file_name := file + ".txt"
  29457. file_path := "日志" + "/" + file_name
  29458. exist, _ := utils.PathExists(file_path)
  29459. if exist { //存在
  29460. fmt.Println("存在")
  29461. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29462. if err != nil {
  29463. fmt.Println("read fail")
  29464. }
  29465. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29466. n, _ := f.Seek(0, 2)
  29467. _, err = f.WriteAt([]byte(content), n)
  29468. } else { //不存在
  29469. fmt.Println("文件不存在,创建文件")
  29470. f, err := os.Create("日志" + "/" + file_name)
  29471. defer f.Close()
  29472. if err != nil {
  29473. } else {
  29474. _, err = f.Write([]byte("记录日志"))
  29475. }
  29476. }
  29477. }
  29478. func saveLog(result string, request string, infno string, desc string) {
  29479. org_id, _ := beego.AppConfig.Int64("org_id")
  29480. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29481. dir := miConfig.OrgName + "日志"
  29482. utils.Mkdir(dir)
  29483. month := time.Unix(1557042972, 0).Format("1")
  29484. year := time.Now().Format("2006")
  29485. month = time.Now().Format("01")
  29486. day := time.Now().Format("02")
  29487. hour := time.Now().Format("15")
  29488. min := time.Now().Format("04")
  29489. sec := time.Now().Format("05")
  29490. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29491. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29492. file_name := file + ".txt"
  29493. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29494. exist, _ := utils.PathExists(file_path)
  29495. if exist { //存在
  29496. fmt.Println("存在")
  29497. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29498. if err != nil {
  29499. fmt.Println("read fail")
  29500. }
  29501. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29502. n, _ := f.Seek(0, 2)
  29503. _, err = f.WriteAt([]byte(content), n)
  29504. } else { //不存在
  29505. fmt.Println("文件不存在,创建文件")
  29506. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29507. defer f.Close()
  29508. if err != nil {
  29509. } else {
  29510. _, err = f.Write([]byte("记录日志"))
  29511. }
  29512. }
  29513. }
  29514. type Charset string
  29515. const (
  29516. UTF8 = Charset("UTF-8")
  29517. GB18030 = Charset("GB18030")
  29518. )
  29519. func ConvertToString(src string, srcCode string, tagCode string) string {
  29520. srcCoder := mahonia.NewDecoder(srcCode)
  29521. srcResult := srcCoder.ConvertString(src)
  29522. tagCoder := mahonia.NewDecoder(tagCode)
  29523. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29524. result := string(cdata)
  29525. return result
  29526. }
  29527. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29528. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29529. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29530. var token string
  29531. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29532. var api string
  29533. if miConfig.MdtrtareaAdmvs == "320921" {
  29534. 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 +
  29535. "&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
  29536. fmt.Println(api)
  29537. } else {
  29538. 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 +
  29539. "&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
  29540. }
  29541. resp, requestErr := http.Get(api)
  29542. if requestErr != nil {
  29543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29544. return ""
  29545. }
  29546. body, ioErr := ioutil.ReadAll(resp.Body)
  29547. if ioErr != nil {
  29548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29550. return ""
  29551. }
  29552. var respJSON map[string]interface{}
  29553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29556. return ""
  29557. }
  29558. var status string
  29559. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29560. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29561. var res ResultTwo //1101结果
  29562. var res10265 ResultTwo10265 //1101结果
  29563. if status == "0" { //读卡成功
  29564. var card_info string //卡信息
  29565. var busi_card_info string
  29566. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29567. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29568. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29569. fmt.Println(card_info)
  29570. fmt.Println(busi_card_info)
  29571. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29572. result, _ := json.Marshal(respJSON)
  29573. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29574. utils.ErrorLog("解析失败:%v", err)
  29575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29576. return ""
  29577. }
  29578. res.ErrMsg = res10265.ErrMsg
  29579. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29580. res.Infcode = infocode
  29581. res.Output = res10265.Output
  29582. res.InfRefmsgid = res10265.InfRefmsgid
  29583. if res.Infcode == 0 {
  29584. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29585. if err == gorm.ErrRecordNotFound {
  29586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29587. return ""
  29588. } else if err != nil {
  29589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29590. return ""
  29591. } else {
  29592. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29593. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29594. infoStr := string(Iinfos)
  29595. idetinfoStr := string(Idetinfos)
  29596. psn := &models.HisPsn{
  29597. PsnNo: res.Output.Baseinfo.PsnNo,
  29598. PatientId: patient.ID,
  29599. Certno: res.Output.Baseinfo.Certno,
  29600. Gend: res.Output.Baseinfo.Gend,
  29601. Naty: res.Output.Baseinfo.Naty,
  29602. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29603. PsnName: res.Output.Baseinfo.PsnName,
  29604. Idetinfo: idetinfoStr,
  29605. Insuinfo: infoStr,
  29606. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29607. CardInfo: card_info,
  29608. VerifyNumber: token,
  29609. }
  29610. service.CreateHisPsn(psn)
  29611. return token
  29612. }
  29613. }
  29614. } else {
  29615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29616. return ""
  29617. }
  29618. } else { //读卡失败
  29619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29620. return ""
  29621. }
  29622. return token
  29623. }
  29624. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29625. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29626. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29627. var token string
  29628. var api string
  29629. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29630. "&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
  29631. fmt.Println(api)
  29632. resp, requestErr := http.Get(api)
  29633. if requestErr != nil {
  29634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29635. return ""
  29636. }
  29637. body, ioErr := ioutil.ReadAll(resp.Body)
  29638. if ioErr != nil {
  29639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29641. return ""
  29642. }
  29643. var respJSON map[string]interface{}
  29644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29647. return ""
  29648. }
  29649. var status string
  29650. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29651. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29652. var res ResultTwo //1101结果
  29653. if status == "1" { //读卡成功
  29654. var card_info string //卡信息
  29655. var busi_card_info string
  29656. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29657. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29658. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29659. fmt.Println(card_info)
  29660. fmt.Println(busi_card_info)
  29661. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29662. result, _ := json.Marshal(respJSON)
  29663. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29664. utils.ErrorLog("解析失败:%v", err)
  29665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29666. return ""
  29667. }
  29668. if res.Infcode == 0 {
  29669. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29670. if err == gorm.ErrRecordNotFound {
  29671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29672. return ""
  29673. } else if err != nil {
  29674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29675. return ""
  29676. } else {
  29677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29679. infoStr := string(Iinfos)
  29680. idetinfoStr := string(Idetinfos)
  29681. psn := &models.HisPsn{
  29682. PsnNo: res.Output.Baseinfo.PsnNo,
  29683. PatientId: patient.ID,
  29684. Certno: res.Output.Baseinfo.Certno,
  29685. Gend: res.Output.Baseinfo.Gend,
  29686. Naty: res.Output.Baseinfo.Naty,
  29687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29688. PsnName: res.Output.Baseinfo.PsnName,
  29689. Idetinfo: idetinfoStr,
  29690. Insuinfo: infoStr,
  29691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29692. CardInfo: card_info,
  29693. VerifyNumber: token,
  29694. }
  29695. service.CreateHisPsn(psn)
  29696. return token
  29697. }
  29698. }
  29699. } else {
  29700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29701. return ""
  29702. }
  29703. return token
  29704. }
  29705. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29706. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29707. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29708. var token string
  29709. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29710. var api string
  29711. if miConfig.MdtrtareaAdmvs == "320921" {
  29712. 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 +
  29713. "&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
  29714. fmt.Println(api)
  29715. } else {
  29716. 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 +
  29717. "&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
  29718. }
  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. var status string
  29737. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29738. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29739. var res ResultTwo //1101结果
  29740. var res10265 ResultTwo10265 //1101结果
  29741. if status == "0" { //读卡成功
  29742. var card_info string //卡信息
  29743. var busi_card_info string
  29744. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29745. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29746. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29747. fmt.Println(card_info)
  29748. fmt.Println(busi_card_info)
  29749. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29750. result, _ := json.Marshal(respJSON)
  29751. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29752. utils.ErrorLog("解析失败:%v", err)
  29753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29754. return ""
  29755. }
  29756. res.ErrMsg = res10265.ErrMsg
  29757. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29758. res.Infcode = infocode
  29759. res.Output = res10265.Output
  29760. res.InfRefmsgid = res10265.InfRefmsgid
  29761. if res.Infcode == 0 {
  29762. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29763. if err == gorm.ErrRecordNotFound {
  29764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29765. return ""
  29766. } else if err != nil {
  29767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29768. return ""
  29769. } else {
  29770. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29771. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29772. infoStr := string(Iinfos)
  29773. idetinfoStr := string(Idetinfos)
  29774. psn := &models.HisPsn{
  29775. PsnNo: res.Output.Baseinfo.PsnNo,
  29776. PatientId: patient.ID,
  29777. Certno: res.Output.Baseinfo.Certno,
  29778. Gend: res.Output.Baseinfo.Gend,
  29779. Naty: res.Output.Baseinfo.Naty,
  29780. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29781. PsnName: res.Output.Baseinfo.PsnName,
  29782. Idetinfo: idetinfoStr,
  29783. Insuinfo: infoStr,
  29784. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29785. CardInfo: card_info,
  29786. VerifyNumber: token,
  29787. }
  29788. service.CreateHisPsn(psn)
  29789. return token
  29790. }
  29791. }
  29792. } else {
  29793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29794. return ""
  29795. }
  29796. } else { //读卡失败
  29797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29798. return ""
  29799. }
  29800. return token
  29801. }
  29802. func DeleteExtraSpaceTwo(s string) string {
  29803. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29804. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29805. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29806. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29807. s2 := make([]byte, len(s1)) //定义字符数组切片
  29808. copy(s2, s1) //将字符串复制到切片
  29809. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29810. for len(spc_index) > 0 { //找到适配项
  29811. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29812. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29813. }
  29814. return string(s2)
  29815. }
  29816. func Remove0000(s string) string {
  29817. str := make([]rune, 0, len(s))
  29818. for _, v := range []rune(s) {
  29819. if v == 0 {
  29820. continue
  29821. }
  29822. str = append(str, v)
  29823. }
  29824. return string(str)
  29825. }
  29826. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29827. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29828. readCard := DllDef.MustFindProc("EcQuery")
  29829. pCardInfo := make([]byte, 8192)
  29830. pBusiCardInfo := make([]byte, 8192)
  29831. data := make(map[string]interface{})
  29832. //pData := make(map[string]interface{})
  29833. inputData := make(map[string]interface{})
  29834. inputData["orgId"] = code
  29835. inputData["businessType"] = "01101"
  29836. inputData["operatorId"] = operator_id
  29837. inputData["operatorName"] = operator_name
  29838. inputData["officeId"] = "001"
  29839. inputData["officeName"] = "血透室"
  29840. //
  29841. data["data"] = inputData
  29842. data["transType"] = "ec.query"
  29843. data["orgId"] = code
  29844. bytesData, _ := json.Marshal(data)
  29845. pCardInfo = bytesData
  29846. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  29847. fmt.Println(ret2)
  29848. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  29849. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  29850. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  29851. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  29852. if ret2 != 0 {
  29853. return "", ""
  29854. }
  29855. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  29856. }
  29857. func DeleteExtraSpace(s string) string {
  29858. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29859. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29860. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29861. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29862. s2 := make([]byte, len(s1)) //定义字符数组切片
  29863. copy(s2, s1) //将字符串复制到切片
  29864. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29865. for len(spc_index) > 0 { //找到适配项
  29866. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29867. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29868. }
  29869. return string(s2)
  29870. }
  29871. // 对账
  29872. func (c *HisApiController) Post3202() {
  29873. start_time := c.GetString("start_time")
  29874. end_time := c.GetString("end_time")
  29875. //insutype := c.GetString("insutype")
  29876. clr_type := c.GetString("clr_type")
  29877. clr_org := c.GetString("clr_optins")
  29878. admin_user_id, _ := c.GetInt64("admin_user_id")
  29879. adminUser := c.GetAdminUserInfo()
  29880. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29881. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29882. if len(clr_org) == 0 {
  29883. clr_org = miConfig.MdtrtareaAdmvs
  29884. }
  29885. timeLayout := "2006-01-02"
  29886. loc, _ := time.LoadLocation("Local")
  29887. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29888. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29889. var orders []*models.HisOrder
  29890. if clr_org == "421300" {
  29891. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29892. } else {
  29893. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29894. }
  29895. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29896. //fixmedins_setl_cnt := int64(len(orders))
  29897. var medfee_sumamt float64
  29898. var acct_pay float64
  29899. var fund_pay_sumamt float64
  29900. for _, item := range orders {
  29901. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29902. acct_pay = acct_pay + item.AcctPay
  29903. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29904. }
  29905. //var medfee_sumamt_two float64
  29906. //var acct_pay_two float64
  29907. //var fund_pay_sumamt_two float64
  29908. //for _, item := range orders_two {
  29909. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29910. // acct_pay_two = acct_pay_two + item.AcctPay
  29911. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29912. //}
  29913. //var user_name string
  29914. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29915. //if role.ID == 0 {
  29916. // user_name = "xxx"
  29917. //} else {
  29918. // user_name = role.UserName
  29919. //}
  29920. var res ResultSix
  29921. if config.IsOpen == 1 {
  29922. var bps []*models.BusinessParamsTwo
  29923. var bp models.BusinessParamsTwo
  29924. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29925. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29926. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29927. bp.MedfeeSumamt = medfee_sumamt_str
  29928. bp.AcctPay = acct_pay_str
  29929. bp.FundPaySumamt = fund_pay_sumamt_str
  29930. bp.Insutype = ""
  29931. bp.StmtBegndate = start_time
  29932. bp.ClrType = clr_type
  29933. bp.SetlOptins = clr_org
  29934. bp.StmtEnddate = end_time
  29935. bps = append(bps, &bp)
  29936. data := make(map[string]interface{})
  29937. data["bps"] = bps
  29938. data["org_name"] = miConfig.OrgName
  29939. data["doctor"] = role.UserName
  29940. data["fixmedins_code"] = miConfig.Code
  29941. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29942. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29943. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29944. if miConfig.MdtrtareaAdmvs == "421300" {
  29945. client := &http.Client{}
  29946. bytesData, _ := json.Marshal(data)
  29947. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29948. resp, _ := client.Do(req)
  29949. defer resp.Body.Close()
  29950. body, ioErr := ioutil.ReadAll(resp.Body)
  29951. if ioErr != nil {
  29952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29954. return
  29955. }
  29956. var respJSON map[string]interface{}
  29957. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29960. return
  29961. }
  29962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29963. userJSONBytes, _ := json.Marshal(respJSON)
  29964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29965. utils.ErrorLog("解析失败:%v", err)
  29966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29967. return
  29968. }
  29969. }
  29970. if miConfig.MdtrtareaAdmvs == "420200" {
  29971. client := &http.Client{}
  29972. bytesData, _ := json.Marshal(data)
  29973. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29974. resp, _ := client.Do(req)
  29975. defer resp.Body.Close()
  29976. body, ioErr := ioutil.ReadAll(resp.Body)
  29977. if ioErr != nil {
  29978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29980. return
  29981. }
  29982. var respJSON map[string]interface{}
  29983. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29986. return
  29987. }
  29988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29989. userJSONBytes, _ := json.Marshal(respJSON)
  29990. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29991. utils.ErrorLog("解析失败:%v", err)
  29992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29993. return
  29994. }
  29995. }
  29996. if miConfig.MdtrtareaAdmvs == "421182" {
  29997. client := &http.Client{}
  29998. bytesData, _ := json.Marshal(data)
  29999. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  30000. resp, _ := client.Do(req)
  30001. defer resp.Body.Close()
  30002. body, ioErr := ioutil.ReadAll(resp.Body)
  30003. if ioErr != nil {
  30004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30006. return
  30007. }
  30008. var respJSON map[string]interface{}
  30009. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30012. return
  30013. }
  30014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30015. userJSONBytes, _ := json.Marshal(respJSON)
  30016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30017. utils.ErrorLog("解析失败:%v", err)
  30018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30019. return
  30020. }
  30021. }
  30022. if res.Infcode == 0 {
  30023. c.ServeSuccessJSON(map[string]interface{}{
  30024. "msg": "发起成功",
  30025. })
  30026. } else {
  30027. c.ServeSuccessJSON(map[string]interface{}{
  30028. "failed_code": -10,
  30029. "msg": res.ErrMsg,
  30030. })
  30031. }
  30032. }
  30033. }
  30034. func (c *HisApiController) Post3202b() {
  30035. start_time := c.GetString("start_time")
  30036. end_time := c.GetString("end_time")
  30037. //insutype := c.GetString("insutype")
  30038. clr_type := c.GetString("clr_type")
  30039. clr_org := c.GetString("clr_optins")
  30040. admin_user_id, _ := c.GetInt64("admin_user_id")
  30041. adminUser := c.GetAdminUserInfo()
  30042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30043. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30044. if len(clr_org) == 0 {
  30045. clr_org = miConfig.MdtrtareaAdmvs
  30046. }
  30047. timeLayout := "2006-01-02"
  30048. loc, _ := time.LoadLocation("Local")
  30049. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30050. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30051. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30052. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30053. //fixmedins_setl_cnt := int64(len(orders))
  30054. var medfee_sumamt float64
  30055. var acct_pay float64
  30056. var fund_pay_sumamt float64
  30057. for _, item := range orders {
  30058. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30059. acct_pay = acct_pay + item.AcctPay
  30060. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30061. }
  30062. //var medfee_sumamt_two float64
  30063. //var acct_pay_two float64
  30064. //var fund_pay_sumamt_two float64
  30065. //for _, item := range orders_two {
  30066. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30067. // acct_pay_two = acct_pay_two + item.AcctPay
  30068. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30069. //}
  30070. //var user_name string
  30071. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30072. //if role.ID == 0 {
  30073. // user_name = "xxx"
  30074. //} else {
  30075. // user_name = role.UserName
  30076. //}
  30077. var res ResultSix
  30078. if config.IsOpen == 1 {
  30079. var bps []*models.BusinessParamsTwo
  30080. var bp models.BusinessParamsTwo
  30081. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30082. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30083. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30084. bp.MedfeeSumamt = medfee_sumamt_str
  30085. bp.AcctPay = acct_pay_str
  30086. bp.FundPaySumamt = fund_pay_sumamt_str
  30087. bp.Insutype = "390"
  30088. bp.StmtBegndate = start_time
  30089. bp.ClrType = clr_type
  30090. bp.SetlOptins = clr_org
  30091. bp.StmtEnddate = end_time
  30092. bps = append(bps, &bp)
  30093. data := make(map[string]interface{})
  30094. data["bps"] = bps
  30095. data["org_name"] = miConfig.OrgName
  30096. data["doctor"] = role.UserName
  30097. data["fixmedins_code"] = miConfig.Code
  30098. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30099. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30100. if miConfig.MdtrtareaAdmvs == "421300" {
  30101. client := &http.Client{}
  30102. bytesData, _ := json.Marshal(data)
  30103. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30104. resp, _ := client.Do(req)
  30105. defer resp.Body.Close()
  30106. body, ioErr := ioutil.ReadAll(resp.Body)
  30107. if ioErr != nil {
  30108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30110. return
  30111. }
  30112. var respJSON map[string]interface{}
  30113. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30116. return
  30117. }
  30118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30119. userJSONBytes, _ := json.Marshal(respJSON)
  30120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30121. utils.ErrorLog("解析失败:%v", err)
  30122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30123. return
  30124. }
  30125. }
  30126. if miConfig.MdtrtareaAdmvs == "420200" {
  30127. client := &http.Client{}
  30128. bytesData, _ := json.Marshal(data)
  30129. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30130. resp, _ := client.Do(req)
  30131. defer resp.Body.Close()
  30132. body, ioErr := ioutil.ReadAll(resp.Body)
  30133. if ioErr != nil {
  30134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30136. return
  30137. }
  30138. var respJSON map[string]interface{}
  30139. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30142. return
  30143. }
  30144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30145. userJSONBytes, _ := json.Marshal(respJSON)
  30146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30147. utils.ErrorLog("解析失败:%v", err)
  30148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30149. return
  30150. }
  30151. }
  30152. if miConfig.MdtrtareaAdmvs == "421182" {
  30153. client := &http.Client{}
  30154. bytesData, _ := json.Marshal(data)
  30155. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  30156. resp, _ := client.Do(req)
  30157. defer resp.Body.Close()
  30158. body, ioErr := ioutil.ReadAll(resp.Body)
  30159. if ioErr != nil {
  30160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30162. return
  30163. }
  30164. var respJSON map[string]interface{}
  30165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30168. return
  30169. }
  30170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30171. userJSONBytes, _ := json.Marshal(respJSON)
  30172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30173. utils.ErrorLog("解析失败:%v", err)
  30174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30175. return
  30176. }
  30177. }
  30178. if res.Infcode == 0 {
  30179. c.ServeSuccessJSON(map[string]interface{}{
  30180. "msg": "发起成功",
  30181. })
  30182. } else {
  30183. c.ServeSuccessJSON(map[string]interface{}{
  30184. "failed_code": -10,
  30185. "msg": res.ErrMsg,
  30186. })
  30187. }
  30188. }
  30189. }
  30190. func (c *HisApiController) Post1608() {
  30191. start_time := c.GetString("start_time")
  30192. end_time := c.GetString("end_time")
  30193. admin_user_id, _ := c.GetInt64("admin_user_id")
  30194. adminUser := c.GetAdminUserInfo()
  30195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30196. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30197. timeLayout := "2006-01-02"
  30198. loc, _ := time.LoadLocation("Local")
  30199. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30200. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30201. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30202. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30203. fixmedins_setl_cnt := int64(len(orders))
  30204. var medfee_sumamt float64
  30205. var func_smamt float64
  30206. for _, item := range orders {
  30207. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30208. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30209. }
  30210. times := strings.Split(start_time, "-")
  30211. time_tows := strings.Split(end_time, "-")
  30212. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30213. var res ResultSix
  30214. if config.IsOpen == 1 {
  30215. //var bps []*models.BusinessParamsTwo
  30216. //var bp models.BusinessParamsTwo
  30217. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30218. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30219. data := make(map[string]interface{})
  30220. data["org_name"] = miConfig.OrgName
  30221. data["doctor"] = role.UserName
  30222. data["func_smamt"] = func_smamt_str
  30223. data["fixmedins_code"] = miConfig.Code
  30224. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30225. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30226. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30227. data["medfee_sumamt"] = medfee_sumamt_str
  30228. data["start_time"] = times[0] + times[1] + times[2]
  30229. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30230. if miConfig.MdtrtareaAdmvs == "421300" {
  30231. client := &http.Client{}
  30232. bytesData, _ := json.Marshal(data)
  30233. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30234. resp, _ := client.Do(req)
  30235. defer resp.Body.Close()
  30236. body, ioErr := ioutil.ReadAll(resp.Body)
  30237. if ioErr != nil {
  30238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30240. return
  30241. }
  30242. var respJSON map[string]interface{}
  30243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30246. return
  30247. }
  30248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30249. userJSONBytes, _ := json.Marshal(respJSON)
  30250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30251. utils.ErrorLog("解析失败:%v", err)
  30252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30253. return
  30254. }
  30255. }
  30256. if miConfig.MdtrtareaAdmvs == "420200" {
  30257. client := &http.Client{}
  30258. bytesData, _ := json.Marshal(data)
  30259. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30260. resp, _ := client.Do(req)
  30261. defer resp.Body.Close()
  30262. body, ioErr := ioutil.ReadAll(resp.Body)
  30263. if ioErr != nil {
  30264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30266. return
  30267. }
  30268. var respJSON map[string]interface{}
  30269. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30272. return
  30273. }
  30274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30275. userJSONBytes, _ := json.Marshal(respJSON)
  30276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30277. utils.ErrorLog("解析失败:%v", err)
  30278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30279. return
  30280. }
  30281. }
  30282. if miConfig.MdtrtareaAdmvs == "421182" {
  30283. client := &http.Client{}
  30284. bytesData, _ := json.Marshal(data)
  30285. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30286. resp, _ := client.Do(req)
  30287. defer resp.Body.Close()
  30288. body, ioErr := ioutil.ReadAll(resp.Body)
  30289. if ioErr != nil {
  30290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30292. return
  30293. }
  30294. var respJSON map[string]interface{}
  30295. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30298. return
  30299. }
  30300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30301. userJSONBytes, _ := json.Marshal(respJSON)
  30302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30303. utils.ErrorLog("解析失败:%v", err)
  30304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30305. return
  30306. }
  30307. }
  30308. if res.Infcode == 0 {
  30309. c.ServeSuccessJSON(map[string]interface{}{
  30310. "msg": "发起成功",
  30311. })
  30312. } else {
  30313. c.ServeSuccessJSON(map[string]interface{}{
  30314. "failed_code": -10,
  30315. "msg": res.ErrMsg,
  30316. })
  30317. }
  30318. }
  30319. }
  30320. // 5.11.1.1【5262】结算信息按时间段查询
  30321. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30322. admin_user_id, _ := c.GetInt64("admin_user_id")
  30323. adminUser := c.GetAdminUserInfo()
  30324. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30325. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30326. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30327. var res Result5262
  30328. if config.IsOpen == 1 {
  30329. if miConfig.MdtrtareaAdmvs == "421300" {
  30330. data := make(map[string]interface{})
  30331. data["bps"] = bp
  30332. data["org_name"] = miConfig.OrgName
  30333. data["doctor"] = role.UserName
  30334. data["fixmedins_code"] = miConfig.Code
  30335. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30336. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30337. data["page"] = strconv.FormatInt(page, 10)
  30338. data["limit"] = strconv.FormatInt(limit, 10)
  30339. fmt.Println(data)
  30340. client := &http.Client{}
  30341. bytesData, _ := json.Marshal(data)
  30342. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30343. resp, _ := client.Do(req)
  30344. defer resp.Body.Close()
  30345. body, ioErr := ioutil.ReadAll(resp.Body)
  30346. if ioErr != nil {
  30347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30349. return
  30350. }
  30351. var respJSON map[string]interface{}
  30352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30355. return
  30356. }
  30357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30358. userJSONBytes, _ := json.Marshal(respJSON)
  30359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30360. utils.ErrorLog("解析失败:%v", err)
  30361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30362. return
  30363. }
  30364. }
  30365. if miConfig.MdtrtareaAdmvs == "420200" {
  30366. data := make(map[string]interface{})
  30367. data["bps"] = bp
  30368. data["org_name"] = miConfig.OrgName
  30369. data["doctor"] = role.UserName
  30370. data["fixmedins_code"] = miConfig.Code
  30371. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30372. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30373. data["page"] = strconv.FormatInt(page, 10)
  30374. data["limit"] = strconv.FormatInt(limit, 10)
  30375. fmt.Println(data)
  30376. client := &http.Client{}
  30377. bytesData, _ := json.Marshal(data)
  30378. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30379. resp, _ := client.Do(req)
  30380. defer resp.Body.Close()
  30381. body, ioErr := ioutil.ReadAll(resp.Body)
  30382. if ioErr != nil {
  30383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30385. return
  30386. }
  30387. var respJSON map[string]interface{}
  30388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30391. return
  30392. }
  30393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30394. userJSONBytes, _ := json.Marshal(respJSON)
  30395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30396. utils.ErrorLog("解析失败:%v", err)
  30397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30398. return
  30399. }
  30400. }
  30401. if miConfig.MdtrtareaAdmvs == "421182" {
  30402. data := make(map[string]interface{})
  30403. data["bps"] = bp
  30404. data["org_name"] = miConfig.OrgName
  30405. data["doctor"] = role.UserName
  30406. data["fixmedins_code"] = miConfig.Code
  30407. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30408. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30409. data["page"] = strconv.FormatInt(page, 10)
  30410. data["limit"] = strconv.FormatInt(limit, 10)
  30411. fmt.Println(data)
  30412. client := &http.Client{}
  30413. bytesData, _ := json.Marshal(data)
  30414. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30415. resp, _ := client.Do(req)
  30416. defer resp.Body.Close()
  30417. body, ioErr := ioutil.ReadAll(resp.Body)
  30418. if ioErr != nil {
  30419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30421. return
  30422. }
  30423. var respJSON map[string]interface{}
  30424. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30427. return
  30428. }
  30429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30430. userJSONBytes, _ := json.Marshal(respJSON)
  30431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30432. utils.ErrorLog("解析失败:%v", err)
  30433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30434. return
  30435. }
  30436. }
  30437. if res.Infcode == 0 {
  30438. c.ServeSuccessJSON(map[string]interface{}{
  30439. "order": res.Output.Result,
  30440. "total": res.Output.PageInfo.RecordCounts,
  30441. })
  30442. } else {
  30443. c.ServeSuccessJSON(map[string]interface{}{
  30444. "failed_code": -10,
  30445. "msg": res.ErrMsg,
  30446. })
  30447. }
  30448. }
  30449. }
  30450. // 5.11.1.2【5267】异地结算信息时间段查询
  30451. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30452. admin_user_id, _ := c.GetInt64("admin_user_id")
  30453. adminUser := c.GetAdminUserInfo()
  30454. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30455. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30456. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30457. var res Result5267
  30458. if config.IsOpen == 1 {
  30459. if miConfig.MdtrtareaAdmvs == "421300" {
  30460. data := make(map[string]interface{})
  30461. data["bps"] = bp
  30462. data["org_name"] = miConfig.OrgName
  30463. data["doctor"] = role.UserName
  30464. data["fixmedins_code"] = miConfig.Code
  30465. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30466. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30467. data["page"] = page
  30468. data["limit"] = limit
  30469. fmt.Println(data)
  30470. client := &http.Client{}
  30471. bytesData, _ := json.Marshal(data)
  30472. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30473. resp, _ := client.Do(req)
  30474. defer resp.Body.Close()
  30475. body, ioErr := ioutil.ReadAll(resp.Body)
  30476. if ioErr != nil {
  30477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30479. return
  30480. }
  30481. var respJSON map[string]interface{}
  30482. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30485. return
  30486. }
  30487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30488. userJSONBytes, _ := json.Marshal(respJSON)
  30489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30490. utils.ErrorLog("解析失败:%v", err)
  30491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30492. return
  30493. }
  30494. }
  30495. if miConfig.MdtrtareaAdmvs == "420200" {
  30496. data := make(map[string]interface{})
  30497. data["bps"] = bp
  30498. data["org_name"] = miConfig.OrgName
  30499. data["doctor"] = role.UserName
  30500. data["fixmedins_code"] = miConfig.Code
  30501. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30502. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30503. data["page"] = page
  30504. data["limit"] = limit
  30505. fmt.Println(data)
  30506. client := &http.Client{}
  30507. bytesData, _ := json.Marshal(data)
  30508. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30509. resp, _ := client.Do(req)
  30510. defer resp.Body.Close()
  30511. body, ioErr := ioutil.ReadAll(resp.Body)
  30512. if ioErr != nil {
  30513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30515. return
  30516. }
  30517. var respJSON map[string]interface{}
  30518. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30521. return
  30522. }
  30523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30524. userJSONBytes, _ := json.Marshal(respJSON)
  30525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30526. utils.ErrorLog("解析失败:%v", err)
  30527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30528. return
  30529. }
  30530. }
  30531. if miConfig.MdtrtareaAdmvs == "421182" {
  30532. data := make(map[string]interface{})
  30533. data["bps"] = bp
  30534. data["org_name"] = miConfig.OrgName
  30535. data["doctor"] = role.UserName
  30536. data["fixmedins_code"] = miConfig.Code
  30537. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30538. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30539. data["page"] = page
  30540. data["limit"] = limit
  30541. fmt.Println(data)
  30542. client := &http.Client{}
  30543. bytesData, _ := json.Marshal(data)
  30544. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30545. resp, _ := client.Do(req)
  30546. defer resp.Body.Close()
  30547. body, ioErr := ioutil.ReadAll(resp.Body)
  30548. if ioErr != nil {
  30549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30551. return
  30552. }
  30553. var respJSON map[string]interface{}
  30554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30557. return
  30558. }
  30559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30560. userJSONBytes, _ := json.Marshal(respJSON)
  30561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30562. utils.ErrorLog("解析失败:%v", err)
  30563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30564. return
  30565. }
  30566. }
  30567. if res.Infcode == 0 {
  30568. c.ServeSuccessJSON(map[string]interface{}{
  30569. "order": res.Output.Result,
  30570. "total": res.Output.PageInfo.RecordCounts,
  30571. })
  30572. } else {
  30573. c.ServeSuccessJSON(map[string]interface{}{
  30574. "failed_code": -10,
  30575. "msg": res.ErrMsg,
  30576. })
  30577. }
  30578. }
  30579. }
  30580. func (c *HisApiController) Post3501() {
  30581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30582. data := make(map[string]interface{})
  30583. var struct3501s []models.Struct3501
  30584. var struct3501 models.Struct3501
  30585. struct3501.OrgName = miConfig.OrgName
  30586. struct3501.AccessKey = miConfig.AccessKey
  30587. struct3501.RequestUrl = miConfig.Url
  30588. struct3501.SecretKey = miConfig.SecretKey
  30589. struct3501.ManuDate = "2022-08-17"
  30590. struct3501.FixmedinsBchno = ""
  30591. struct3501.ManuLotnum = ""
  30592. struct3501.RxFlag = "0"
  30593. struct3501.ExpyEnd = "2022-08-17"
  30594. struct3501.Invdate = "2022-08-17"
  30595. struct3501.InvCnt = "20.25"
  30596. struct3501.Memo = ""
  30597. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30598. struct3501.FixmedinsHilistId = miConfig.Code
  30599. struct3501.FixmedinsHilistName = miConfig.OrgName
  30600. struct3501s = append(struct3501s, struct3501)
  30601. data["struct_3501s"] = struct3501s
  30602. client := &http.Client{}
  30603. bytesData, _ := json.Marshal(data)
  30604. var req *http.Request
  30605. if miConfig.MdtrtareaAdmvs == "320921" {
  30606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30607. } else {
  30608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30609. }
  30610. resp, _ := client.Do(req)
  30611. defer resp.Body.Close()
  30612. body, ioErr := ioutil.ReadAll(resp.Body)
  30613. if ioErr != nil {
  30614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30616. return
  30617. }
  30618. var respJSON map[string]interface{}
  30619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30622. return
  30623. }
  30624. var res ResultSix
  30625. var resSix10265 ResultSix10265 //1101结果
  30626. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30627. result, _ := json.Marshal(respJSON)
  30628. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30629. utils.ErrorLog("解析失败:%v", err)
  30630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30631. return
  30632. }
  30633. res.InfRefmsgid = resSix10265.InfRefmsgid
  30634. res.Output = resSix10265.Output
  30635. res.ErrMsg = resSix10265.ErrMsg
  30636. res.Cainfo = resSix10265.Cainfo
  30637. res.WarnMsg = resSix10265.WarnMsg
  30638. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30639. res.Infcode = infocode
  30640. if infocode == 0 {
  30641. c.ServeSuccessJSON(map[string]interface{}{
  30642. "msg": "上传成功",
  30643. })
  30644. return
  30645. } else {
  30646. c.ServeSuccessJSON(map[string]interface{}{
  30647. "failed_code": -10,
  30648. "msg": res.ErrMsg,
  30649. })
  30650. return
  30651. }
  30652. }
  30653. func (c *HisApiController) Post3502() {
  30654. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30655. data := make(map[string]interface{})
  30656. var struct3502s []models.Struct3502
  30657. var struct3502 models.Struct3502
  30658. struct3502.OrgName = miConfig.OrgName
  30659. struct3502.AccessKey = miConfig.AccessKey
  30660. struct3502.RequestUrl = miConfig.Url
  30661. struct3502.SecretKey = miConfig.SecretKey
  30662. struct3502.ManuDate = "2022-08-15"
  30663. struct3502.FixmedinsBchno = ""
  30664. struct3502.ManuLotnum = ""
  30665. struct3502.RxFlag = "0"
  30666. struct3502.ExpyEnd = "2022-08-15"
  30667. struct3502.Invdate = "2022-08-15"
  30668. struct3502.InvCnt = "20.25"
  30669. struct3502.Memo = ""
  30670. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30671. struct3502.FixmedinsHilistId = miConfig.Code
  30672. struct3502.FixmedinsHilistName = miConfig.OrgName
  30673. struct3502s = append(struct3502s, struct3502)
  30674. data["struct_3502s"] = struct3502s
  30675. client := &http.Client{}
  30676. bytesData, _ := json.Marshal(data)
  30677. var req *http.Request
  30678. if miConfig.MdtrtareaAdmvs == "320921" {
  30679. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30680. } else {
  30681. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30682. }
  30683. resp, _ := client.Do(req)
  30684. defer resp.Body.Close()
  30685. body, ioErr := ioutil.ReadAll(resp.Body)
  30686. if ioErr != nil {
  30687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30689. return
  30690. }
  30691. var respJSON map[string]interface{}
  30692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30695. return
  30696. }
  30697. var res ResultSix
  30698. var resSix10265 ResultSix10265 //1101结果
  30699. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30700. result, _ := json.Marshal(respJSON)
  30701. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30702. utils.ErrorLog("解析失败:%v", err)
  30703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30704. return
  30705. }
  30706. res.InfRefmsgid = resSix10265.InfRefmsgid
  30707. res.Output = resSix10265.Output
  30708. res.ErrMsg = resSix10265.ErrMsg
  30709. res.Cainfo = resSix10265.Cainfo
  30710. res.WarnMsg = resSix10265.WarnMsg
  30711. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30712. res.Infcode = infocode
  30713. if infocode == 0 {
  30714. c.ServeSuccessJSON(map[string]interface{}{
  30715. "msg": "上传成功",
  30716. })
  30717. return
  30718. } else {
  30719. c.ServeSuccessJSON(map[string]interface{}{
  30720. "failed_code": -10,
  30721. "msg": res.ErrMsg,
  30722. })
  30723. return
  30724. }
  30725. }
  30726. func (c *HisApiController) Post3503() {
  30727. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30728. data := make(map[string]interface{})
  30729. var struct3501s []models.Struct3501
  30730. var struct3501 models.Struct3501
  30731. struct3501.OrgName = miConfig.OrgName
  30732. struct3501.AccessKey = miConfig.AccessKey
  30733. struct3501.RequestUrl = miConfig.Url
  30734. struct3501.SecretKey = miConfig.SecretKey
  30735. struct3501.ManuDate = "2022-08-15"
  30736. struct3501.FixmedinsBchno = ""
  30737. struct3501.ManuLotnum = ""
  30738. struct3501.RxFlag = "0"
  30739. struct3501.ExpyEnd = "2022-08-15"
  30740. struct3501.Invdate = "2022-08-15"
  30741. struct3501.InvCnt = "20.25"
  30742. struct3501.Memo = ""
  30743. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30744. struct3501.FixmedinsHilistId = miConfig.Code
  30745. struct3501.FixmedinsHilistName = miConfig.OrgName
  30746. struct3501s = append(struct3501s, struct3501)
  30747. data["struct_3501s"] = struct3501s
  30748. client := &http.Client{}
  30749. bytesData, _ := json.Marshal(data)
  30750. var req *http.Request
  30751. if miConfig.MdtrtareaAdmvs == "320921" {
  30752. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30753. } else {
  30754. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30755. }
  30756. resp, _ := client.Do(req)
  30757. defer resp.Body.Close()
  30758. body, ioErr := ioutil.ReadAll(resp.Body)
  30759. if ioErr != nil {
  30760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30762. return
  30763. }
  30764. var respJSON map[string]interface{}
  30765. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30768. return
  30769. }
  30770. var res ResultSix
  30771. var resSix10265 ResultSix10265 //1101结果
  30772. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30773. result, _ := json.Marshal(respJSON)
  30774. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30775. utils.ErrorLog("解析失败:%v", err)
  30776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30777. return
  30778. }
  30779. res.InfRefmsgid = resSix10265.InfRefmsgid
  30780. res.Output = resSix10265.Output
  30781. res.ErrMsg = resSix10265.ErrMsg
  30782. res.Cainfo = resSix10265.Cainfo
  30783. res.WarnMsg = resSix10265.WarnMsg
  30784. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30785. res.Infcode = infocode
  30786. if infocode == 0 {
  30787. c.ServeSuccessJSON(map[string]interface{}{
  30788. "msg": "上传成功",
  30789. })
  30790. return
  30791. } else {
  30792. c.ServeSuccessJSON(map[string]interface{}{
  30793. "failed_code": -10,
  30794. "msg": res.ErrMsg,
  30795. })
  30796. return
  30797. }
  30798. }
  30799. func (c *HisApiController) Post3504() {
  30800. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30801. data := make(map[string]interface{})
  30802. var struct3501s []models.Struct3501
  30803. var struct3501 models.Struct3501
  30804. struct3501.OrgName = miConfig.OrgName
  30805. struct3501.AccessKey = miConfig.AccessKey
  30806. struct3501.RequestUrl = miConfig.Url
  30807. struct3501.SecretKey = miConfig.SecretKey
  30808. struct3501.ManuDate = "2022-08-15"
  30809. struct3501.FixmedinsBchno = ""
  30810. struct3501.ManuLotnum = ""
  30811. struct3501.RxFlag = "0"
  30812. struct3501.ExpyEnd = "2022-08-15"
  30813. struct3501.Invdate = "2022-08-15"
  30814. struct3501.InvCnt = "20.25"
  30815. struct3501.Memo = ""
  30816. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30817. struct3501.FixmedinsHilistId = miConfig.Code
  30818. struct3501.FixmedinsHilistName = miConfig.OrgName
  30819. struct3501s = append(struct3501s, struct3501)
  30820. data["struct_3501s"] = struct3501s
  30821. client := &http.Client{}
  30822. bytesData, _ := json.Marshal(data)
  30823. var req *http.Request
  30824. if miConfig.MdtrtareaAdmvs == "320921" {
  30825. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30826. } else {
  30827. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30828. }
  30829. resp, _ := client.Do(req)
  30830. defer resp.Body.Close()
  30831. body, ioErr := ioutil.ReadAll(resp.Body)
  30832. if ioErr != nil {
  30833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30835. return
  30836. }
  30837. var respJSON map[string]interface{}
  30838. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30841. return
  30842. }
  30843. var res ResultSix
  30844. var resSix10265 ResultSix10265 //1101结果
  30845. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30846. result, _ := json.Marshal(respJSON)
  30847. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30848. utils.ErrorLog("解析失败:%v", err)
  30849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30850. return
  30851. }
  30852. res.InfRefmsgid = resSix10265.InfRefmsgid
  30853. res.Output = resSix10265.Output
  30854. res.ErrMsg = resSix10265.ErrMsg
  30855. res.Cainfo = resSix10265.Cainfo
  30856. res.WarnMsg = resSix10265.WarnMsg
  30857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30858. res.Infcode = infocode
  30859. if infocode == 0 {
  30860. c.ServeSuccessJSON(map[string]interface{}{
  30861. "msg": "上传成功",
  30862. })
  30863. return
  30864. } else {
  30865. c.ServeSuccessJSON(map[string]interface{}{
  30866. "failed_code": -10,
  30867. "msg": res.ErrMsg,
  30868. })
  30869. return
  30870. }
  30871. }
  30872. func (c *HisApiController) Post3505() {
  30873. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30874. data := make(map[string]interface{})
  30875. var struct3501s []models.Struct3501
  30876. var struct3501 models.Struct3501
  30877. struct3501.OrgName = miConfig.OrgName
  30878. struct3501.AccessKey = miConfig.AccessKey
  30879. struct3501.RequestUrl = miConfig.Url
  30880. struct3501.SecretKey = miConfig.SecretKey
  30881. struct3501.ManuDate = "2022-08-15"
  30882. struct3501.FixmedinsBchno = ""
  30883. struct3501.ManuLotnum = ""
  30884. struct3501.RxFlag = "0"
  30885. struct3501.ExpyEnd = "2022-08-15"
  30886. struct3501.Invdate = "2022-08-15"
  30887. struct3501.InvCnt = "20.25"
  30888. struct3501.Memo = ""
  30889. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30890. struct3501.FixmedinsHilistId = miConfig.Code
  30891. struct3501.FixmedinsHilistName = miConfig.OrgName
  30892. struct3501s = append(struct3501s, struct3501)
  30893. data["struct_3501s"] = struct3501s
  30894. client := &http.Client{}
  30895. bytesData, _ := json.Marshal(data)
  30896. var req *http.Request
  30897. if miConfig.MdtrtareaAdmvs == "320921" {
  30898. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30899. } else {
  30900. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30901. }
  30902. resp, _ := client.Do(req)
  30903. defer resp.Body.Close()
  30904. body, ioErr := ioutil.ReadAll(resp.Body)
  30905. if ioErr != nil {
  30906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30908. return
  30909. }
  30910. var respJSON map[string]interface{}
  30911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30914. return
  30915. }
  30916. var res ResultSix
  30917. var resSix10265 ResultSix10265 //1101结果
  30918. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30919. result, _ := json.Marshal(respJSON)
  30920. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30921. utils.ErrorLog("解析失败:%v", err)
  30922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30923. return
  30924. }
  30925. res.InfRefmsgid = resSix10265.InfRefmsgid
  30926. res.Output = resSix10265.Output
  30927. res.ErrMsg = resSix10265.ErrMsg
  30928. res.Cainfo = resSix10265.Cainfo
  30929. res.WarnMsg = resSix10265.WarnMsg
  30930. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30931. res.Infcode = infocode
  30932. if infocode == 0 {
  30933. c.ServeSuccessJSON(map[string]interface{}{
  30934. "msg": "上传成功",
  30935. })
  30936. return
  30937. } else {
  30938. c.ServeSuccessJSON(map[string]interface{}{
  30939. "failed_code": -10,
  30940. "msg": res.ErrMsg,
  30941. })
  30942. return
  30943. }
  30944. }
  30945. func (c *HisApiController) Post3506() {
  30946. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30947. data := make(map[string]interface{})
  30948. var struct3501s []models.Struct3501
  30949. var struct3501 models.Struct3501
  30950. struct3501.OrgName = miConfig.OrgName
  30951. struct3501.AccessKey = miConfig.AccessKey
  30952. struct3501.RequestUrl = miConfig.Url
  30953. struct3501.SecretKey = miConfig.SecretKey
  30954. struct3501.ManuDate = "2022-08-15"
  30955. struct3501.FixmedinsBchno = ""
  30956. struct3501.ManuLotnum = ""
  30957. struct3501.RxFlag = "0"
  30958. struct3501.ExpyEnd = "2022-08-15"
  30959. struct3501.Invdate = "2022-08-15"
  30960. struct3501.InvCnt = "20.25"
  30961. struct3501.Memo = ""
  30962. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30963. struct3501.FixmedinsHilistId = miConfig.Code
  30964. struct3501.FixmedinsHilistName = miConfig.OrgName
  30965. struct3501s = append(struct3501s, struct3501)
  30966. data["struct_3501s"] = struct3501s
  30967. client := &http.Client{}
  30968. bytesData, _ := json.Marshal(data)
  30969. var req *http.Request
  30970. if miConfig.MdtrtareaAdmvs == "320921" {
  30971. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30972. } else {
  30973. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30974. }
  30975. resp, _ := client.Do(req)
  30976. defer resp.Body.Close()
  30977. body, ioErr := ioutil.ReadAll(resp.Body)
  30978. if ioErr != nil {
  30979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30981. return
  30982. }
  30983. var respJSON map[string]interface{}
  30984. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30987. return
  30988. }
  30989. var res ResultSix
  30990. var resSix10265 ResultSix10265 //1101结果
  30991. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30992. result, _ := json.Marshal(respJSON)
  30993. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30994. utils.ErrorLog("解析失败:%v", err)
  30995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30996. return
  30997. }
  30998. res.InfRefmsgid = resSix10265.InfRefmsgid
  30999. res.Output = resSix10265.Output
  31000. res.ErrMsg = resSix10265.ErrMsg
  31001. res.Cainfo = resSix10265.Cainfo
  31002. res.WarnMsg = resSix10265.WarnMsg
  31003. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31004. res.Infcode = infocode
  31005. if infocode == 0 {
  31006. c.ServeSuccessJSON(map[string]interface{}{
  31007. "msg": "上传成功",
  31008. })
  31009. return
  31010. } else {
  31011. c.ServeSuccessJSON(map[string]interface{}{
  31012. "failed_code": -10,
  31013. "msg": res.ErrMsg,
  31014. })
  31015. return
  31016. }
  31017. }
  31018. func (c *HisApiController) Post3507() {
  31019. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31020. data := make(map[string]interface{})
  31021. var struct3501s []models.Struct3501
  31022. var struct3501 models.Struct3501
  31023. struct3501.OrgName = miConfig.OrgName
  31024. struct3501.AccessKey = miConfig.AccessKey
  31025. struct3501.RequestUrl = miConfig.Url
  31026. struct3501.SecretKey = miConfig.SecretKey
  31027. struct3501.ManuDate = "2022-08-15"
  31028. struct3501.FixmedinsBchno = ""
  31029. struct3501.ManuLotnum = ""
  31030. struct3501.RxFlag = "0"
  31031. struct3501.ExpyEnd = "2022-08-15"
  31032. struct3501.Invdate = "2022-08-15"
  31033. struct3501.InvCnt = "20.25"
  31034. struct3501.Memo = ""
  31035. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31036. struct3501.FixmedinsHilistId = miConfig.Code
  31037. struct3501.FixmedinsHilistName = miConfig.OrgName
  31038. struct3501s = append(struct3501s, struct3501)
  31039. data["struct_3501s"] = struct3501s
  31040. client := &http.Client{}
  31041. bytesData, _ := json.Marshal(data)
  31042. var req *http.Request
  31043. if miConfig.MdtrtareaAdmvs == "320921" {
  31044. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31045. } else {
  31046. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31047. }
  31048. resp, _ := client.Do(req)
  31049. defer resp.Body.Close()
  31050. body, ioErr := ioutil.ReadAll(resp.Body)
  31051. if ioErr != nil {
  31052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31054. return
  31055. }
  31056. var respJSON map[string]interface{}
  31057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31060. return
  31061. }
  31062. var res ResultSix
  31063. var resSix10265 ResultSix10265 //1101结果
  31064. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31065. result, _ := json.Marshal(respJSON)
  31066. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31067. utils.ErrorLog("解析失败:%v", err)
  31068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31069. return
  31070. }
  31071. res.InfRefmsgid = resSix10265.InfRefmsgid
  31072. res.Output = resSix10265.Output
  31073. res.ErrMsg = resSix10265.ErrMsg
  31074. res.Cainfo = resSix10265.Cainfo
  31075. res.WarnMsg = resSix10265.WarnMsg
  31076. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31077. res.Infcode = infocode
  31078. if infocode == 0 {
  31079. c.ServeSuccessJSON(map[string]interface{}{
  31080. "msg": "上传成功",
  31081. })
  31082. return
  31083. } else {
  31084. c.ServeSuccessJSON(map[string]interface{}{
  31085. "failed_code": -10,
  31086. "msg": res.ErrMsg,
  31087. })
  31088. return
  31089. }
  31090. }
  31091. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31092. // WebSocket服务器地址
  31093. serverURL := "ws://127.0.0.1:8899"
  31094. // 解析WebSocket服务器地址
  31095. u, err := url.Parse(serverURL)
  31096. if err != nil {
  31097. }
  31098. // 建立WebSocket连接
  31099. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31100. if err != nil {
  31101. }
  31102. defer conn.Close()
  31103. input2 := make(map[string]interface{})
  31104. input := make(map[string]interface{})
  31105. inputData := make(map[string]interface{})
  31106. inputData["orgId"] = code
  31107. inputData["businessType"] = "01101"
  31108. inputData["operatorId"] = operator_id
  31109. inputData["operatorName"] = operator_name
  31110. inputData["officeId"] = "001"
  31111. inputData["officeName"] = "血透室"
  31112. inputData["deviceType"] = ""
  31113. input["data"] = inputData
  31114. input["orgId"] = code
  31115. input["transType"] = "ec.query"
  31116. //if md == ""
  31117. if md[:4] == "4403" {
  31118. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31119. } else if md[:4] == "4401" {
  31120. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31121. } else {
  31122. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31123. }
  31124. input2["indata"] = input
  31125. fmt.Println(input2)
  31126. bytesData, _ := json.Marshal(input2)
  31127. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31128. if err != nil {
  31129. fmt.Println(err)
  31130. }
  31131. // 接收消息
  31132. _, receivedMessage, err := conn.ReadMessage()
  31133. if err != nil {
  31134. fmt.Println(err)
  31135. }
  31136. return "", string(receivedMessage)
  31137. }
  31138. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  31139. // WebSocket服务器地址
  31140. serverURL := "ws://127.0.0.1:8899"
  31141. // 解析WebSocket服务器地址
  31142. u, err := url.Parse(serverURL)
  31143. if err != nil {
  31144. }
  31145. // 建立WebSocket连接
  31146. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31147. if err != nil {
  31148. }
  31149. defer conn.Close()
  31150. input2 := make(map[string]interface{})
  31151. input := make(map[string]interface{})
  31152. inputData := make(map[string]interface{})
  31153. inputData["orgId"] = code
  31154. inputData["businessType"] = "01103"
  31155. inputData["operatorId"] = operator_id
  31156. inputData["operatorName"] = operator_name
  31157. inputData["officeId"] = "001"
  31158. inputData["officeName"] = "血透室"
  31159. inputData["deviceType"] = ""
  31160. input["data"] = inputData
  31161. input["orgId"] = code
  31162. input["transType"] = "ec.query"
  31163. //if md ==
  31164. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  31165. input2["indata"] = input
  31166. fmt.Println(input2)
  31167. bytesData, _ := json.Marshal(input2)
  31168. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31169. if err != nil {
  31170. fmt.Println(err)
  31171. }
  31172. // 接收消息
  31173. _, receivedMessage, err := conn.ReadMessage()
  31174. if err != nil {
  31175. fmt.Println(err)
  31176. }
  31177. return "", string(receivedMessage)
  31178. }
  31179. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31180. // WebSocket服务器地址
  31181. serverURL := "ws://127.0.0.1:8899"
  31182. // 解析WebSocket服务器地址
  31183. u, err := url.Parse(serverURL)
  31184. if err != nil {
  31185. }
  31186. // 建立WebSocket连接
  31187. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31188. if err != nil {
  31189. }
  31190. defer conn.Close()
  31191. input2 := make(map[string]interface{})
  31192. input := make(map[string]interface{})
  31193. inputData := make(map[string]interface{})
  31194. inputData["orgId"] = code
  31195. inputData["businessType"] = "01101"
  31196. inputData["operatorId"] = operator_id
  31197. inputData["operatorName"] = operator_name
  31198. inputData["officeId"] = "001"
  31199. inputData["officeName"] = "血透室"
  31200. inputData["deviceType"] = ""
  31201. input["data"] = inputData
  31202. input["orgId"] = code
  31203. input["transType"] = "ec.query"
  31204. //if md == ""
  31205. if md[:4] == "4403" {
  31206. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31207. } else if md[:4] == "4401" {
  31208. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31209. } else {
  31210. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31211. }
  31212. input2["indata"] = input
  31213. fmt.Println(input2)
  31214. bytesData, _ := json.Marshal(input2)
  31215. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31216. if err != nil {
  31217. fmt.Println(err)
  31218. }
  31219. // 接收消息
  31220. _, receivedMessage, err := conn.ReadMessage()
  31221. if err != nil {
  31222. fmt.Println(err)
  31223. }
  31224. return "", string(receivedMessage)
  31225. }
  31226. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31227. // WebSocket服务器地址
  31228. serverURL := "ws://127.0.0.1:8899"
  31229. // 解析WebSocket服务器地址
  31230. u, err := url.Parse(serverURL)
  31231. if err != nil {
  31232. }
  31233. // 建立WebSocket连接
  31234. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31235. if err != nil {
  31236. }
  31237. defer conn.Close()
  31238. input2 := make(map[string]interface{})
  31239. input := make(map[string]interface{})
  31240. inputData := make(map[string]interface{})
  31241. inputData["orgId"] = code
  31242. inputData["businessType"] = "01301"
  31243. inputData["operatorId"] = operator_id
  31244. inputData["operatorName"] = operator_name
  31245. inputData["officeId"] = "001"
  31246. inputData["officeName"] = "血透室"
  31247. inputData["deviceType"] = ""
  31248. input["data"] = inputData
  31249. input["orgId"] = code
  31250. input["transType"] = "ec.query"
  31251. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31252. input2["indata"] = input
  31253. bytesData, _ := json.Marshal(input2)
  31254. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31255. if err != nil {
  31256. fmt.Println(err)
  31257. }
  31258. // 接收消息
  31259. _, receivedMessage, err := conn.ReadMessage()
  31260. if err != nil {
  31261. fmt.Println(err)
  31262. }
  31263. return "", string(receivedMessage)
  31264. }
  31265. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31266. newArr = make([]string, 0)
  31267. for i := 0; i < len(arr); i++ {
  31268. repeat := false
  31269. for j := i + 1; j < len(arr); j++ {
  31270. if arr[i] == arr[j] {
  31271. repeat = true
  31272. break
  31273. }
  31274. }
  31275. if !repeat {
  31276. newArr = append(newArr, arr[i])
  31277. }
  31278. }
  31279. return
  31280. }
  31281. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31282. if len(idNumber) != 18 {
  31283. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31284. }
  31285. // 提取出生日期
  31286. year, err := strconv.Atoi(idNumber[6:10])
  31287. if err != nil {
  31288. return "", 0, err
  31289. }
  31290. month, err := strconv.Atoi(idNumber[10:12])
  31291. if err != nil {
  31292. return "", 0, err
  31293. }
  31294. day, err := strconv.Atoi(idNumber[12:14])
  31295. if err != nil {
  31296. return "", 0, err
  31297. }
  31298. // 格式化生日字符串
  31299. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31300. birthdateFormatted := birthdate.Format("2006-01-02")
  31301. // 计算年龄
  31302. today := time.Now()
  31303. age := today.Year() - birthdate.Year()
  31304. if today.YearDay() < birthdate.YearDay() {
  31305. age--
  31306. }
  31307. return birthdateFormatted, age, nil
  31308. }